Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

What Labview 8.5 function is equivalent to WNDPROC

Hello,
In VB i have those code lines:

Protected

Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

If

(m.Msg = SpecificU32Message) Then

...

End IF

MyBase

.WndProc(m)

End Sub

 

Is there any way to implement this procedure in Labview 8.5, and how?

 

Tnx,

HaD



Message Edited by HaD on 07-07-2008 11:04 PM

Message Edited by HaD on 07-07-2008 11:05 PM
Message 1 of 8
(5,253 Views)

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.

Message 2 of 8
(5,245 Views)
Thanks for answer,
The link to the windows message library is for labview 5.0 and is not working..

What i need to do is very simple,
I have a dll (not mine) that encapsulate some other dlls function. one of the function will start a data streaming from external hardware (camera) to window handle, and i need to use the messages to know when a new frame is available, and the VB code is developer code for displaying a new frame on window form. I want to mimic it to labview.
 
Thanks,
HaD
0 Kudos
Message 3 of 8
(5,232 Views)

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.

Message 4 of 8
(5,221 Views)
Thanks!
 
It seems to be the right ans, i am almost got it, but one thing is missing
In VB there is line :

If (m.Msg = MyCameraMessage) Then

If (m.WParam = cameraId) Then

Dim myImage As Image = Image.FromHbitmap(m.LParam)

 

im asking about the function "Image.FromHbitmap(Handle)" how to convert an Handle to Bitmap in Labview Vision.

 

Thanks.

 

0 Kudos
Message 5 of 8
(5,212 Views)

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)

0 Kudos
Message 6 of 8
(5,206 Views)

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.

Message 7 of 8
(5,198 Views)
I can short the code to one line:

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

 

 

0 Kudos
Message 8 of 8
(5,180 Views)