LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetCtrlVal checkbox

Why doesn't the following code work? If i check the box or don't check the box, IsChecked is always = to 1.

 

 int IsChecked = 0;
 

       GetCtrlVal(LED_PANEL, LED_PANEL_CHBX_POWER, &IsChecked);
        if(IsChecked == TRUE)

0 Kudos
Message 1 of 4
(6,816 Views)

Hi,

this is one of the most typical problems found by new users of CVI. GetCtrlVal -like SetCtrlVal and all other control-related or panel-related commands- accepts as the first parameter a panel handle, i.e. the handle returned by LoadPanel (or CreatePanel) function. This is clearly stated in the online help for the function.

You are passing the panel constant name defined within the UIR editor instead, so your instruction will not work.

 

The panel handle is the ID of a particular resource loaded in memory: you could load the same panel more than once, identifying each of them via the corresponding handle returned by the system while loading each panel.

 

If your instruction lies within a control callback, the panel handle is the first parameter of the function:

 

int CVICALLBACK ControlCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)

{

    int     IsChecked;

 

    if (event == EVENT_COMMIT) {

        GetCtrlVal (panel, LED_PANEL_CHBX_POWER, &IsChecked);
        if (IsChecked == TRUE) {

        }

    }

    return 0;

}

Message Edited by Roberto Bozzolo on 10-09-2009 09:56 PM


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 2 of 4
(6,813 Views)

That was it. Thanks a bunch. I am new to cvi and new to posting. I searched in the post and my local CVI help files "F1" to no luck.

So i just threw it out here. afriad i wouldn't have enough infomation.

The help files with the Labwindows cvi seem to cover LOTS on listboxes and IsListItemChecked... but nothing on handling just a checkbox.

for a while i wasn't sure GetCtrlVal was the right function to use.

Thanks again.

0 Kudos
Message 3 of 4
(6,809 Views)

bonutti:

 

Getting to some CVI help takes a bit of browsing.  To get some help on using controls, in CVI help, goto the Index tab and enter controls (user interface).

From there you can browse various topics including programming with.

 

One of the ways I like best to verify that you're using the CVI function parameters correctly is through the function panels.  If the function name is already in your code, just click on the name and press Ctrl-P.  In the function panel window that opens, you can then right-click on any parameter and get help for that parameter.  You cam also right-click on a blank area on the function panel to get function help.

 

If you don't have the function name in you code yet, you can press Shift-Ctrl-P to pull up a function panel search box.  I use the search often to bring up the function panels even for functions I use often just to avoid typing the whole function name.

 

In the function panel, you can also click the toolbar button to Declare Variable... and tell it where to put the declaration (I typically tell it to Add declaration to current block in target file), or click on the toolbar button to Insert Function Call.  The icons for these buttons look different in different versions of CVI.

 

You can also browse to function panels through the Library menu in the CVI project window.

0 Kudos
Message 4 of 4
(6,765 Views)