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. Bitmap of CBitmapButton not working

Bitmap of CBitmapButton not working

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphics
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.
  • G Offline
    G Offline
    greekgoddj
    wrote on last edited by
    #1

    Hello, I am trying to use CBitmapButton with four bitmaps but it is not working. The button shows up, but not the bitmaps. When I set the control's style to BS_OWNERDRAW as it has been suggested then the bitmaps still don't show..but also what used to be the button now becomes a flat grey area on the screen. I have also tried BS_OWNERDRAWN without and without BS_PUSHBUTTON and no luck. CWnd* parent = CWnd::FromHandle(this->m_hWnd); BOOL success = m_BitmapButton.Create(("Play Section"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW, CRect(10,10,44,44), parent, 1); success = m_BitmapButton.LoadBitmaps(IDB_PLAYSECTIONU, IDB_PLAYSECTIOND, IDB_PLAYSECTIONF, IDB_PLAYSECTIONX); Another even more important question is, why does CBitmapbutton need to be ownerdrawn? isn't the whole idea that I give the control four bitmaps and it takes care of applying the appropriate one according to wether the mouse moves over it, presses it etc? Thanks Aristotel

    R 1 Reply Last reply
    0
    • G greekgoddj

      Hello, I am trying to use CBitmapButton with four bitmaps but it is not working. The button shows up, but not the bitmaps. When I set the control's style to BS_OWNERDRAW as it has been suggested then the bitmaps still don't show..but also what used to be the button now becomes a flat grey area on the screen. I have also tried BS_OWNERDRAWN without and without BS_PUSHBUTTON and no luck. CWnd* parent = CWnd::FromHandle(this->m_hWnd); BOOL success = m_BitmapButton.Create(("Play Section"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW, CRect(10,10,44,44), parent, 1); success = m_BitmapButton.LoadBitmaps(IDB_PLAYSECTIONU, IDB_PLAYSECTIOND, IDB_PLAYSECTIONF, IDB_PLAYSECTIONX); Another even more important question is, why does CBitmapbutton need to be ownerdrawn? isn't the whole idea that I give the control four bitmaps and it takes care of applying the appropriate one according to wether the mouse moves over it, presses it etc? Thanks Aristotel

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      greekgoddj wrote: Another even more important question is, why does CBitmapbutton need to be ownerdrawn? isn't the whole idea that I give the control four bitmaps and it takes care of applying the appropriate one according to wether the mouse moves over it, presses it etc? The standard Windows button supports only one bitmap, which is displayed instead of the text on a regular button. To support four bitmaps, CBitmapButton uses owner-draw so it can display all four bitmaps and prevent Windows from drawing the standard button shape.

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      G 1 Reply Last reply
      0
      • R Ryan Binns

        greekgoddj wrote: Another even more important question is, why does CBitmapbutton need to be ownerdrawn? isn't the whole idea that I give the control four bitmaps and it takes care of applying the appropriate one according to wether the mouse moves over it, presses it etc? The standard Windows button supports only one bitmap, which is displayed instead of the text on a regular button. To support four bitmaps, CBitmapButton uses owner-draw so it can display all four bitmaps and prevent Windows from drawing the standard button shape.

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        G Offline
        G Offline
        greekgoddj
        wrote on last edited by
        #3

        Hi Ryan... I managed to track down CBitmapButton::DrawItem() and look at its code inside. So at least now I don't have to worry about taking care of the actual bitmap selection and drawing depending on the state. I did however notice that that function never gets called. Setting breakpoints shows that it never gets called. Thanks, Aristotel

        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