Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows
), the user is still able to resize it. One solution you can use is to call the
ReleaseCapture() function on the WM_SIZE event. That way, every time the user grabs
a border and starts dragging, the mouse would lose control of the border:
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
ReleaseCapture();
// TODO: Add your message handler code here
}
Another way the user change the size of a window consists of minimizing it. As you
surely know already, to minimize the window, the user clicks the system Minimize
button. If at two time you want to find out whether a window is minimized, you can
call the CWnd::IsIconic() method. Its syntax is:
BOOL IsIconic( ) const;
This method returns TRUE if the window is minimized. Otherwise it returns FALSE.
If you do not want the user to be able to minimize a wndow, you can omit the
WS_MINIMIZEBOX style when creating the window.
If you want the user to be able to maximize the window, add the WS_ MAXIMIZEBOX
style. This can be done as follows:
CMainFrame::CMainFrame()
{
// Declare a window class variable
WNDCLASS WndCls;
const char *StrWndName = "Windows Fundamentals";
...
const char *StrClass = AfxRegisterWndClass(WndCls.style, WndCls.hCursor,
WndCls.hbrBackground, WndCls.hIcon);
Create(StrClass, StrWndName,
WS_OVERLAPPED | WS_CAPTION |
WS_SYSMENU | WS_THICKFRAME |
WS_MAXIMIZEBOX, rectDefault);
}
7.
At any time, to find out if the window is maximized, you can call the
CWnd::IsZoomed() method. Its syntax is:
BOOL IsZoomed( ) const;
This method returns TRUE if the window is maximized. Otherwise, it returns FALSE.
If you created the application using AppWizard, all system buttons are added to the
frame. If you want to remove a style, use the CFrameWnd::PreCreateWindow() event.
In the following example, the system Minimize button is removed on the frame: