Chapter 2 Variables and Identifiers Visual C++ and MFC Fundamentals
Practical Learning: Creating a Simple Window
- To use the dynamic macros, change the file as follows:
#include <afx.h>
#include <afxwin.h>
class CSimpleFrame : public CFrameWnd
{
public:
CSimpleFrame();
DECLARE_DYNCREATE(CSimpleFrame)
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CSimpleApp : public CWinApp
{
BOOL InitInstance();
};
IMPLEMENT_DYNCREATE(CSimpleFrame, CFrameWnd)
CSimpleFrame::CSimpleFrame()
{
// Create the window's frame
Create(NULL, "Windows Application");
}
CSimpleApp theApp;
- Test the application and return to MSVC.
2.2.4 Windows Styles.......................................................................................
Windows styles are characteristics that control such features as its appearance, its
borders, its minimized, its maximized, or its resizing states, etc.
After creating a window, to display it to the user, you can apply the WS_VISIBLE style
to it. Here is an example:
Create(NULL, "Windows Application", WS_VISIBLE);
The top section of a window has a long bar called the title bar. This is a section we
referred to above and saw that it is used to display the name of the window. This bar is
added with the WS_CAPTION value for the style argument. Here is an example:
Create(NULL, "Windows Application", WS_CAPTION);