{"id":194,"date":"2014-06-09T17:09:37","date_gmt":"2014-06-09T08:09:37","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=194"},"modified":"2019-06-27T10:35:14","modified_gmt":"2019-06-27T01:35:14","slug":"%ed%81%b4%eb%9e%98%ec%8a%a4%eb%a7%8c-%ec%82%ac%ec%9a%a9%ed%95%9c-window","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=194","title":{"rendered":"\ud074\ub798\uc2a4\ub9cc \uc0ac\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\nclass CApp{\r\n    static char szAppName[];\r\n\tHWND hwnd;\r\n\tMSG msg;\r\n\tWNDCLASSEX wndclass;\r\n\t\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\tvoid OnCreate();\r\n\tvoid OnDraw();\r\n\tvoid OnDestroy();\r\n};\r\n\r\nvoid CApp::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 CApp::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 CApp::ExitInstance(){\r\n\treturn msg.wParam;\r\n}\r\n\r\nchar CApp::szAppName[]=\"HelloWin\";\r\n\r\nvoid CApp::OnCreate(){\r\n}\r\n\r\nvoid CApp::OnDraw(){\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 CApp::OnDestroy(){\r\n\tPostQuitMessage(0);\r\n}\r\n\r\nCApp 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\tapp.OnCreate();\r\n\t\treturn 0;\r\n\tcase WM_PAINT:\r\n\t\tapp.OnDraw();\r\n\t\treturn 0;\r\n\tcase WM_DESTROY:\r\n\t\tapp.OnDestroy();\r\n\t\treturn 0;\r\n\t}\r\n\treturn DefWindowProc(hwnd,iMsg,wParam,lParam);\r\n}\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>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;Windows.h&gt; LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam); class CApp{ 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 void OnCreate(); void OnDraw(); void OnDestroy(); }; void CApp::InitInstance(HINSTANCE hInstance, PSTR szCmdLine, int iCmdShow) { wndclass.cbSize = sizeof(wndclass); wndclass.style =\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=194\">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-194","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\/194","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=194"}],"version-history":[{"count":4,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/194\/revisions"}],"predecessor-version":[{"id":532,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/194\/revisions\/532"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}