HelloApp - mfc samples

Minimal MFC sample that illustrates that few lines of code are required to get a window to appear on the screen.

2025-11-25

Written by: xiaobin

The default is to use CFrameWnd!

Create method

Create(NULL, _T("Hello World!"), WS_OVERLAPPEDWINDOW, rectDefault);

CWnd

Use CreateEx() to customize special windows.

AfxRegisterWndClass

const char* AfxRegisterWndClass(UINT nClassStyle,
    HCURSOR hCursor,
    HBRUSH hbrBackground,
    HICON hIcon);
COLOR_WINDOW+1 = COLOR_WINDOWFRAME

LoadCursor

CreateEx method

        CreateEx(WS_EX_CLIENTEDGE,
            AfxRegisterWndClass(0, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_WINDOW+1)),
            _T("Hello-World!"), WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, 0);
CW_USEDEFAULT is valid only for overlapped windows; 
if it is specified for a pop-up or child window, the x and y parameters are set to zero.

Ref