ActiveX control userdraw in vb.net

  • Thread starter Thread starter Per Cramer
  • Start date Start date
P

Per Cramer

i am having a vb.net problem...

I am using an activex component from plexityhide. It is the phgant
control. I am upgrading my program from vb6 to vb.net. Now i am having
a big problem. The control has got a userdraw event for the
background. It returns a hdc and left,right,top,bottom value.

Now the problem is with the hdc. I contacted the manufacturer and
their sollution works good, but it is in C#. It is :

private void axphSchemaX1_OnUserDrawTime(object sender,
AxphGantXControl.IphSchemaXEvents_OnUserDrawTimeEvent e)
{
Graphics gr=System.Drawing.Graphics.FromHdc((IntPtr)e.theHDC);
gr.DrawLine(new Pen(Color.Beige,5),e.left,e.top,e.right,e.bottom);
gr.DrawLine(new Pen(Color.BlueViolet,5),e.right,e.top,e.left,e.bottom);
}

So it tried to convert this to vb.net and used :

Dim G As Graphics = Graphics.FromHdc(CType(e.theHDC, System.IntPtr))

G.DrawRectangle(New Pen(Color.Red, 5), e.left, e.top, e.right,
e.bottom)

But this doesn't work. Whatever i try i tells me that "Value of type
'integer' cannott be converted to 'System.IntPtr'
 
Hi,

Try this instead.

dim Hdc as new IntPtr(e.theHDC)
Dim G As Graphics = Graphics.FromHdc(Hdc)

Ken
------------------
i am having a vb.net problem...

I am using an activex component from plexityhide. It is the phgant
control. I am upgrading my program from vb6 to vb.net. Now i am having
a big problem. The control has got a userdraw event for the
background. It returns a hdc and left,right,top,bottom value.

Now the problem is with the hdc. I contacted the manufacturer and
their sollution works good, but it is in C#. It is :

private void axphSchemaX1_OnUserDrawTime(object sender,
AxphGantXControl.IphSchemaXEvents_OnUserDrawTimeEvent e)
{
Graphics gr=System.Drawing.Graphics.FromHdc((IntPtr)e.theHDC);
gr.DrawLine(new Pen(Color.Beige,5),e.left,e.top,e.right,e.bottom);
gr.DrawLine(new Pen(Color.BlueViolet,5),e.right,e.top,e.left,e.bottom);
}

So it tried to convert this to vb.net and used :




G.DrawRectangle(New Pen(Color.Red, 5), e.left, e.top, e.right,
e.bottom)

But this doesn't work. Whatever i try i tells me that "Value of type
'integer' cannott be converted to 'System.IntPtr'
 
Per,

Per Cramer said:
Dim G As Graphics = Graphics.FromHdc(CType(e.theHDC, System.IntPtr))
[...]
But this doesn't work. Whatever i try i tells me that "Value of type
'integer' cannott be converted to 'System.IntPtr'

\\\
Dim g As Graphics = Graphics.FromHdc(New IntPtr(e.theHDC))
///
 
Hi,

I tried both and keep getting the same error

But i got it fixed. I use :

Dim intPointer As Int32 = e.theHDC
Dim ipPtr As New IntPtr(intPointer)

Dim G As Graphics = Graphics.FromHdc(ipPtr)

Now it works

Regards,

per
 
Per Cramer said:
I tried both and keep getting the same error

But i got it fixed. I use :

Dim intPointer As Int32 = e.theHDC
Dim ipPtr As New IntPtr(intPointer)

Dim G As Graphics = Graphics.FromHdc(ipPtr)

Well, the code does exactly the same as the code posted by Ken an me, except
that it uses two variables which are not necessary.
 
I know the code does exactly the same as the previous samples, but like
i said before, the other way doesn't work.

I tried both the ways, the manufacturer tried both the ways and this is
a work around we got from microsoft.

Regards,

Per
 
Per Cramer said:
I tried both the ways, the manufacturer tried both the ways and this is
a work around we got from microsoft.

That's interesting :-).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top