Basic MFC question
-
Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan
-
Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan
-
Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan
This site contains some examples of how to save and restore window position. I saw an article http://www.codeproject.com/docview/persistframes.asp[^] about storing and loading positions of SDI/MDI ChildFrame, MainFrame and so on more recently.
-
Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan
add this in CMainFrame::OnCreate() :
SetWindowPos(NULL, 0,0, 600,350,SWP_NOZORDER|SWP_NOMOVE);
-
Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan
In addition to S.Rod.'s answer you can also use MoveWindow(200,100,450,300,TRUE); This will change the size and move it around the screen Also, GetClientRect(&rcClient); // get size of client area m_cyClient = rcClient.bottom-rcClient.top; // only the 'y' length Will get the size of the window. To get the left and right sides you can rcClient.Right-rcClien.Right Jeff Patterson Programmers speak in Code. www.anti-dmca.org