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. CBitmapButton mouseover change bitmap? (vc++ 6.0)

CBitmapButton mouseover change bitmap? (vc++ 6.0)

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++graphics
3 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.
  • R Offline
    R Offline
    rolfhorror
    wrote on last edited by
    #1

    hi, im sure this question is a regular one. i'm making an app with bitmapbuttons and want to change bitmap on the button when hovering over them can't seem to find any good articles about this subject. heres a code i've been trying out, cant seem to get it to work. //loaded the default button bitmaps in OnInitDialog() m_btn1.LoadBitmaps(IDB_MYBUTTON_DEFAULT); //this works and sets the bitmaps on my buttons //something like this is what i want to do void CMyDlg::OnMouseMove(UINT nFlags, CPoint point) { CRect m_Rect; m_btn1.GetWindowRect(m_Rect); if (m_Rect.PtInRect(point)) { //when mouse is over button change to this bitmap m_btn1.LoadBitmaps(IDB_MYBUTTON_OVER); } } any solutions? tanx :-)

    M 1 Reply Last reply
    0
    • R rolfhorror

      hi, im sure this question is a regular one. i'm making an app with bitmapbuttons and want to change bitmap on the button when hovering over them can't seem to find any good articles about this subject. heres a code i've been trying out, cant seem to get it to work. //loaded the default button bitmaps in OnInitDialog() m_btn1.LoadBitmaps(IDB_MYBUTTON_DEFAULT); //this works and sets the bitmaps on my buttons //something like this is what i want to do void CMyDlg::OnMouseMove(UINT nFlags, CPoint point) { CRect m_Rect; m_btn1.GetWindowRect(m_Rect); if (m_Rect.PtInRect(point)) { //when mouse is over button change to this bitmap m_btn1.LoadBitmaps(IDB_MYBUTTON_OVER); } } any solutions? tanx :-)

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You won't get a WM_MOUSEMOVE message in the dialog when the cursor is moved over a button.  You need to check for WM_MOUSEMOVE in the button class. In your button class' OnMouseMove(), the first time it's called when the cursor enters the button, you can use TrackMouseEvent() with the TME_LEAVE flag.  Then you'll get a WM_MOUSELEAVE message when the cursor is moved off the button so you can set the bitmaps back to the original. Also, after your LoadBitmaps() calls, you may need to call UpdateWindow() on the button(s) to get them to redraw (maybe not, but if the button bitmaps aren't changing, it's worth a  try :)). Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      R 1 Reply Last reply
      0
      • M Mark Salsbery

        You won't get a WM_MOUSEMOVE message in the dialog when the cursor is moved over a button.  You need to check for WM_MOUSEMOVE in the button class. In your button class' OnMouseMove(), the first time it's called when the cursor enters the button, you can use TrackMouseEvent() with the TME_LEAVE flag.  Then you'll get a WM_MOUSELEAVE message when the cursor is moved off the button so you can set the bitmaps back to the original. Also, after your LoadBitmaps() calls, you may need to call UpdateWindow() on the button(s) to get them to redraw (maybe not, but if the button bitmaps aren't changing, it's worth a  try :)). Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        R Offline
        R Offline
        rolfhorror
        wrote on last edited by
        #3

        tanx, i'll try that! :)

        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