LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if the checkbox is checked or not?

Solved!
Go to solution

Is there any function available in CVI to check if a checkbox is selected / checked or not?

0 Kudos
Message 1 of 11
(6,558 Views)
sure; you can use the function GetCtrlVal ( PANEL, PANEL_CHECKBOX, &value );
0 Kudos
Message 2 of 11
(6,558 Views)

This is not working with me? For this function "GetCtrlVal" the CVI help gives "When the control ID is for a list box or ring control, GetCtrlVal returns the value of the currently selected list item."

 

But I wanted to check if a checkbox is checked or not?

0 Kudos
Message 3 of 11
(6,517 Views)

1) There is no contradiction. If you read the help carefully, it says: GetCtrlVal obtains the current value of a control... the following text 'When the control ID is for a list box...' is for the special cases of a list box and ring control only.

Hence, if you do not have a list box or ring control, then GetCtrlVal simply obtains the current value of a control, including a checkbox.

 

2) If it doesn't work for you, you should post the code you are using. You might want to check first if you are using the correct panel handle and control id.

0 Kudos
Message 4 of 11
(6,512 Views)

If you are using the checkboxes associated with a List Box control, you need to use the IsListItemChecked() function.

 

JR

0 Kudos
Message 5 of 11
(6,511 Views)

Attached is the screen shot of the user interface I am using in CVI:

 

In user interface the checkbox (CHECKBOX_4) is placed on the panel (Main_Menu)

 

 

Below is the way I defined the both:

 

#define Main_Menu 1

#define Main_Menu_CHECKBOX_4 11

 

 

Below is the code I used for knowing whether the checkbox is checked or not:

 

GetCtrlVal(Main_Menu, Main_Menu_CHECKBOX_4, &iIsChecked2);

0 Kudos
Message 6 of 11
(6,504 Views)

you should not define the constants yourself, this is already done by the UIR editor. These constants can be found in the corresponding include file of your UIR.

 

So if your UIR file name is my_gui.uir, the corresponding include file is my_gui.h; you need to include this file into your project:

 

at the top of your C file, add the line

 

#include "my_gui.h"

Message Edited by Wolfgang on 03-24-2010 05:56 PM
0 Kudos
Message 7 of 11
(6,500 Views)

You must use the panel handle as the first parameter to GetCtrlVal, not a value you make up yourself. This is the return value from your LoadPanel() call.

 

I think you should work through a few of the basic CVI shipping examples to give you an idea of how to approach a CVI program.

 

JR

0 Kudos
Message 8 of 11
(6,491 Views)

When I try to complite the project the below is the error I am getting, if I do not define the "Main_Menu_CHECKBOX_7":

__TestMain.c - 1 error
 188, 27   Undeclared identifier 'Main_Menu_CHECKBOX_4'.


Or other way how to generate the corresponding include file for the .uir files?

0 Kudos
Message 9 of 11
(6,481 Views)
Solution
Accepted by topic author pa1majeti

from the help file:

 

LabWindows/CVI automatically generates the necessary header file every time you save a .uir file.

 

So: generate an include file, include it in your source code, and in your source code, only use the constants as defined in the include file. If you continue to receive undeclared identifiers, check your source code if you have missed changing a panel or control id.

 

Good luck.

Message 10 of 11
(6,476 Views)