maximizing window in MFC application
-
Hi, I have a MFC application and wish to change the way the application behaves when a user maximises the main window frame. I understand that I need to add a virtual function to the document class that inherits from the CDocument class. However, I am not sure what the name of the function is that is used when maximising the window. If you can tell me, that would be great. Thanks !
-
Hi, I have a MFC application and wish to change the way the application behaves when a user maximises the main window frame. I understand that I need to add a virtual function to the document class that inherits from the CDocument class. However, I am not sure what the name of the function is that is used when maximising the window. If you can tell me, that would be great. Thanks !
the OnSize function takes UINT which identifies the minimise or maximise request. that how ever is in MainFrm and View not Doc example of an action based on minimised action.
void CMainFrame::OnSize(UINT nType, int cx, int cy) { if(nType == SIZE_MINIMIZED) { ShowWindow(SW_HIDE); } else { CFrameWnd::OnSize(nType, cx, cy); } }
hope that helps. if im wrong about the document OnSize let me know please :) -
the OnSize function takes UINT which identifies the minimise or maximise request. that how ever is in MainFrm and View not Doc example of an action based on minimised action.
void CMainFrame::OnSize(UINT nType, int cx, int cy) { if(nType == SIZE_MINIMIZED) { ShowWindow(SW_HIDE); } else { CFrameWnd::OnSize(nType, cx, cy); } }
hope that helps. if im wrong about the document OnSize let me know please :)Hi ya, Thanks for your post. I actually found this
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { // kiran. static const CPoint point0 = CPoint(0, 0); if(m_PageSize != point0) { const long my = lpMMI -> ptMaxSize.y; const long ty = lpMMI -> ptMaxTrackSize.y; lpMMI -> ptMaxSize = m_PageSize; lpMMI -> ptMaxTrackSize = m_PageSize; lpMMI -> ptMaxSize.y = my; lpMMI -> ptMaxTrackSize.y = ty; } CFrameWnd::OnGetMinMaxInfo(lpMMI); }
in my code and put a break point on it when I clicked the maximise button. The code then stopped at the break point proving that this function is invoked when using max / min. I guess the structure should contain info whether the user is doing a max / min ? Thanks -
Hi, I have a MFC application and wish to change the way the application behaves when a user maximises the main window frame. I understand that I need to add a virtual function to the document class that inherits from the CDocument class. However, I am not sure what the name of the function is that is used when maximising the window. If you can tell me, that would be great. Thanks !
-
I NEVER TRIED, but you can test to handle the WM_ONSIZE Message There you get the UINT nType, which you can test on if(nType == SIZE_MEXIMIZED) I hope it's true what i say :laugh: Good luck
Hi Yes, I am sure what you suggested will work (am implementing it now) as I found this example
void CMainFrame::OnSize(UINT nType, int cx, int cy) { CFrameWnd::OnSize(nType, cx, cy); CMenu* pmenu = GetMenu(); if (nType == SIZE_MAXIMIZED) pmenu->EnableMenuItem(ID_FREEZE, MF_DISABLED|MF_GRAYED); else pmenu->EnableMenuItem(ID_FREEZE, MF_ENABLED); Draw }
Thanks for your suggestion. -
Hi ya, Thanks for your post. I actually found this
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { // kiran. static const CPoint point0 = CPoint(0, 0); if(m_PageSize != point0) { const long my = lpMMI -> ptMaxSize.y; const long ty = lpMMI -> ptMaxTrackSize.y; lpMMI -> ptMaxSize = m_PageSize; lpMMI -> ptMaxTrackSize = m_PageSize; lpMMI -> ptMaxSize.y = my; lpMMI -> ptMaxTrackSize.y = ty; } CFrameWnd::OnGetMinMaxInfo(lpMMI); }
in my code and put a break point on it when I clicked the maximise button. The code then stopped at the break point proving that this function is invoked when using max / min. I guess the structure should contain info whether the user is doing a max / min ? Thanksminkowski wrote:
...proving that this function is invoked when using max / min.
True, but that does not mean it is the only function involved in such a request. The
WM_GETMINMAXINFO
message is sent to a window when the size or position of the window is about to change. You can handle this message to override the window's default maximized size and position, or its default minimum or maximum tracking size. TheWM_SIZE
message is sent to a window after its size has changed. Given your request of, "...change the way the application behaves when a user maximises the main window frame.", I'd opt for handling this message.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne