LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

String background color when active

I am writing an application that will be run in to modes - edit mode, and locked mode.  I have a bunch of string controls, and I would like them to look and act like normal in edit mode, but look and act like text message controls when in locked mode. I use the following code to switch a string control into locked mode:

                SetCtrlAttribute (panel, ctrl, ATTR_CTRL_MODE, VAL_INDICATOR);
                SetCtrlAttribute (panel, ctrl, ATTR_FRAME_COLOR, VAL_TRANSPARENT);
                SetCtrlAttribute (panel, ctrl, ATTR_TEXT_BGCOLOR, VAL_TRANSPARENT);

This works for the most part, however, when the control becomes active (the user clicks on it), the background of the string becomes white, and a dotted line surround it. Is there any way to change this "active background color", or to prevent a control from gaining focus?

0 Kudos
Message 1 of 4
(3,257 Views)
One easy way to accomplish this is to immediately move the focus to some other control when in "locked" mode. The callback for these string controls could include something like this:
case EVENT_GOT_FOCUS:
if (!editMode)
SetActiveCtrl (panel, PNL_SOME_OTHER_CONTROL);
break;

Regards,
Colin.
Message 2 of 4
(3,246 Views)

One other way is to swallow mouse events if in indicator mode. To swallow events you can simply trap them in the control callback and exit the callback immediately with return 1. This has the effect of acting as if the mouse action on the control had never take place.

The possibility to click and highlight control text even if in indicator mode is provided essentially to let the user copy control contents in the clipboard in order to paste it elsewhere: if you don't mind loosing this facility swallowing the event is your better choice.



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 4
(3,240 Views)
That did the trick. I don't think that the ability to select the text in locked mode will be needed.
Thanks!
0 Kudos
Message 4 of 4
(3,223 Views)