CStatic* pStatic = (CStatic*) GetDlgItem(IDC_911_STATIC);
pStatic->ModifyStyle(0, SS_BITMAP|SS_CENTERIMAGE|WS_CHILD|WS_VISIBLE, 0);
pStatic->SetBitmap( ::LoadBitmap(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_RED)) );
The doc is at
http://msdn.microsoft.com/en-us/library/bb760773%28VS.85%29.aspx It says:
---
Windows XP: This style bit no longer results in unused portions of the
control being filled with the color of the top left pixel of the bitmap or
icon. Unused portions of the control will remain the background color.
---
You might try SS_REALSIZECONTROL.
But for SS_BITMAP it says the control resizes to the size of the bitmap
anyway, so I'm not sure why there would be any extra area that needed
filling?
-- David
I'll have to go another route for this now. Should be simple to do... I
don't want the control to resize to the bitmap. The control will resize with
the dialog because I need it to go across the entire dialog.
Anyway, thanks for letting me know about the change.
>In VS 2003, I created a dialog project which contained a CStatic which
>stretched across the top of the dialog. Depending on a "state" in the
>program, I would show or hide this static control. I used SetBitmap to set
>the static to a small red bitmap. The static would be completely filled in
>the red bitmap since it has the style SS_CENTERIMAGE. This worked great. I
>have moved to VS 2008 and have the manifest set so I use the latest common
>controls, etc. Now the static does not get completely filled by the bitmap
>even thought the API doc says it should. Any ideas? Here is the code
>snippet.
>
>CStatic* pStatic = (CStatic*) GetDlgItem(IDC_911_STATIC);
****
Why are you using the obsolete GetDlgItem? This is retro Petzold programming! If you are
using more than one GetDlgItem per year, you are not using MFC correctly. Create a member
variable.
****
>pStatic->ModifyStyle(0, SS_BITMAP|SS_CENTERIMAGE|WS_CHILD|WS_VISIBLE, 0);
****
Put spaces around | so the code is readable. Generally, you should not assume that style
bits like this can be changed; create the control with the styles you want.
****
>pStatic->SetBitmap( ::LoadBitmap(AfxGetResourceHandle(),
>MAKEINTRESOURCE(IDB_RED)) );
****
LoadBitmap can distort the colors of bitmaps. You should use LoadImage.
Generally, I do not trust the bitmap drawing logic; I'm more inclined to simply create a
subclass of the control and do the drawing myself; that way, I know it is going to do what
I want, and not change at the whim of some designer who decides that the control should
work differently than it was specified to work.
joe
****
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm