Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MouseHover effect on ListBox

MouseHover effect on ListBox

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AbhiHcl
    wrote on last edited by
    #1

    Hi I ahve created a Listbox using myclass which is derived from Clistbox. I want to set the Mouseover effect on the listbox, I mean whenever my mouse moves from one index to other it should be hilighted. Can anybode please help me.. Please send me some sample code if possible.. Thanks

    C 1 Reply Last reply
    0
    • A AbhiHcl

      Hi I ahve created a Listbox using myclass which is derived from Clistbox. I want to set the Mouseover effect on the listbox, I mean whenever my mouse moves from one index to other it should be hilighted. Can anybode please help me.. Please send me some sample code if possible.. Thanks

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      As far as i know CListBox doesn't provide you with this feature. You can however try implement it yourself , you would probably need to use an owner drawn list box for this by adding the LBS_OWNERDRAWFIXED style, handle the WM_MOUSEMOVE message, use TrackMouseEvent[^], the ItemFromPoint[^] method. p.s: CListCtrl however does have an extended style called LVS_EX_TRACKSELECT that probably does what you want, if possible you might try to use CListCtrl instead of CListBox.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

      A 1 Reply Last reply
      0
      • C Code o mat

        As far as i know CListBox doesn't provide you with this feature. You can however try implement it yourself , you would probably need to use an owner drawn list box for this by adding the LBS_OWNERDRAWFIXED style, handle the WM_MOUSEMOVE message, use TrackMouseEvent[^], the ItemFromPoint[^] method. p.s: CListCtrl however does have an extended style called LVS_EX_TRACKSELECT that probably does what you want, if possible you might try to use CListCtrl instead of CListBox.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

        A Offline
        A Offline
        AbhiHcl
        wrote on last edited by
        #3

        I am trying with the below function, but every time its drawing the 1st item only.. basically the GetItemRect() needs the index value as the first parameter, can u please tell how to get the index value of the list box when mouse is moving from one item to other. my code is like this : void CTxListControl::OnMouseHover(UINT nFlags, CPoint point) { CDC* pDC = GetWindowDC(); CRect rect; GetItemRect(0,rect); rect.OffsetRect( -rect.left, -rect.top); CBrush brush( RGB(0, 0, 255)); pDC->FillRect(rect, &brush); }

        C 1 Reply Last reply
        0
        • A AbhiHcl

          I am trying with the below function, but every time its drawing the 1st item only.. basically the GetItemRect() needs the index value as the first parameter, can u please tell how to get the index value of the list box when mouse is moving from one item to other. my code is like this : void CTxListControl::OnMouseHover(UINT nFlags, CPoint point) { CDC* pDC = GetWindowDC(); CRect rect; GetItemRect(0,rect); rect.OffsetRect( -rect.left, -rect.top); CBrush brush( RGB(0, 0, 255)); pDC->FillRect(rect, &brush); }

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          See ItemFromPoint[^], as i already wrote.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups