LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Group Toggle Buttons

Since group radio button support have been introduced in CVI, are there any thoughts of expanding this group control towards other toggle button styles besides just the round radio button?  And what if I would like the grouping to be laid out horizontally, rather than vertically?

Thanks for the feedback.
0 Kudos
Message 1 of 6
(4,036 Views)

Hi Steve,

actually it's quite easy to program such a group yourself. All you have to do is give each group number the same callback function and then check the control parameter to see which group number has been clicked. I give you an example of how to adjust the user interface to make sure only one toggle button is active:


int CVICALLBACK ButtonGroupCallback (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2) {
 // This is the callback function for the toggle buttons. 
 switch (event) {
  case EVENT_COMMIT:
   
   // Adjust the user interface.
   SetCtrlVal (pnl, PNL_BUTTON1, control == PNL_BUTTON1);
   SetCtrlVal (pnl, PNL_BUTTON2, control == PNL_BUTTON2);
   SetCtrlVal (pnl, PNL_BUTTON3, control == PNL_BUTTON3);

   break;
 }
 return 0;
}

You can write similar functions to check which button is active and take action depending on the activated button.

I have attached a small example program, dealing with toggle buttons and LED's.

 

 

Message Edited by Wim S on 08-04-2006 08:51 AM

Message 2 of 6
(4,030 Views)
Thanks for your excellent example!   I had previously been using static variables and a ton of compares to arrive at the same end.   Following your example I replaced with 10 lines with 2 lines.
0 Kudos
Message 3 of 6
(4,010 Views)
Thanks.  I tried your example and it works, although I do not yet understand the process with the SetCtrlVal assignments using  '=='.  Maybe you can enlighten me?
0 Kudos
Message 4 of 6
(4,003 Views)
No problem, thanks a lot for the ratings Smiley Happy
0 Kudos
Message 5 of 6
(4,001 Views)

Hello Steve.

The '==' statement is actually an encapsulated 'if' statement. The comparison will return 1 or 0, which is exactly the value you need in the SetCtrlVal function.

You could also write  SetCtrlVal (pnl, PNL_BUTTON1, control == PNL_BUTTON1? 1 : 0);

0 Kudos
Message 6 of 6
(3,997 Views)