Click to See Complete Forum and Search --> : Setting the Window size


April 6th, 1999, 02:25 PM
hi

in a simple SDI-Application created by the MFC-wizard, how do I set the windowsize upon the initialization of the program?
I´ve tried inserting the following commands in the CView::PreCreateWindow function:

CWnd* mywin = AfxGetMainWnd(); // Points to my only application window ( I think )
mywin->SetWindowPos(mywin, 300,300,200,100,SWP_SHOWWINDOW);

It runs ok but does not do anything at all. Where should this statement be located or what would be the correct command?

thx

Posterboy
April 6th, 1999, 03:03 PM
You just set the CREATESTRUCT to the disered width, hieght, and starting position :
Look up CREATESTRUCT in the msdn libraray
example:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx = ?;
cs.cy = ?;
cs.x = ?;
cs.y = ?;

return TRUE;
}

Allen Yuh
April 6th, 1999, 03:26 PM
You should determine the size you want before call
CWnd::PreCreateWindow

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx = ?;
cs.cy = ?;
cs.x = ?;
cs.y = ?;

return CFrameWnd::PreCreateWindow(cs);
}

Good luck.