LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Win32 driven Popup Menu in LabVIEW Front Panel?

Hi,
I have created a VI that uses the Win32 API functions to display a popup meu on a VI's front panel. This isn't a decorated text box filled, showed and hidden with a property node, but a real windows system popup menu.
Anybody want to test it out? I'd appreciate any feedback, fixes or better implementations.
The VI uses several sub VIs encapsulate the API calls for convenience, error checking and appearance.
CreatePopupMenu is used to get a menu handle to a new empty menu structure. AppendMenu is called with the MF_BYPOSITION and MF_STRING constants to add menu items from a string array. TrackPopupMenu is called with the menu handle, a window handle (FindWindow gets the window handle), an
d the default flags for menu tracking. DestroyMenu is called to reclaim resources used by the menu.
I have used sub VIs and the DLL from the Windows Messageing Queue llb available on the Developer Zone. I have used several other handy API calls to convert screen coordinates to client window coordinates using both POINTs and RECTs, etc.
Hope y'all find this stuff useful, and if you get it to work on an NT or 2000 machine, let me know. If it doesn't work, let me know that too. I can tote a cussin' with the best of them.
John Wilson
Sanders Engineering & Analytical Services, Inc.
Mobile, AL
251-633-4120
johnwilson@pctechnician.net
0 Kudos
Message 1 of 3
(3,127 Views)
I download your attached file to test it.
I can test it under Win98SE and Win2000 but i have a small question for you:
Is It possible to disable the default rigth mouse popup menu for any labview
control (obviously to use your popup menu...)

Alessio Colzi
John Wilson wrote in message
5065000000080000008F230000-993342863000@exchange.ni.com...
> Hi,
> I have created a VI that uses the Win32 API functions to display a
> popup meu on a VI's front panel. This isn't a decorated text box
> filled, showed and hidden with a property node, but a real windows
> system popup menu.
> Anybody want to test it out? I'd appreciate any feedback, fixes or
> better implementations.
> The VI uses several sub VIs encapsulate the API calls for
> convenience, error
checking and appearance.
> CreatePopupMenu is used to get a menu handle to a new empty menu
> structure. AppendMenu is called with the MF_BYPOSITION and MF_STRING
> constants to add menu items from a string array. TrackPopupMenu is
> called with the menu handle, a window handle (FindWindow gets the
> window handle), and the default flags for menu tracking. DestroyMenu
> is called to reclaim resources used by the menu.
> I have used sub VIs and the DLL from the Windows Messageing Queue
> llb available on the Developer Zone. I have used several other handy
> API calls to convert screen coordinates to client window coordinates
> using both POINTs and RECTs, etc.
> Hope y'all find this stuff useful, and if you get it to work on an
> NT or 2000 machine, let me know. If it doesn't work, let me know that
> too. I can tote a cussin' with the best of them.
> John Wilson
> Sanders Engineering & Analytical Services, Inc.
> Mobile, AL
> 251-633-4120
> johnwilson@pctechnician.net
0 Kudos
Message 2 of 3
(3,127 Views)
I believe so. To do so, you must again move outside of the LabVIEW programming environment to a compiler program such as C++. In the compiler, you must write a program to 'subclass' the labview window, whcih means to get access to and filter events. Once you see the event you want (ie, right mouse click), you process the event and choose whether to pass it on to the labview window.
Sometimes you would want to pass the event back to Labview, and sometimes not. For example, you might want the context menu(right click) to function everywhere but over the plot area of a graph. That would require building a dll to subclass the labview window, capturing the mouse clicks when the cursor location (x,y) is over the plot area.
A beter way for you to use this v
i right now would be to watch for SHIFT or CTRL clicks over the point of interest and send the mouse X,Y position to the Pop-up Menu subvi. I will build a subclassing dll soon, though.
0 Kudos
Message 3 of 3
(3,127 Views)