LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Decoration: Adding Rollover effect on list item in listbox

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 ;

0 Kudos
Message 1 of 4
(4,066 Views)

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.

0 Kudos
Message 2 of 4
(4,065 Views)

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

0 Kudos
Message 3 of 4
(4,031 Views)

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! 

0 Kudos
Message 4 of 4
(4,025 Views)