Visual C++ and MFC Fundamentals Chapter 5: The Document/View Architecture
WM_SHOWWINDOW: After creating a window, it needs to be displayed. Also, if the
window was previously hidden, you can decide to show it. On the other hand, if a
window is displaying, you may want to hide it, for any reason you judge necessary. To
take any of these actions, that is, to show or hide a window, you must send the
ON_WM_SHOWWINDOW message. The syntax of this message is:afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);When using this message, bShow is a Boolean argument determines what state to apply to
the window. If it is TRUE, the window needs to be displayed. If it is FALSE, the
window must be hidden.nStatus is a positive integer that can have one of the following values:Value DescriptionSW_PARENTCLOSING
If the window that sent this message is a frame, the
window is being minimized.
If the window that sent this message is hosted by another
window, the window is being hidden.SW_PARENTOPENING
If the window that sent this message is a frame, the
window is being restored.
If the window that sent this message is hosted by another
window, the window is displaying0 The message was sent from a CWnd::ShowWindow()
methodPractical Learning: Showing a Window
- To maximize the window at startup, change the program as follows:
#include <afxwin.h>class CMainFrame : public CFrameWnd
{
public:
CMainFrame ();protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
DECLARE_MESSAGE_MAP()
};CMainFrame::CMainFrame()
{
// Create the window's frame
Create(NULL, "Windows Application", WS_OVERLAPPEDWINDOW,
CRect(120, 100, 700, 480), NULL);
}class CExerciseApp: public CWinApp
{
public:
BOOL InitInstance();
};BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)