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