목차

<title>ATL/WTL</title>

ATL/WTL

WTL for MFC Programmers, Part I - ATL GUI Classes

CWindowImpl

창을 만드는 설명

Using the ATL Windowing Classes

빈 윈도우 만들기

#include "targetver.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
 
#include <atlbase.h>
#include <atlwin.h>
 
#include "resource.h"
 
 
class MainWindow : public CWindowImpl<MainWindow>
{
public:
    DECLARE_WND_CLASS(_T("210424_A"));
 
 
    BEGIN_MSG_MAP(MainWindow);
    //MESSAGE_HANDLER(WM_PAINT, OnPaint)
    MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
    END_MSG_MAP();
 
 
    LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        PostQuitMessage(0);
        return 0;
    }
};
 
 
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
    MainWindow _wnd;
    RECT _rc = { 0, 0, 200, 200 };
 
    _wnd.Create(0, /*CWindow::rcDefault*/_rc, _T("Wnd"), WS_OVERLAPPEDWINDOW, 0, (UINT)NULL);
    _wnd.CenterWindow();
 
    if(!_wnd) return -1;
 
    _wnd.ShowWindow(nCmdShow);
    _wnd.UpdateWindow();
 
    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_HANENGCURSOR));
 
    MSG msg;
    while(GetMessage(&msg, nullptr, 0, 0))
    {
        if(!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
 
    return 0;
}