LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Convert I32 to .Net IntPtr?

I created an .Net Invoke that is linked to "System.Drawing.Image" Class, it convert HBITMAP handle to picture.
I get HBITMAP from other dll through a Windows Message (thats the Lparam in the picture).
 
The problem is that the HBITMAP from the dll is I32 and the .NET require IntPtr type, and i didnt succeded to cast I32 to IntPtr.
 
Please Help,
HaD
 
Image attached
0 Kudos
Message 1 of 15
(8,286 Views)
Help!
0 Kudos
Message 2 of 15
(8,260 Views)
Hi HaD,
i´m not sure, but maybe it works if you type cast it to the needed type.
 
Hope it helps.
Mike
0 Kudos
Message 3 of 15
(8,258 Views)
You cannot simply "cast" to a .NET datatype. You must use the proper constructor. In this case you need to use the constructor for IntPtr. Specifically, the one that accepts an integer as an argument:




Message Edited by smercurio_fc on 07-09-2008 09:19 AM
Message 4 of 15
(8,251 Views)
How you got constructor to intptr??? i cant find it.
0 Kudos
Message 5 of 15
(8,242 Views)
  1. Place a .NET constructor node on the block diagram.
  2. In the popup dialog select "mscorlib" from the list of assemblies. Make sure you select the right one in case you see more than one depending on how many .NET versions you may have. 
  3. In the "Objects" listbox expand "System".
  4. Scroll down until you see "IntPtr". Select it.
  5. In the "Constructors" listbox select the appropriate constructor, which in your case is IntPtr(Int32 value).
  6. Click OK
  7. Wire your integer constant to the "value" terminal.



Message Edited by smercurio_fc on 07-09-2008 11:29 AM
Message 6 of 15
(8,232 Views)
Thanks!
0 Kudos
Message 7 of 15
(8,216 Views)
Dear
 
In addition, I can use system.intptr class
And I want to use System.drawing.image class
But, I could not call system.drawing.image in LV(.net)
 
Plase inform.
How you got constructor to system.drawing.image class???
 
Sincerely yours,
Bongchan Park


메시지가 08-02-2008 08:15 PM에 bc7041에 의해 편집되었음
0 Kudos
Message 8 of 15
(8,103 Views)
I can remember that i created an .Net container and selected ImageBox... Image box has .Image class...
0 Kudos
Message 9 of 15
(8,096 Views)
System.Drawing.Image is an abstract class. There are no constructors for it.
0 Kudos
Message 10 of 15
(8,077 Views)