473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ActiveX control userdraw in vb.net

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_OnUserDrawTimeEv ent e)
{
Graphics gr=System.Drawing.Graphics.FromHdc((IntPtr)e.theHD C);
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.bot tom);
}

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'
Nov 21 '05 #1
6 1081
Hi,

Try this instead.

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

Ken
------------------
"Per Cramer" <pe********@hotmail.com> wrote in message
news:cc**************************@posting.google.c om...
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_OnUserDrawTimeEv ent e)
{
Graphics gr=System.Drawing.Graphics.FromHdc((IntPtr)e.theHD C);
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.bot tom);
}

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'
Nov 21 '05 #2
Per,

"Per Cramer" <pe********@hotmail.com> schrieb:
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))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #4
"Per Cramer" <pe********@hotmail.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #6
"Per Cramer" <pe********@hotmail.com> schrieb:
I tried both the ways, the manufacturer tried both the ways and this is
a work around we got from microsoft.


That's interesting :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
2
by: Fie Fie Niles | last post by:
This one XP machine (with IE 6) is having a problem viewing any ActiveX controls (created on VB6) on the Internet Explorer browser. I put the same ActiveX control in a VB program, and when I run...
1
by: Anand Kale | last post by:
How to have ActiveX control called from Web Form in ASP.Net ? ActiveX control is written using VC++/MFC/ATL-COM. Also kindly answer following issues, 1. Also how to take care of issues about...
3
by: Jeffery Franzen | last post by:
Anyone know where the documentation is regarding Activex controls in asp web forms? I'm using VS.NET 2002 enterprise and am trying to use Activex controls in vb.net web form app. I do the add...
3
by: Weston Fryatt | last post by:
Simple question I hope.... How do I send data to and from an ASP.Net (server side) web page to a ActiveX Control (client side) embedded in a web browser??? What I need to do, is I have image...
7
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do...
1
by: Jayender | last post by:
Hi, I have an ActiveX control (to display the Images),I have added the reference of that in my web based applicaton .and added the ocx in my tool bar , but the viewer (activex component- ocx ) is...
6
by: Budhi Saputra Prasetya | last post by:
Hi All, I'm trying to display .NET Custom Control (created using Inherited Control) on an ASPX page, but no luck. I already registered the Control to Global Assembly Cache through .NET Framework...
6
by: hufaunder | last post by:
I have an ActiveX component that I want to use in a library that I am writing. As a first test I used the ActiveX component in a windows form application. Adding the component created: Ax.dll...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.