{"id":205,"date":"2014-06-09T19:14:33","date_gmt":"2014-06-09T10:14:33","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=205"},"modified":"2019-06-27T10:56:27","modified_gmt":"2019-06-27T01:56:27","slug":"%ea%b0%80%ec%83%81%ed%95%a8%ec%88%98%eb%a5%bc-%ec%9d%b4%ec%9a%a9%ed%95%9c-window","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=205","title":{"rendered":"\uac00\uc0c1\ud568\uc218\ub97c \uc774\uc6a9\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><\/p>\n<pre class=\"lang:c++ decode:true \" >#include &lt;Windows.h&gt;\r\n\r\nLRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam);\r\n\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\t\/\/message handler\r\n\tvirtual void OnCreate() = 0;\r\n\tvirtual void OnDraw() = 0;\r\n\tvirtual void OnDestroy() = 0;\r\n};\r\n\r\nvoid CObject::InitInstance(HINSTANCE hInstance, PSTR szCmdLine, int iCmdShow)\r\n{\r\n\twndclass.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\"Hello Program\",\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[]=\"HelloWin\";\r\n\r\nCObject* pCObject;\r\n\r\n\/\/class CView\r\nclass CView:public CObject{\r\n\t\/\/override all message handler\r\n\tvoid OnCreate();\r\n\tvoid OnDraw();\r\n\tvoid OnDestroy();\r\n};\r\n\r\nvoid CView::OnCreate(){\r\n}\r\n\r\nvoid CView::OnDraw()\r\n{\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,\"Hello Window\",-1,&amp;rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);\r\n\tEndPaint(hwnd,&amp;ps);\r\n}\r\n\r\nvoid CView::OnDestroy() {\r\n\tPostQuitMessage(0);\r\n}\r\n\r\nCView app;\r\n\r\nLRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)\r\n{\r\n\tswitch(iMsg){\r\n\tcase WM_CREATE:\r\n\t\tpCObject-&gt;OnCreate(); \/\/CObject* pCObject;\r\n\t\treturn 0;\r\n\tcase WM_PAINT:\r\n\t\tpCObject-&gt;OnDraw();\r\n\t\treturn 0;\r\n\tcase WM_DESTROY:\r\n\t\tpCObject-&gt;OnDestroy();\r\n\t\treturn 0;\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\tpCObject = &amp;app; \/\/ CView app;\r\n\tpCObject-&gt;InitInstance(hInstance,szCmdLine,iCmdShow);\r\n\tpCObject-&gt;Run();\r\n\treturn pCObject-&gt;ExitInstance();\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;Windows.h&gt; LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam); \/\/Class CObject class CObject{ protected: static char szAppName[]; HWND hwnd; MSG msg; WNDCLASSEX wndclass; public: void InitInstance(HINSTANCE hInstance, PSTR szCmdLine, int iCmdShow); void Run();\/\/Message WPARAM ExitInstance(); \/\/exit \/\/message handler virtual void OnCreate() = 0; virtual void OnDraw() = 0; virtual void OnDestroy() = 0; }; void\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=205\">Read More &raquo;<\/a><\/span><\/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-205","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\/205","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=205"}],"version-history":[{"count":2,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/205\/revisions"}],"predecessor-version":[{"id":545,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/205\/revisions\/545"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}