LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Make panel modal from a CVI dll

I'm creating a CVI dll.  It will popup a main panel.  I need this panel to be a modal, just like a dialog window, user must exist before they can return to the caller.

The InstallPopup function doesn't work in this case.

 

By the way, I have additional popup panels on top of the main panel.  They are working ok with the InstallPopup function.

 

George Zou
0 Kudos
Message 1 of 3
(4,275 Views)

George:

 

CVI doesn't create system modal windows.  InstallPopup creates application modal windows: the window (or panel) stays on top of other windows in the same application, but other applications can go active on top of the installed popups.

 

You could make the panel floating, which will have it be always on top, but not necessarily the foreground or active window.  To make a panel float, you can do it programmatically using

SetPanelAttribute (panelHandle, ATTR_FLOATING, VAL_FLOAT_ALWAYS);

or you can do it in the UI editor by double-clicking on a blank spot in the panel, and then click on Other Attributes, and set the Floating Style.  Having the panel float will keep it on top so it won't get lost under other windows, but other applications can still be active.

 

You could also use a timer to force your window to be the foreground window using the Win32 API (or Windows SDK) SetForegroundWindow() function.  This isn't a perfect solution, and you may see some strange behaviour on background windows if you really try to get them to be active, but it helps avoid an inadvertant click forcing the user to search for the desired window.

 

The attached appliaction uses a timer and SetForegroundWindow() to keep the panels on top.  It also calls InstallPopup to install a popup on top of the main panel, and sets the popup to be the foreground window.  There are some additional details in comments in the code and in text boxes on the panels.

 

The Win32 API (or Windows SDK, depending on which CVI version you have) isn't installed by default.  If it's not installed, you just need to reinstall CVI, selecting the Win32 API as an option.  Note that you need to use the version that ships with CVI, not VC++ or other development tool.

Message 2 of 3
(4,265 Views)

Or if you need just a simple dialog box, you can use the Windows SDK/Win32 API MessageBox function to create a real system modal dialog box.  See my old example here.

http://forums.ni.com/t5/LabWindows-CVI/MessagePopup-dissappears-behind-active-panel/m-p/182042#M1409...

0 Kudos
Message 3 of 3
(4,222 Views)