How do I resize my SDI window (i want to do it in my OnNewDocument in the document class)?
Is it something like this?
thanks.Code:CMainFrame *pMF = (CMainFrame*)AfxGetMainWnd();
pMF->SetWindowPos(NULL, 0,0,50,50, SWP_NOMOVE);
Printable View
How do I resize my SDI window (i want to do it in my OnNewDocument in the document class)?
Is it something like this?
thanks.Code:CMainFrame *pMF = (CMainFrame*)AfxGetMainWnd();
pMF->SetWindowPos(NULL, 0,0,50,50, SWP_NOMOVE);
Well, why not try it?
my program crash with that piece of code, i've tried several things, but i think that i have to create a pointer to my mainframe, but i dunno how...
What kind of crash? I don't think you may pass NULL as first parameter. Use SWP_NOZORDER and pass any of the constants if you don't want to change the z order.
And you don't need to cast to a CMainFrame, CWnd supports SetWindowPos, so you can write
AfxGetMainWnd()->SetWindowPos(...);
Oh, and I recommend that you learn using the debugger, it's a wonderful thing...
Well, the pointer to the MainFrame "pMF" or "AfxGetMainWnd()" returns with no value. (pMF = 0x00000000 {CMainFrame hWnd=???})
So I get the error: "Unhandled exception at 0x7c208dd4 (mfc70d.dll) in MineSweeper.exe: 0xC0000005: Access violation reading location 0x00000020".
Then you obviously don't have a valid main window, at least not one that's properly registered with MFC.
Can you post your InitInstance function here?