LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a horizontal Radio Group?

Solved!
Go to solution

An alternative way of doing what Al suggested is to directly call the control callback or better use CallCtrlCallback:

 

Alternative 1:

int CVICALLBACK Reset (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
            // Preset initial element of the radio group
            SetCtrlVal (panelHandle, PANEL_OPT1, 1);
            OptionCallback (panelHandle, PANEL_OPT1, event, NULL, 0, 0);
            break;
    }
    return 0;
}
 

Alternative 2:

int CVICALLBACK Reset (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
            // Preset initial element of the radio group
            SetCtrlVal (panelHandle, PANEL_OPT1, 1);
            CallCtrlCallback (panelHandle, PANEL_OPT1, event, 0, 0, 0);
            break;
    }
    return 0;
}
 

Both methods avoid unnecessary duplications of code that may lead to unexpected results in case you change something in your project (from the simple control name changing to more complex scenarios you can think of: in any case the code that handles the radio group is located in one callback only, not split in two of them).

 

I personally prefere the use of CallCtrlCallback since it may be applied to controls already customized with ChainCtrlCallback, for example several toolbox controls like the password and path controls. You will need to include toolbox.h in your project to use CallCtrlCallback.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 11 of 12
(1,141 Views)
Thankyou guys for helping me out on this one too. Thank you for your help. I really apreciate it.
Regards,
Farhan Ahmad.
0 Kudos
Message 12 of 12
(1,118 Views)