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. CListBox

CListBox

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
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 have created a list box using CListBox class. I want to give the hover effect on the list box item. like combo box. Please anyone can help me how to do that. Thanks

    N 1 Reply Last reply
    0
    • A AbhiHcl

      Hi I have created a list box using CListBox class. I want to give the hover effect on the list box item. like combo box. Please anyone can help me how to do that. Thanks

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      You will need to handle the WM_MOUSEMOVE message and do the handling yourself.

      home

      A 1 Reply Last reply
      0
      • N Niklas L

        You will need to handle the WM_MOUSEMOVE message and do the handling yourself.

        home

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

        Can u post some sample code please ???

        N 1 Reply Last reply
        0
        • A AbhiHcl

          Can u post some sample code please ???

          N Offline
          N Offline
          Niklas L
          wrote on last edited by
          #4

          No, but here is the rough idea. 1. Create a new class derived from CListBox -> CHoverListBox. 2. Make it owner drawn (a window style). 3. Override DrawItem() and possibly OnMeasureItem(). You will need DrawItem since you will be changing the visual appearance of the control while hovering. 4. Add a message handler for WM_MOUSEMOVE, and in this handler figure out which item the cursor is over. Cooridnates of the mouse is supplied in screen coords, so you should convert them to client coords using CListBox::ScreenToClient(). Then use CListBox::GetItemRect() to find the hovered item. Set a flag for this item, and then call Invalidate(FALSE) to force a repaint. 5. Implement DrawItem() to look at the flag set, and paint the items accordingly. 6. Now you have a reusable class. 7. Write an article about what you did and post it on this site. Tip: Do not use CListBox::SetItemData() to set the flag, because the space is likely to be needed by the users of your control. Use a separate integer in your class instead.

          home

          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