Modal Dialog in LabWindows/CVI
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
分类
Technology

发表评论