12-15-2008 09:40 PM
Hi,
Is it possible to hilite a list item when the mouse cursor rolls over a list box?
Below is my code which I manage to change the property of the text (in BOLD).
However, the background only covers only the text. Is it possible to hitelite the entire row when the mouse rollover the listbox?
I am using labwindows 6.0
case EVENT_MOUSE_MOVE:
GetCtrlAttribute (iGlobalPanel, GLOBAL_LISTBOX,ATTR_HEIGHT,&ctrlHeight) ;
GetCtrlAttribute (iGlobalPanel, GLOBAL_LISTBOX,ATTR_WIDTH,&ctrlWidth) ;
GetCtrlAttribute (iGlobalPanel, GLOBAL_LISTBOX,ATTR_LEFT,&ctrlLeft) ;
GetCtrlAttribute (iGlobalPanel, GLOBAL_LISTBOX,ATTR_TOP,&ctrlTop) ;
// ctrlitemheight = height of each control item in listbox
ctrlitemheight = (int) (ctrlHeight/numItemsInList) ; //numItemsInList = number of list item shown
if(numItemsInList>1)
{
for (i=0; i<numItemsInList; i++)
{
if (eventData1 > ctrlTop+(ctrlitemheight*i) && eventData1 < ctrlTop+(ctrlitemheight*(i+1)))
{
if((ctrlLeft <= eventData2) && (eventData2 < (ctrlLeft+ctrlWidth)))
{
// selected list item
sprintf (buf, "\033bg%06X\033fg%06X", 0x00FFCC66, 0x00000000); //0x00FFCC66 = background color, 0x00000000=text color
strcat (buf, "Hello") ;
ReplaceListItem (iGlobalPanel, GLOBAL_LISTBOX, i, buf, i) ;
}
}
}
}
break ;
12-15-2008 09:49 PM
I think I should rephrase the question.
I am trying to find out how to colour a specific list item in a listbox rather than the mouseover effect.
12-17-2008 01:58 AM
Hihi,
You may want to take a look at this post. It mentioned how to change the foreground and background of each item in the listbox. What it does is it will change the foreground and background color of the hightlighted item in the listbox. However, you can only see it when you highlight another item in the listbox.
If you do not want to see the highlight, you can set control attribute (hide hilite).
Hope this is useful to you.
Thank you & Regards
Lee
Applications Engineer | NI ASEAN
12-17-2008 03:00 AM
Yes. That is what I have been doing. I have changed the background and foreground colours of the item.
My intention was to hilite the entire item and not just the text and the text background.
I think I will stick to the idea of changing the text hilite instead of the entire item for now.
Thanks a lot!