Discussion:
Bitmap Buttons in Dialogs / EnableWindow
(too old to reply)
Frank
2015-01-19 13:11:36 UTC
Permalink
Dear people,

I have a bitmap button:

PUSHBUTTON "Upload",IDC_UPLOAD,20,26,86,51,BS_BITMAP

in a dialog resource and set the bitmap
in the code with CButton::SetBitmap.
This works fine.

But when I disable the button with CWnd::EnableWindow,
the whole button becomes dark grey. I recall
having seen a disabled button where the
picture just had a "lighter" version
of the original picture when disabling.

What am I doing wrong?
Geoff
2015-01-19 18:35:30 UTC
Permalink
Post by Frank
Dear people,
PUSHBUTTON "Upload",IDC_UPLOAD,20,26,86,51,BS_BITMAP
in a dialog resource and set the bitmap
in the code with CButton::SetBitmap.
This works fine.
But when I disable the button with CWnd::EnableWindow,
the whole button becomes dark grey. I recall
having seen a disabled button where the
picture just had a "lighter" version
of the original picture when disabling.
What am I doing wrong?
You must provide your own greyed-out version of your button and
respond to the control messages it will receive.

Windows will gray out non-custom buttons for you but when you decide
to customize your buttons you take on the responsibility for providing
all the versions of that button in all the states it may be required
to display.

This might be helpful:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb775941(v=vs.85).aspx

Joe Newcomer answered this question in 2001 and described some of the
defects of the CButton class. His solution was a smarter CBitmapButton
class you may find helpful.

http://www.codeproject.com/Articles/530/A-Better-Bitmap-Button-Class
David Lowndes
2015-01-19 22:04:52 UTC
Permalink
Post by Frank
But when I disable the button with CWnd::EnableWindow,
the whole button becomes dark grey. I recall
having seen a disabled button where the
picture just had a "lighter" version
of the original picture when disabling.
Hi Frank,

If you use an icon (BS_ICON) instead of a bitmap, I think you'll find
the result should be better.

Dave

Loading...