Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximizing an MFC window

Status
Not open for further replies.

timmay3141

Programmer
Dec 3, 2002
468
US
I have a SDI app using MFC which I want to be maximized when it is launched. I thought I could do this by going into the app's InitInstance and changing a line to this:

m_pMainWnd->ShowWindow(SW_MAXIMIZE);

This sort of works - but there is a bit of a problem. Firstly, you can see when the window is first created it is not maximized, but it immediately becomes maximized (it just looks bad). Secondly, I'm using Direct3D and initializing the perspective (which uses the window size) in OnInitialUpdate, which is unfortunately called before ShowWindow is called. This means that the perspective uses the non-maximized window's dimensions, and as a result the images look bad. I could move where I setup the perspective, but as I've never used DirectX in MFC before I don't know exactly where to move it to. Any help would be appreciated.
 
when you create a window using Create* methods, specify explicitly the coordinates of window to use. Don't let the operation system to give some default coordinates.

Ion Filipski
1c.bmp
 
You can also override CWnd::preCreateWindow() to set the desired windowsize.

Greetings,
Rick
 
I changed PreCreateWindow and got it working. Thanks to both of you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top