LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I programaticly edit a panel?

Solved!
Go to solution

I have a panel that contains a number of buttons.

The number of buttons and the text in the buttons are supposed to change during the program execution.

I know how to create the buttons on the fly using NewCtrl, but have problems erasing/modifying excisting buttons.

 

 

Is there a way to get access to the list of Ctrl objects in a panel, investigate the Ctrl objects and erase or modify the Ctrl?

At the moment I am using  DiscardCtrl, but this requires me to keep track of the Ctrl objects.

Mistakes in mainting this information are hard to debug. It would be far simpler if I could access the information that the application maintains.

0 Kudos
Message 1 of 3
(3,168 Views)
Solution
Accepted by topic author René Meessen

A magic rule in CVI is that everything you can do in the UIR editor can be done programmatically ar runtime: you only have to know the right way to do it! So:

 

Deleting a control: DiscardCtrl () (you already discovered it)

Editing control aspect: almost all operations are done with SetCtrlAttribute with the appropriate attribute.

Obtaining the list of controls can be done this way:

GetCtrlAttribute (panelHandle, ATTR_FIRST_CTRL, &ctrlID);

while (ctrlID) {

   // operate on the control

    ....

 

   // Get next control: 0 if the last control in the panel is found

   GetCtrlAttribute (panelHandle, ctrlID,  ATTR_NEXT_CTRL, &ctrlID)

}

 

While scanning the controls in a panel you can retrieve details on the control by using

GetCtrlAttribute (panelHandle, ctrlID, ATTR_CTRL_STYLE, &style);

The list of control styles (buttons, rings...) can be found in userint.h

 

As an example, attached is a function I developed that:

- scans all controls in a panel

- switches all operable controls between indicator or hot

- skipping controls in a variable-list of arguments

 

 

To call this function to set all control as hot:

SetParamPanel (panelHandle, 1, VAL_HOT, 0);

 

To set all controls as indicator except quit button:

SetParamPanel (panelHandle, 0, VAL_HOT, PANEL_QUIT, 0)

 

Hope this helps.



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 3
(3,162 Views)

Thanks,

Getting the next controll was what I was looking for.

0 Kudos
Message 3 of 3
(3,157 Views)