LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

programmatically suspending command button?

Solved!
Go to solution

Is there an attribute for a command button (or other input items, for that matter) that disables further input from that button? I am hoping I won't need to use this, but it might be helpful to prevent a user from overloading the input stream to the program.

0 Kudos
Message 1 of 17
(6,001 Views)
Solution
Accepted by mzimmers

SetInputMode (panelHandle, PANEL_CONTROLID, 0);

This will disable user input from every UI control (buittons, numerics, strings...) visually dimming it.

 

SetCtrlAttribute (panelHandle, PANEL_CONTROLID, ATTR_CTRL_MODE, VAL_INDICATOR);

This will prevent user action on the control but it will not dim it.

 

In my opinion it is better the first solution, since it is evident to the user that the control is not operable.



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?
Message 2 of 17
(5,994 Views)

@RobertoBozzolo wrote:

SetCtrlAttribute (panelHandle, PANEL_CONTROLID, ATTR_CTRL_MODE, VAL_INDICATOR);

This will prevent user action on the control but it will not dim it.


In order to dim the control, you can use SetCtrlAttribute ( panelHandle, PANEL_CONTROLID, ATTR_DIMMED, 1 );

To disable one control I thus use both functions: set it to indicator mode and dim it.

0 Kudos
Message 3 of 17
(5,992 Views)

Just out of curiosity, what's the difference, if any, between SetInputMode and SetCtrlAttribute (indicator + dimmed)?



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 4 of 17
(5,988 Views)

Hi Roberto,

 

it does make a visual difference in two aspects, see the figure below:

 

 

input_mode.png

 

The upper ring control has been made inactive using the two SetCtrlAttribute functions, the lower appearance is due to SetInputMode.

 

1) Having a control dimmed still shows arrows. Personally I find this counterintuitive Smiley Wink

 

2) The colors are different, too. I don't like it so much having different controls having different levels of grey: If you have an indicator and dim it it looks different than if you have a control dimmed... I think I reported it in this forum before but if I remember correctly it is like this by design...

0 Kudos
Message 5 of 17
(5,983 Views)

Gosh, I never noticed colour difference! Guess I never tried dimming indicators.

 

You're right with reference to arrows: SetInputMode leaves them, even if not operable, while setting the control as indicator hides them.

It is to be said though that setting a control to indicator actually moves the control lable to the left a few pixels and this misalignment is very ugly especially if you are lining up several controls and set as indicator only some of them. In this case you need to add at least other two lines to maintain panel aspect:

 

GetCtrlAttribute (..., ..., ATTR_LABEL_LEFT, &left):

SetCtrlAttribute (..., ..., ATTR_CTRL_MODE, VAL_INDICATOR);

SetCtrlAttribute (..., ..., ATTR_DIMMED, 1);

SetCtrlAttribute (..., ..., ATTR_LABEL_LEFT, left):

 

For this reason I am not so comfortable with setting controls as indicators, even if I second your opinion on dimmed arrows.



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?
Message 6 of 17
(5,979 Views)

Hi Roberto,

 

I am well aware of the label problem and thus I don't use labels... Instead I use text messages which also has the benefit that the 'label' (i.e. text message) of the control is not dimmed (one still should be able to read the label conveniently even if the control is dimmed)

 

I am using dimmed indicators if the numbers are not valid, the default value might be misleading. Imagine a numeric result of a computation - while the computation is in progress there is no result...

Message 7 of 17
(5,976 Views)

Thank you both for the detailed replies. I'll have to think about which approach I should use.

 

The discussion reminded me of another question: when in the debugger, I notice that when I change the color or text of a button via SetCtrlAttribute(), the change doesn't take place immediately. It seems to take place when the function exits. (This behavior is occurring within a callback.)

 

So:

 

1. is this what happens when running non-debug as well?

2. if so, is there something that can be done to force the update to display sooner? I think refreshing the entire panel would be overkill.

0 Kudos
Message 8 of 17
(5,967 Views)

Read about 'Processing Events' in the help, in particular the functions ProcessSystemEvents and ProcessDrawEvents

Message 9 of 17
(5,965 Views)

i am facing thye same problem although there is alot of very useful discussion about dimming of the induicator but there was no discussion on event process hierarchy my again question will be the same , when i dim or change type of my command button to indicator it seems to take effect on function exit which i dont want , i want to deactivate all command buttons imidiately when i press one button and then activate all when command button task complete, is there a way , are there any example or useful matterial for me ,, pleaseeee help

0 Kudos
Message 10 of 17
(5,548 Views)