07-07-2008 11:04 PM - edited 07-07-2008 11:05 PM
Protected
Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)(m.Msg = SpecificU32Message) ThenIf
...
End IF
.WndProc(m) End SubMyBase
Is there any way to implement this procedure in Labview 8.5, and how?
Tnx,
HaD
07-08-2008 01:41 AM
Hi, HaD,
In general this function "hidden" inside of LabVIEW realization, you can't access or modify it.
Otherwise there are two possibilities depends from your goal:
First, you can create your own window (inside of DLL), where you will handle messages, then call this DLL and organize the data exchange with host LabVIEW application. Quite complicatd way.
Second, if you need to handle some Window Messages, then I will recommend to try this: Windows Message Queue Library, and may be it will be possible solution for your problem.
best regards,
Andrey.
07-08-2008 04:58 AM
07-08-2008 07:58 AM
Hi, HaD,
Now i understood your problem. Theoretically you can do following (assumed taht you have Vision Development Module installed):
- create IMAQ Window (with call IMAQ WindDraw)
- obtain windows handle to this window (with IMAQ Get Window Handle)
- initialize given dll with this handle
- create Messages Queue with this handle for your specific message
- wait on this specific message
now if dll will send specific message to this window, then you will get it in LabVIEW (without polling!).
in attachment you can found Windows Messages Queue VIs recompiled from 5.x to 8.5, so you can play with it.
In additional I have create an example, where user-defined message WM_USER+4 will be send to IMAQ Vision in one cycle and recieved in other. This is just the illustration for idea described above.
hopefully this will be helpful,
Andrey.
07-08-2008 09:23 AM
im asking about the function "Image.FromHbitmap(Handle)" how to convert an Handle to Bitmap in Labview Vision.
Thanks.
07-08-2008 09:48 AM
sorry forgot to put int he next line, just to make clear what VB do with this image (very simple).
ViewfinderPictureBox.Image = myImage
So the question remain how to do in labview:
Dim
myImage As Image = Image.FromHbitmap(m.LParam)07-08-2008 10:41 AM
Not so bad...
Now the most complicated part. You've got the handle to GDI Bitmap and should convert this to IMAQ Vision.
In few words - "direct" conversion is impossible, you should recover the pointer to the pixel data, and transfer the image from GDI bitmap to IMAQ Vision.
There are two possible solutions:
- you can do this with .net as in your VB example. Just use Invoke Node System.Drawing.Image.FromHbitmap, then use Bitmap methods and properties.
- you can try to access pixel data directly in GDI Bitmap.
Both methods quite complicated. Deep understanding of the Windows GDI and IMAQ Vision required here.
I guess that the first method will be a little bit more easy for programming, but the second will be a little bit faster.
best regards,
Andrey.
07-08-2008 04:43 PM
PictureBox.Image = Image.FromHbitmap(m.LParam)
So i created
1).Net PictureBox on front panel
2).Net Invoke Node, From Syste.Drawing.Image
It seems that i just need to convert the I32 to .Net IntPtr, so i created a IntPtr and tried to cast the I32 pointer to handle but its not working and i get <Net exception on the invoke node.
so how i can do the conversion from I32 to IntPtr
image attached