Modal Dialog in LabWindows/CVI

| | 评论(0)

Modal Dialog in LabWindows/CVI

May 19, 2003

Create a modal dialog in main panel's callback.

MacAddrPanel = LoadPanel(mainPanel, "MacAddr.uir", MAC_PANEL);
SetCtrlVal( MacAddrPanel, MAC_PANEL_STRING, "");
n = InstallPopup(MacAddrPanel);
resetUI();

Run. You can find that the main panel thread will go on executing, instead of pause at InstallPopup(). How can you do if you need a true "modal dialog"?

The solution is GetUserEvent(), which waits for the COMMIT event of of whole process.

MacAddrPanel = LoadPanel(mainPanel, "MacAddr.uir", MAC_PANEL);
GetMacAddressPrefix( buffer);
SetCtrlVal( MacAddrPanel, MAC_PANEL_STRING, buffer);

n = InstallPopup(MacAddrPanel);
SetActiveCtrl( MacAddrPanel, MAC_PANEL_STRING);
FakeKeystroke( VAL_END_VKEY); // push the active cusor to the end of the line
resetUI();

while(1) // Wait for "Ok" or "Cancel" button of MAC_PANEL was pressed
{
GetUserEvent( 1, &panelHandle, &controlID);
if(panelHandle == MacAddrPanel))
{
RemovePanel(0); // Do not call RemovePanel() in the CallBack of OK and Cancel button
// Because we let user press enter to send a commit
break;
}
}

if( controlID == MAC_PANEL_QUITBUTTON) // Cancel was pressed
return -1;

GetCtrlVal( MacAddrPanel, MAC_PANEL_STRING, s);

An extra result is, we can know which button was pressed from the return value "controlID".
posted 2004.02.10 Tuesday

分类

发表评论

关于此日记

此日记由mach发表于2004年2月10日 00:39

此Blog上的上一篇日记Hide a picture

此Blog上的下一篇日记哇,春节期间我错过了这个LOGO

主索引归档页可以看到最新的日记和所有日记。

Powered by Movable Type 4.0