How to maximize child windows
-
I have an MFC MDI program using VC6. When the application starts I want the initial child window to be maximized within the frame. I've tried ModifyStyle(0,WS_MAXIMIZE); in the OnActivateView() and added cs.style |= WS_MAXIMIZE; to the beginning of PreCreateWindow(); Any other ideas?
-
I have an MFC MDI program using VC6. When the application starts I want the initial child window to be maximized within the frame. I've tried ModifyStyle(0,WS_MAXIMIZE); in the OnActivateView() and added cs.style |= WS_MAXIMIZE; to the beginning of PreCreateWindow(); Any other ideas?
I don't know if this is the correct way, but in the ActivateFrame Method I set the SW_SHOMAXIMIZED flag, this does the job just for the intial activation of the window.
void CChildFrame::ActivateFrame(int nCmdShow) { // TODO: Modify this function to change how the frame is activated. nCmdShow = SW_SHOWMAXIMIZED; CMDIChildWnd::ActivateFrame(nCmdShow); }
If you have more than one window in your MDI, i have noticed it will unmaximize when you switch to a new window.. I tried to get around this by using a ModifyStyle(NULL,WS_MAXIMIZE)void CChildFrame::OnSetFocus(CWnd* pOldWnd) { CMDIChildWnd::OnSetFocus(pOldWnd); // TODO: Add your message handler code here ModifyStyle(NULL,WS_MAXIMIZE); }
As I said, I don't know if this is the correct way to do it.. Its just what I figured out while I was playing.. Please let me know if you find a better way. -Rick -
I don't know if this is the correct way, but in the ActivateFrame Method I set the SW_SHOMAXIMIZED flag, this does the job just for the intial activation of the window.
void CChildFrame::ActivateFrame(int nCmdShow) { // TODO: Modify this function to change how the frame is activated. nCmdShow = SW_SHOWMAXIMIZED; CMDIChildWnd::ActivateFrame(nCmdShow); }
If you have more than one window in your MDI, i have noticed it will unmaximize when you switch to a new window.. I tried to get around this by using a ModifyStyle(NULL,WS_MAXIMIZE)void CChildFrame::OnSetFocus(CWnd* pOldWnd) { CMDIChildWnd::OnSetFocus(pOldWnd); // TODO: Add your message handler code here ModifyStyle(NULL,WS_MAXIMIZE); }
As I said, I don't know if this is the correct way to do it.. Its just what I figured out while I was playing.. Please let me know if you find a better way. -RickThank you for your help. ActivateFrame() alone works in my program without the problem you described. My view is derived from CHtmlView, which is derived from CFormView. I created two instances of the same view during runtime (that is, I selected File | New), switched between them (Window | ) and both windows stayed maximized.
-
I don't know if this is the correct way, but in the ActivateFrame Method I set the SW_SHOMAXIMIZED flag, this does the job just for the intial activation of the window.
void CChildFrame::ActivateFrame(int nCmdShow) { // TODO: Modify this function to change how the frame is activated. nCmdShow = SW_SHOWMAXIMIZED; CMDIChildWnd::ActivateFrame(nCmdShow); }
If you have more than one window in your MDI, i have noticed it will unmaximize when you switch to a new window.. I tried to get around this by using a ModifyStyle(NULL,WS_MAXIMIZE)void CChildFrame::OnSetFocus(CWnd* pOldWnd) { CMDIChildWnd::OnSetFocus(pOldWnd); // TODO: Add your message handler code here ModifyStyle(NULL,WS_MAXIMIZE); }
As I said, I don't know if this is the correct way to do it.. Its just what I figured out while I was playing.. Please let me know if you find a better way. -RickCChildFrame::ActivateFrame() is a recomended way to do this. I don't know if your code in CChildFrame::OnSetFocus() will do anything usefull however. With MDI only one window is ever maximized at a time. When you switch to another window, the current window is restored to its normal size and then the new window is maximized. This is all a pain in the backside as far as I'm concerned and I assume it has something to do with the early Win 3.x MDI implementation. One of the problems with this is that you can see the windows flash to restored and then maximized size as you change MDI windows and open and close windows. This flashing varies across different windows versions. In my CChildFrame::ActivateFrame() in ED for Windows (see sig) I wrap the call to CMDIChildWnd::ActivateFrame() in pMDIClient->SetRedraw( FALSE/TRUE ) calls. Neville Franks, Author of ED for Windows. www.getsoft.com
-
CChildFrame::ActivateFrame() is a recomended way to do this. I don't know if your code in CChildFrame::OnSetFocus() will do anything usefull however. With MDI only one window is ever maximized at a time. When you switch to another window, the current window is restored to its normal size and then the new window is maximized. This is all a pain in the backside as far as I'm concerned and I assume it has something to do with the early Win 3.x MDI implementation. One of the problems with this is that you can see the windows flash to restored and then maximized size as you change MDI windows and open and close windows. This flashing varies across different windows versions. In my CChildFrame::ActivateFrame() in ED for Windows (see sig) I wrap the call to CMDIChildWnd::ActivateFrame() in pMDIClient->SetRedraw( FALSE/TRUE ) calls. Neville Franks, Author of ED for Windows. www.getsoft.com
Hi, I'm a newbie to MFC. I have an MDI with CFormView as my base class. I can't find the ActivateFrame() function. Someone suggested I try this in CMyFormView::OnInitialUpdate() CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(FALSE); but this still doesn't work. Any suggestions? Cheers
-
Hi, I'm a newbie to MFC. I have an MDI with CFormView as my base class. I can't find the ActivateFrame() function. Someone suggested I try this in CMyFormView::OnInitialUpdate() CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(FALSE); but this still doesn't work. Any suggestions? Cheers
Kash wrote: ActivateFrame() is a member of CMDIChildWnd. The Help will tell you this. ;-) To access it you need to derive a class from CMDIChildWnd. This is usually named CChildFrame. Then you can use CChildFrame::ActivateFrame() If you want to get at the MDI Client Window inside this then use: CWnd* pMDIClient = GetParent(); Make sure you call CMDIChildWnd::ActivateFrame() from within your CChildFrame::ActivateFrame(). Neville Franks, Author of ED for Windows. www.getsoft.com
-
I have an MFC MDI program using VC6. When the application starts I want the initial child window to be maximized within the frame. I've tried ModifyStyle(0,WS_MAXIMIZE); in the OnActivateView() and added cs.style |= WS_MAXIMIZE; to the beginning of PreCreateWindow(); Any other ideas?
I've used it in PreCreateWindow in the ChildFrm and it works great. cs.style |= WS_MAXIMIZE. I placed it after the CMDIChildWnd::PreCreateWindow( cs ); Perhaps something else is confusing it. Joel Lucsy (jjlucsy@ameritech.net)
-
I've used it in PreCreateWindow in the ChildFrm and it works great. cs.style |= WS_MAXIMIZE. I placed it after the CMDIChildWnd::PreCreateWindow( cs ); Perhaps something else is confusing it. Joel Lucsy (jjlucsy@ameritech.net)
I didn't put it in that class, and that's why it probably did not work. Thanks for your suggestion.