Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / November 2004

Tip: Looking for answers? Try searching our database.

Bitmap and SetWindowPos

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JohnL - 26 Nov 2004 23:08 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.