LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Quit panel - ESC key

hi
 
when a panel is loaded after performing some operations i want to close that panel by pressing ESC key .
pls tell me the best one do to this
 
sks
0 Kudos
Message 1 of 5
(3,996 Views)
Hi,

One way to do this is to assign a callback function to the panel. You can then check for key presses. The eventData1 parameter will contain the extended key code. If the callback function is called 'ProcessPanel', then the code would look something like this:

int CVICALLBACK ProcessPanel (int panel, int event, void *callbackData, int eventData1, int eventData2)
{                           
   switch (event)
            {
              ...             
             case EVENT_KEYPRESS:
                        switch (eventData1)   // (will contain the key code)
                                   {
                                    case VAL_ESC_VKEY:       // close the window
                                                HidePanel (panel);
                                                break;
                                    
                                   // ... optional checks for other keys such as arrow keys, <home>, <end>, etc.

                                    default:
                                    break;
                                   }
                        break;
          }                               
 return 0;                     
}

Alternatively, you could simply assign ESC as the hotkey to a button on the panel and assign a callback to this button to hide the panel. If you didn't want it displayed, you could overlay an opaque canvas over this button to hide it and prevent a user from clicking on it.

John.

Message 2 of 5
(3,988 Views)

On your panel create a control that will close the panel.  This control can be placed out of the way or behind something if you do not want it to be visable. 

Set the shortcut for the control to be the ESC key. 

Edit: Looks like JAH can type faster than meSmiley Happy

Message Edited by mvr on 07-21-2006 07:55 AM

Message 3 of 5
(3,987 Views)
thanks mvr .. it works
 
sks
 
0 Kudos
Message 4 of 5
(3,977 Views)

Hi JAH,

I think you also deserve your stars Smiley Wink

0 Kudos
Message 5 of 5
(3,949 Views)