{"id":216,"date":"2014-06-10T17:19:59","date_gmt":"2014-06-10T08:19:59","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=216"},"modified":"2014-06-10T17:19:59","modified_gmt":"2014-06-10T08:19:59","slug":"%eb%a9%94%ec%8b%9c%ec%a7%80%eb%a7%8c-%ec%a7%91%ec%a4%91%ed%95%9c-window","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=216","title":{"rendered":"\uba54\uc2dc\uc9c0\ub9cc \uc9d1\uc911\ud55c window"},"content":{"rendered":"<p><a href=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2014\/06\/classwindow.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2014\/06\/classwindow-300x236.png\" alt=\"classwindow\" width=\"300\" height=\"236\" class=\"alignnone size-medium wp-image-197\" srcset=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2014\/06\/classwindow-300x236.png 300w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2014\/06\/classwindow.png 319w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nstdafx.h<br \/>\n<pre id=\"code_snippet_56\" style=\"position:relative;width:100%;border:0;padding:0;\">#include &lt;windows.h&gt;\r\n\r\n#ifndef _stdafx_\r\n#define _stdafx_\r\n\r\n#define DECLARE_MESSAGE_MAP()    static MessageMap messageMap[];\r\n#define BEGIN_MESSAGE_MAP(class_name)\tMessageMap class_name::messageMap[]={\r\n#define END_MESSAGE_MAP()\t{0,NULL}};\r\nLRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam);\r\n\r\n#endif _stdafx_<\/pre><br \/>\nstdafx.cpp<br \/>\n<pre id=\"code_snippet_57\" style=\"position:relative;width:100%;border:0;padding:0;\">#include &lt;windows.h&gt;\r\n#include &quot;CView.h&quot;\r\n\r\nextern CView app;\r\n\r\nLRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)\r\n{\r\n    int i=0;\r\n\r\n\twhile(CView::messageMap[i].iMsg!=0){\r\n\t\tif(iMsg==CView::messageMap[i].iMsg){\r\n\t\t\tfpCViewGlobal=CView::messageMap[i].fp;\r\n\t\t\t(app.*fpCViewGlobal)(wParam,lParam);\r\n\t\t\treturn 0L;\r\n\t\t}\r\n\t\t++i;\r\n\t}\r\n\treturn DefWindowProc(hwnd,iMsg,wParam,lParam);\r\n}\r\nint WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)\r\n{\r\n\tapp.InitInstance(hInstance,szCmdLine,iCmdShow);\r\n\tapp.Run();\r\n\treturn app.ExitInstance();\r\n}<\/pre><\/p>\n<p>CObject.h<br \/>\n<pre id=\"code_snippet_58\" style=\"position:relative;width:100%;border:0;padding:0;\">#include &lt;Windows.h&gt;\r\n\r\n#ifndef _CObject_\r\n#define _CObject_\r\n\/\/Class CObject\r\nclass CObject{\r\nprotected:\r\n    static char szAppName[];\r\n\tHWND hwnd;\r\n\tMSG msg;\r\n\tWNDCLASSEX wndclass;\r\npublic:\r\n\tvoid InitInstance(HINSTANCE hInstance, PSTR szCmdLine, int iCmdShow);\r\n\tvoid Run();\/\/Message\r\n    WPARAM ExitInstance(); \/\/exit\r\n};\r\n#endif _CObject_<\/pre><br \/>\nCObject.cpp<br \/>\n<pre id=\"code_snippet_59\" style=\"position:relative;width:100%;border:0;padding:0;\">#include &lt;Windows.h&gt;\r\n#include &quot;stdafx.h&quot;\r\n#include &quot;CObject.h&quot;\r\n\r\nvoid CObject::InitInstance(HINSTANCE hInstance, PSTR szCmdLine, int iCmdShow)\r\n{\r\n    wndclass.cbSize = sizeof(wndclass);\r\n\twndclass.style  = CS_HREDRAW|CS_VREDRAW;\r\n\twndclass.lpfnWndProc = WndProc;\r\n\twndclass.cbClsExtra =0;\r\n\twndclass.cbWndExtra= 0;\r\n\twndclass.hInstance = hInstance;\r\n\twndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);\r\n\twndclass.hCursor = LoadCursor(NULL,IDC_ARROW);\r\n\twndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);\r\n\twndclass.lpszMenuName = NULL;\r\n\twndclass.lpszClassName = szAppName;\r\n\twndclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);\r\n\r\n\tRegisterClassEx(&amp;wndclass);\r\n\r\n\thwnd = CreateWindow(szAppName,\r\n\t\t\t\t\t\t&quot;Hello Program&quot;,\r\n\t\t\t\t\t\tWS_OVERLAPPEDWINDOW,\r\n\t\t\t\t\t\tCW_USEDEFAULT,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\tCW_USEDEFAULT,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\tNULL,\r\n\t\t\t\t\t\tNULL,\r\n\t\t\t\t\t\thInstance,\r\n\t\t\t\t\t\tNULL);\r\n\tShowWindow(hwnd,iCmdShow);\r\n\tUpdateWindow(hwnd);\r\n}\r\n\r\nvoid CObject::Run(){\r\n\twhile(GetMessage(&amp;msg,NULL,0,0)){\r\n\t\tTranslateMessage(&amp;msg);\r\n\t\tDispatchMessage(&amp;msg);\r\n\t}\r\n}\r\n\r\nWPARAM CObject::ExitInstance(){\r\n\treturn msg.wParam;\r\n}\r\n\r\nchar CObject::szAppName[]=&quot;HelloWin&quot;;<\/pre><\/p>\n<p>CView.h \uba54\uc2dc\uc9c0\ub9cc \uc9d1\uc911<br \/>\n<pre id=\"code_snippet_60\" style=\"position:relative;width:100%;border:0;padding:0;\">#include &lt;windows.h&gt;\r\n#include &quot;stdafx.h&quot;\r\n#include &quot;CObject.h&quot;\r\n\r\n#ifndef _CView_\r\n#define _CView_\r\n\r\nclass CView;\r\n\r\ntypedef LRESULT (CView::*CViewFunPointer)(WPARAM,LPARAM);\/\/\ud568\uc218\ud3ec\uc778\ud130\r\n\r\ntypedef struct tagMessgeMap{ \/\/\uad6c\uc870\uccb4\r\n    UINT iMsg;\r\n\tCViewFunPointer fp;  \/\/\ud568\uc218\ud3ec\uc778\ud130 \uc8fc\uc18c\r\n}MessageMap;\r\nstatic CViewFunPointer fpCViewGlobal; \/\/\uc815\uc801 \uc8fc\uc18c\r\n\r\nclass CView:public CObject{\r\npublic:\r\n\t\/\/{{AFX_MESSAGE\r\n\tLRESULT OnCreate(WPARAM,LPARAM);\r\n\tLRESULT OnDraw(WPARAM,LPARAM);\r\n\tLRESULT OnDestroy(WPARAM,LPARAM);\r\n\tLRESULT OnLButtonDown(WPARAM,LPARAM);\r\n\t\/\/}}AFX_MESSAGE\r\n\r\n\tDECLARE_MESSAGE_MAP()\r\n};\r\n\r\n#endif _CView_<\/pre><br \/>\nCView.cpp<br \/>\n<pre id=\"code_snippet_61\" style=\"position:relative;width:100%;border:0;padding:0;\">#include &lt;windows.h&gt;\r\n#include &quot;stdafx.h&quot;\r\n#include &quot;CView.h&quot;\r\n\r\nCView app;\r\n\r\n\/\/{{AFX_MESSAGE\r\nBEGIN_MESSAGE_MAP(CView)\r\n    {WM_CREATE,&amp;CView::OnCreate},\r\n\t{WM_PAINT,&amp;CView::OnDraw},\r\n\t{WM_DESTROY,&amp;CView::OnDestroy},\r\n\t{WM_LBUTTONDOWN,&amp;CView::OnLButtonDown},\r\nEND_MESSAGE_MAP()\r\n\/\/}}AFX_MESSAGE\r\n\r\nLRESULT CView::OnCreate(WPARAM wParam,LPARAM lParam){\r\n\treturn 0L;\r\n}\r\n\r\nLRESULT CView::OnDraw(WPARAM wParam,LPARAM lParam){\r\n\tHDC hdc;\r\n\tPAINTSTRUCT ps;\r\n\tRECT rect;\r\n\r\n\thdc=BeginPaint(hwnd,&amp;ps);\r\n\tGetClientRect(hwnd,&amp;rect);\r\n\tDrawText(hdc,&quot;Hello Window&quot;,-1,&amp;rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);\r\n\tEndPaint(hwnd,&amp;ps);\r\n\treturn 0L;\r\n}\r\n\r\nLRESULT CView::OnDestroy(WPARAM wParam,LPARAM lParam){\r\n\tPostQuitMessage(0);\r\n\treturn 0L;\r\n}\r\n\r\nLRESULT CView::OnLButtonDown(WPARAM wParam,LPARAM lParam) {\r\n\tPostQuitMessage(0);\r\n\treturn 0L;\r\n}<\/pre><br \/>\nMFC\uac00 \uc0dd\uc131\ud55c \ucf54\ub4dc\uc5d0 CView.h CView.cpp \ub9cc \uc788\ub2e4\uace0 \uc0dd\uac01\ud574\ubd10\ub77c.<br \/>\n\uac04\uacb0\ud568 \uadf8 \uc790\uccb4\uc774\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>stdafx.h stdafx.cpp CObject.h CObject.cpp CView.h \uba54\uc2dc\uc9c0\ub9cc \uc9d1\uc911 CView.cpp MFC\uac00 \uc0dd\uc131\ud55c \ucf54\ub4dc\uc5d0 CView.h CView.cpp \ub9cc \uc788\ub2e4\uace0 \uc0dd\uac01\ud574\ubd10\ub77c. \uac04\uacb0\ud568 \uadf8 \uc790\uccb4\uc774\ub2e4.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-216","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216"}],"version-history":[{"count":1,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":217,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions\/217"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}