Hi there,
I am developing a Win32 application with Visual C++ 6.0.
I put two bitmaps (CStatic control) on the dialog and hope to control their
sizes by using SetWindowPos function. The bitmaps are actually first
imported to ResourceView, then assigned to the CStatic control. I tried
SetWindowPos() inside of CDialog::OnInitDialog(), however, I found the
function only takes effects on one bitmap, not the other. I compared the two
bitmaps and see nothing difference between them. I am really hammered this
time.
Anybody can help?
Thanks in advance.
John
//In DlgTestDlg2.cpp
BOOL CDlgTestDlg2::OnInitDialog()
{
CDialog::OnInitDialog();
//Set the emulator
GetDlgItem(IDC_Emulator)->SetWindowPos ( &wndBottom, 0, 0,
245, 313,
SWP_SHOWWINDOW);
//Set the menu bar
GetDlgItem(IDC_MenuBar)->SetWindowPos ( &wndTop, 0, 0,
245, 313,
SWP_SHOWWINDOW);
}
//In Resource File
CONTROL 130,IDC_Emulator,"Static",SS_BITMAP,0,3,245,313
CONTROL 134,IDC_MenuBar,"Static",SS_BITMAP,31,337,184,18
//In Resource.h
#define IDC_MenuBar 1000
#define IDC_Emulator 1005
JohnL - 28 Nov 2004 04:05 GMT
Sorry, I found a typo in my last email.
Here is the correct one.
//Set the menu bar
GetDlgItem(IDC_MenuBar)->SetWindowPos ( &wndTop, 20, 260,
200, 45,
SWP_SHOWWINDOW);
Still the same problem. I tried different settings, and the second
SetWindowPos just did not work. Any idea?
Thanks.
John
> Hi there,
>
[quoted text clipped - 39 lines]
> #define IDC_MenuBar 1000
> #define IDC_Emulator 1005
David Lowndes - 28 Nov 2004 10:12 GMT
>Sorry, I found a typo in my last email.
>..
>Still the same problem. I tried different settings, and the second
>SetWindowPos just did not work. Any idea?
John,
You say it doesn't work - specifically what doesn't work? Is the
control visible in it's original position, or not visible at all? Have
you checked with Spy++ where the control really is? Is the first one
working (since it has the same co-ords as you've used in the RC file)?
I'm not sure why you're specifying top/bottom in your code - if
there's no reason, don't do it and use SWP_NOZORDER.
Dave

Signature
MVP VC++ FAQ: http://www.mvps.org/vcfaq
JohnL - 29 Nov 2004 16:22 GMT
The first bitmap is visible and the size is changed. The second bitmap is
visible too but the size is not changed.
I tried all the options including SWP_NOZORDER but no luck.
John
> >Sorry, I found a typo in my last email.
> >..
[quoted text clipped - 12 lines]
>
> Dave
JohnL - 29 Nov 2004 17:13 GMT
Just found the reason why the second bitmap cannot be sized. The second
bitmap was declared by me as a super class of CStatic class: CBmpStatic.
Inside of BOOL CBmpStatic::ReloadBitmap(int nBitmapID), I use the following
codes to load different bitmaps during runtime.
hBmp = (HBITMAP)::LoadImage( AfxGetInstanceHandle(),
MAKEINTRESOURCE(nBitmapID), IMAGE_BITMAP, 0,0,
LR_LOADMAP3DCOLORS );
So it will use default size. However, after I set the width and height in
pixels, the new size still does not take effect. Any idea?
hBmp = (HBITMAP)::LoadImage( AfxGetInstanceHandle(),
MAKEINTRESOURCE(nBitmapID), IMAGE_BITMAP, 300,100,
LR_LOADMAP3DCOLORS );
John
> >Sorry, I found a typo in my last email.
> >..
[quoted text clipped - 12 lines]
>
> Dave
JohnL - 29 Nov 2004 17:19 GMT
Just solved the problem. ::LoadImage now works.
Thanks for the response.
John
> >Sorry, I found a typo in my last email.
> >..
[quoted text clipped - 12 lines]
>
> Dave