LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Dimmed buttons delay but do not disable a button click .

When I push button A on the main panel I want it to disable several other buttons also on the main panel. I am trying to accomplish this by dimming the buttons at the beginning of button A's callback function and then restoring the buttons at the end of buttons A's callback. The problem I encounter is that when a dimmed button is pressed it's callback is queued up and once the button is un-dimmed the queued callbacks are run. In contrast, I would prefer that when a dimmed button is clicked this mouse click is just completely ignored and the callback from this click is never run. Does anyone know how to accomplish this?

Also, I am trying to dim items from a menu bar using SetCtrlAttribute and ATTR_DIMMED(the same way I'm dimming the control buttons) but am not having any success. Is it possible to dynamically dim menu bar items?
0 Kudos
Message 1 of 7
(4,450 Views)
Call ProcessSystemEvents() at the end of the callback for button A before undimming button B.
The behavior you describe is related to the way CVI and Windows process events that occur during callbacks. CVI does not process events that occur during a callback, unless you call ProcessSystemEvents. So when, in you callback for button A, you dim button B then press button B, that event is queued but not processed. Then you undim button B and return from button A callback. Now CVI is ready to process the click on button B. Button B is no longer dimmed so the callback for button B is executed.
When you call ProcessSystemEvents in callback A before undimming B, it forces CVI to process events (like the click on button B) that occured during the callback for button A. Since button B is dimmed, the click will be processed and ignored.
Message 2 of 7
(4,437 Views)
...and to disable menu items use SetMenuBarAttribute (menuBar, menuItem, ATTR_DIMMED, 1);


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 3 of 7
(4,432 Views)
P.S.: Also in a callback, CVI doesn't process draw events (like drawing the buttons dimmed), so you may want to call ProcessDrawEvents() immediately after dimming button B in callback A so button B looks disabled.
0 Kudos
Message 4 of 7
(4,431 Views)
Here's a quick example that shows you the behavior with and without calling ProcessSystemEvents.
0 Kudos
Message 5 of 7
(4,429 Views)
Have you tried

SetCtrlAttribute (panel, PANEL_BUTTON, ATTR_VISIBLE, 0);

?

Bye
0 Kudos
Message 6 of 7
(4,420 Views)
Thanks to everyone for the replies. I implemented the suggestions and everything is working exactly as I would want.
0 Kudos
Message 7 of 7
(4,416 Views)