LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

List Box Row Highlighting

I would like to keep the active selected row of a list box fully highlighted even when the list box is not the current active control.  How can this be done?
0 Kudos
Message 1 of 3
(3,474 Views)

AFAIK a listbox does not maintain highlighting when it's not the active control. Instead, a dotted box surrounds the active item when not active.

A possible solution to this could be to trap EVENT_GOT_FOCUS and EVENT_LOST_FOCUS in the listbox callback: when loosing focus get the active item and replace it with the same text adding a proper combination of backgroun / foreground colors, when getting focus, replace again it with the normal black/white colors. The background color will encompass only the printed text: if you want to highlight the whole line you'll need to add extra spaces to item text. For help on using colors in a listbox look at \samples\userint\listdelx example.



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 3
(3,463 Views)
Thanks!.  Your suggestion along with the addition of a few other housekeeping details works, except for the first time that I leave the list box and focus on a different control.  In this only first only instance I never trap on the EVENT_LOST_FOCUS event.  At all subsequent times that I go back to the list box I get a the appropriate EVENT_LOST_FOCUS and EVENT_GOT_FOCUS events.  But aside from this one minor issue, the method works nicely.

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