MFC Picture Control image size.
-
(google-fu seems to be lacking today, and I'm certain I'm not asking or doing the right thing) I have defined a UI in the resource editor with a Picture Control and assign a bitmap on it :
CONTROL IDB\_BITMAP1,IDC\_BACKGROUND\_PICTURE,"Static",SS\_BITMAP | SS\_CENTERIMAGE,14,7,425,263
The problem is that sometimes (most of the time) the actual bitmap does not have the same size as the picture control. Is there a way to know the actual pixel size of the Picture Control ? Am I doing this the wrong way? or Am I forced to do this in code (get picturecontrol client size, and StretchBlt ... )? Thanks.
I'd rather be phishing!
-
(google-fu seems to be lacking today, and I'm certain I'm not asking or doing the right thing) I have defined a UI in the resource editor with a Picture Control and assign a bitmap on it :
CONTROL IDB\_BITMAP1,IDC\_BACKGROUND\_PICTURE,"Static",SS\_BITMAP | SS\_CENTERIMAGE,14,7,425,263
The problem is that sometimes (most of the time) the actual bitmap does not have the same size as the picture control. Is there a way to know the actual pixel size of the Picture Control ? Am I doing this the wrong way? or Am I forced to do this in code (get picturecontrol client size, and StretchBlt ... )? Thanks.
I'd rather be phishing!
Maximilien wrote:
Is there a way to know the actual pixel size of the Picture Control ?
You already set this size in the .rc file. But if you mean the real image size... Well, first try to "play" with SS_REALSIZEIMAGE and SS_CENTERIMAGE flags. If it won't help then try to owner-draw. //edit: you could use [GetBitmapDimensionEx function (wingdi.h) | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getbitmapdimensionex) to obtain bitmap size.
-
(google-fu seems to be lacking today, and I'm certain I'm not asking or doing the right thing) I have defined a UI in the resource editor with a Picture Control and assign a bitmap on it :
CONTROL IDB\_BITMAP1,IDC\_BACKGROUND\_PICTURE,"Static",SS\_BITMAP | SS\_CENTERIMAGE,14,7,425,263
The problem is that sometimes (most of the time) the actual bitmap does not have the same size as the picture control. Is there a way to know the actual pixel size of the Picture Control ? Am I doing this the wrong way? or Am I forced to do this in code (get picturecontrol client size, and StretchBlt ... )? Thanks.
I'd rather be phishing!
You know the size of the picture control from the resource file. Or you can use
GetWindowRect
orGetClientRect
to capture it at run time. You can then use StretchBlt[^] to display the bitmap at the appropriate size. Alternatively, depending on what else is in your view, you could resize the picture control. -
Maximilien wrote:
Is there a way to know the actual pixel size of the Picture Control ?
You already set this size in the .rc file. But if you mean the real image size... Well, first try to "play" with SS_REALSIZEIMAGE and SS_CENTERIMAGE flags. If it won't help then try to owner-draw. //edit: you could use [GetBitmapDimensionEx function (wingdi.h) | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getbitmapdimensionex) to obtain bitmap size.
thanks. will skip MFC and do it the good old way.
I'd rather be phishing!
-
You know the size of the picture control from the resource file. Or you can use
GetWindowRect
orGetClientRect
to capture it at run time. You can then use StretchBlt[^] to display the bitmap at the appropriate size. Alternatively, depending on what else is in your view, you could resize the picture control.thanks. will skip MFC and do it the good old way.
I'd rather be phishing!
-
thanks. will skip MFC and do it the good old way.
I'd rather be phishing!
-
thanks. will skip MFC and do it the good old way.
I'd rather be phishing!
Your problem has nothing to do with MFC! MFC is just a wrapper for plain Win32 API