LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Numeric Control - Text and Background Color changes when operating inc/dec arrows

Solved!
Go to solution

Hi,

 

I'm developing an application that has a panel with black background and green or red numbers. I've added numeric controls and configured the text color and text background color attributes accordinglingy. I set the numeric control to hot or validate  control mode and show the inc/dec arrows, since I want to be able to incr/decr the numbers.

 

The problem is that when I run the application and I hit the inc/dec arrows, then the colors inside the numeric control frame become inverted: the black background becomes white and the green number becomes cyan. I've created a callback function assosicated with the numeric control and tried forcing the text and background color, in the EVENT_VAL_CHANGED section, using the SetCtrlAttrribute() function, but to no avail. Also added ProcessDrawEvents didn't help.

 

When I mouse click again outside the numeric control, then it reverts back to its original colors (green text, black background).

 

Any suggestions as to how I can fix this ?

I want it to keep its original colors at all times, even when I'm clicking the incr/decr arrows...

 

Kind regards,

pgriep

 

 

 

0 Kudos
Message 1 of 5
(5,611 Views)

Can you post a small sample that reproduces this behaviour?



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 5
(5,607 Views)

Hi Roberto,

 

I think you may want to check the UIR file, therefore I've attached the CVI code as a zip file for you to try..

 

I'm running Windows 7 Pro 64-bit and my screen is set to 1920x1080, 32-bit color.

 

Cheers,

pgriep

0 Kudos
Message 3 of 5
(5,595 Views)

Ok, now I see what's happening.

The effect you are seeing is a resul of standard numeric control behaviour combined with the black bcakground: when you use arrows to increment/decrement a numeric control its value will be automatically highlighted; on the default background you'll see the white area and figures highlighted in black (white numbers on balck background). If you set the background to black the system will automatically change the colors used to highlight the text, and that's what you're seeing.

By the way, this does not happens if you use up and down keys on the keyboard: text is not highlighted so colors are not changing.

Additionally, this is not only valid for numerics: see the behaviour of the string controls on the bottom of your panel when you tab up to them. This effect does not happen on controls set as indicator like the big clock in the upper part of the panel.

 

The only way I can see to overcome this behaviour is to hide control built-in arrows and create your own up and down buttons with which you can manipulate the numeric control. I am attaching a modified version of your project with buttons on the left numeric; sorry for the poor aesthetic:  I have used some arrow icons I had on my disk, you may want to create your own arrows with the colors and shape you prefer.



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 4 of 5
(5,590 Views)
Solution
Accepted by topic author pgriep

Hi Roberto,

 

I figured this would be an alternative way to fix it. Just hoped I could fix it by setting or clearing an attribute.

Thanks for the effort!

 

Cheers,

pgriep

0 Kudos
Message 5 of 5
(5,584 Views)