{"id":24,"date":"2013-11-10T07:40:34","date_gmt":"2013-11-09T22:40:34","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=24"},"modified":"2018-08-17T15:25:57","modified_gmt":"2018-08-17T06:25:57","slug":"apiwin32-winmain-%ea%b8%b0%eb%b3%b8%ec%86%8c%ec%8a%a4%ec%bd%94%eb%93%9c","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=24","title":{"rendered":"[API]Win32 WinMain \uae30\ubcf8\uc18c\uc2a4\ucf54\ub4dc"},"content":{"rendered":"<p><a href=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2013\/11\/Win32Project3.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2013\/11\/Win32Project3-300x191.jpg\" alt=\"Win32Project3\" width=\"300\" height=\"191\" class=\"alignnone size-medium wp-image-40\" srcset=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2013\/11\/Win32Project3-300x191.jpg 300w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2013\/11\/Win32Project3.jpg 461w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<pre class=\"lang:c++ decode:true \" >\/\/ Win32Project3.cpp : \uc751\uc6a9 \ud504\ub85c\uadf8\ub7a8\uc5d0 \ub300\ud55c \uc9c4\uc785\uc810\uc744 \uc815\uc758\ud569\ub2c8\ub2e4.\r\n\/\/\r\n\r\n#include \"stdafx.h\"\r\n#include \"Win32Project3.h\"\r\n\r\n#define MAX_LOADSTRING 100\r\n\r\n\/\/ \uc804\uc5ed \ubcc0\uc218:\r\nHINSTANCE hInst;\t\/\/ \ud604\uc7ac \uc778\uc2a4\ud134\uc2a4\uc785\ub2c8\ub2e4.\r\nTCHAR szTitle[MAX_LOADSTRING];\t\/\/ \uc81c\ubaa9 \ud45c\uc2dc\uc904 \ud14d\uc2a4\ud2b8\uc785\ub2c8\ub2e4.\r\nTCHAR szWindowClass[MAX_LOADSTRING];\t\/\/ \uae30\ubcf8 \ucc3d \ud074\ub798\uc2a4 \uc774\ub984\uc785\ub2c8\ub2e4.\r\n\r\n\/\/ \uc774 \ucf54\ub4dc \ubaa8\ub4c8\uc5d0 \ub4e4\uc5b4 \uc788\ub294 \ud568\uc218\uc758 \uc815\ubc29\ud5a5 \uc120\uc5b8\uc785\ub2c8\ub2e4.\r\nATOM\tMyRegisterClass(HINSTANCE hInstance);\r\nBOOL\tInitInstance(HINSTANCE, int);\r\nLRESULT CALLBACK\tWndProc(HWND, UINT, WPARAM, LPARAM);\r\nINT_PTR CALLBACK\tAbout(HWND, UINT, WPARAM, LPARAM);\r\n\r\nint APIENTRY _tWinMain(_In_ HINSTANCE hInstance,\r\n_In_opt_ HINSTANCE hPrevInstance,\r\n_In_ LPTSTR lpCmdLine,\r\n_In_ int nCmdShow)\r\n{\r\nUNREFERENCED_PARAMETER(hPrevInstance);\r\nUNREFERENCED_PARAMETER(lpCmdLine);\r\n\r\n\/\/ TODO: \uc5ec\uae30\uc5d0 \ucf54\ub4dc\ub97c \uc785\ub825\ud569\ub2c8\ub2e4.\r\nMSG msg;\r\nHACCEL hAccelTable;\r\n\r\n\/\/ \uc804\uc5ed \ubb38\uc790\uc5f4\uc744 \ucd08\uae30\ud654\ud569\ub2c8\ub2e4.\r\nLoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);\r\nLoadString(hInstance, IDC_WIN32PROJECT3, szWindowClass, MAX_LOADSTRING);\r\nMyRegisterClass(hInstance);\r\n\r\n\/\/ \uc751\uc6a9 \ud504\ub85c\uadf8\ub7a8 \ucd08\uae30\ud654\ub97c \uc218\ud589\ud569\ub2c8\ub2e4.\r\nif (!InitInstance (hInstance, nCmdShow))\r\n{\r\nreturn FALSE;\r\n}\r\n\r\nhAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WIN32PROJECT3));\r\n\r\n\/\/ \uae30\ubcf8 \uba54\uc2dc\uc9c0 \ub8e8\ud504\uc785\ub2c8\ub2e4.\r\nwhile (GetMessage(&amp;msg, NULL, 0, 0))\r\n{\r\nif (!TranslateAccelerator(msg.hwnd, hAccelTable, &amp;msg))\r\n{\r\nTranslateMessage(&amp;msg);\r\nDispatchMessage(&amp;msg);\r\n}\r\n}\r\n\r\nreturn (int) msg.wParam;\r\n}\r\n\r\n\/\/\r\n\/\/ \ud568\uc218: MyRegisterClass()\r\n\/\/\r\n\/\/ \ubaa9\uc801: \ucc3d \ud074\ub798\uc2a4\ub97c \ub4f1\ub85d\ud569\ub2c8\ub2e4.\r\n\/\/\r\nATOM MyRegisterClass(HINSTANCE hInstance)\r\n{\r\nWNDCLASSEX wcex;\r\n\r\nwcex.cbSize = sizeof(WNDCLASSEX);\r\n\r\nwcex.style\t= CS_HREDRAW | CS_VREDRAW;\r\nwcex.lpfnWndProc\t= WndProc;\r\nwcex.cbClsExtra\t= 0;\r\nwcex.cbWndExtra\t= 0;\r\nwcex.hInstance\t= hInstance;\r\nwcex.hIcon\t= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WIN32PROJECT3));\r\nwcex.hCursor\t= LoadCursor(NULL, IDC_ARROW);\r\nwcex.hbrBackground\t= (HBRUSH)(COLOR_WINDOW+1);\r\nwcex.lpszMenuName\t= MAKEINTRESOURCE(IDC_WIN32PROJECT3);\r\nwcex.lpszClassName\t= szWindowClass;\r\nwcex.hIconSm\t= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));\r\n\r\nreturn RegisterClassEx(&amp;wcex);\r\n}\r\n\r\n\/\/\r\n\/\/ \ud568\uc218: InitInstance(HINSTANCE, int)\r\n\/\/\r\n\/\/ \ubaa9\uc801: \uc778\uc2a4\ud134\uc2a4 \ud578\ub4e4\uc744 \uc800\uc7a5\ud558\uace0 \uc8fc \ucc3d\uc744 \ub9cc\ub4ed\ub2c8\ub2e4.\r\n\/\/\r\n\/\/ \uc124\uba85:\r\n\/\/\r\n\/\/ \uc774 \ud568\uc218\ub97c \ud1b5\ud574 \uc778\uc2a4\ud134\uc2a4 \ud578\ub4e4\uc744 \uc804\uc5ed \ubcc0\uc218\uc5d0 \uc800\uc7a5\ud558\uace0\r\n\/\/ \uc8fc \ud504\ub85c\uadf8\ub7a8 \ucc3d\uc744 \ub9cc\ub4e0 \ub2e4\uc74c \ud45c\uc2dc\ud569\ub2c8\ub2e4.\r\n\/\/\r\nBOOL InitInstance(HINSTANCE hInstance, int nCmdShow)\r\n{\r\nHWND hWnd;\r\n\r\nhInst = hInstance; \/\/ \uc778\uc2a4\ud134\uc2a4 \ud578\ub4e4\uc744 \uc804\uc5ed \ubcc0\uc218\uc5d0 \uc800\uc7a5\ud569\ub2c8\ub2e4.\r\n\r\nhWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,\r\nCW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);\r\n\r\nif (!hWnd)\r\n{\r\nreturn FALSE;\r\n}\r\n\r\nShowWindow(hWnd, nCmdShow);\r\nUpdateWindow(hWnd);\r\n\r\nreturn TRUE;\r\n}\r\n\r\n\/\/\r\n\/\/ \ud568\uc218: WndProc(HWND, UINT, WPARAM, LPARAM)\r\n\/\/\r\n\/\/ \ubaa9\uc801: \uc8fc \ucc3d\uc758 \uba54\uc2dc\uc9c0\ub97c \ucc98\ub9ac\ud569\ub2c8\ub2e4.\r\n\/\/\r\n\/\/ WM_COMMAND\t- \uc751\uc6a9 \ud504\ub85c\uadf8\ub7a8 \uba54\ub274\ub97c \ucc98\ub9ac\ud569\ub2c8\ub2e4.\r\n\/\/ WM_PAINT\t- \uc8fc \ucc3d\uc744 \uadf8\ub9bd\ub2c8\ub2e4.\r\n\/\/ WM_DESTROY\t- \uc885\ub8cc \uba54\uc2dc\uc9c0\ub97c \uac8c\uc2dc\ud558\uace0 \ubc18\ud658\ud569\ub2c8\ub2e4.\r\n\/\/\r\n\/\/\r\nLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\nint wmId, wmEvent;\r\nPAINTSTRUCT ps;\r\nHDC hdc;\r\n\r\nswitch (message)\r\n{\r\ncase WM_COMMAND:\r\nwmId = LOWORD(wParam);\r\nwmEvent = HIWORD(wParam);\r\n\/\/ \uba54\ub274 \uc120\ud0dd\uc744 \uad6c\ubb38 \ubd84\uc11d\ud569\ub2c8\ub2e4.\r\nswitch (wmId)\r\n{\r\ncase IDM_ABOUT:\r\nDialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);\r\nbreak;\r\ncase IDM_EXIT:\r\nDestroyWindow(hWnd);\r\nbreak;\r\ndefault:\r\nreturn DefWindowProc(hWnd, message, wParam, lParam);\r\n}\r\nbreak;\r\ncase WM_PAINT:\r\nhdc = BeginPaint(hWnd, &amp;ps);\r\n\/\/ TODO: \uc5ec\uae30\uc5d0 \uadf8\ub9ac\uae30 \ucf54\ub4dc\ub97c \ucd94\uac00\ud569\ub2c8\ub2e4.\r\nEndPaint(hWnd, &amp;ps);\r\nbreak;\r\ncase WM_DESTROY:\r\nPostQuitMessage(0);\r\nbreak;\r\ndefault:\r\nreturn DefWindowProc(hWnd, message, wParam, lParam);\r\n}\r\nreturn 0;\r\n}\r\n\r\n\/\/ \uc815\ubcf4 \ub300\ud654 \uc0c1\uc790\uc758 \uba54\uc2dc\uc9c0 \ucc98\ub9ac\uae30\uc785\ub2c8\ub2e4.\r\nINT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\nUNREFERENCED_PARAMETER(lParam);\r\nswitch (message)\r\n{\r\ncase WM_INITDIALOG:\r\nreturn (INT_PTR)TRUE;\r\nhttp:\/\/csharp.ihavenomoney.co.kr\/wp-admin\/post.php?post=24&action=edit#\r\ncase WM_COMMAND:\r\nif (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)\r\n{\r\nEndDialog(hDlg, LOWORD(wParam));\r\nreturn (INT_PTR)TRUE;\r\n}\r\nbreak;\r\n}\r\nreturn (INT_PTR)FALSE;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ Win32Project3.cpp : \uc751\uc6a9 \ud504\ub85c\uadf8\ub7a8\uc5d0 \ub300\ud55c \uc9c4\uc785\uc810\uc744 \uc815\uc758\ud569\ub2c8\ub2e4. \/\/ #include &#8220;stdafx.h&#8221; #include &#8220;Win32Project3.h&#8221; #define MAX_LOADSTRING 100 \/\/ \uc804\uc5ed \ubcc0\uc218: HINSTANCE hInst; \/\/ \ud604\uc7ac \uc778\uc2a4\ud134\uc2a4\uc785\ub2c8\ub2e4. TCHAR szTitle[MAX_LOADSTRING]; \/\/ \uc81c\ubaa9 \ud45c\uc2dc\uc904 \ud14d\uc2a4\ud2b8\uc785\ub2c8\ub2e4. TCHAR szWindowClass[MAX_LOADSTRING]; \/\/ \uae30\ubcf8 \ucc3d \ud074\ub798\uc2a4 \uc774\ub984\uc785\ub2c8\ub2e4. \/\/ \uc774 \ucf54\ub4dc \ubaa8\ub4c8\uc5d0 \ub4e4\uc5b4 \uc788\ub294 \ud568\uc218\uc758 \uc815\ubc29\ud5a5 \uc120\uc5b8\uc785\ub2c8\ub2e4. ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND,\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=24\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-24","post","type-post","status-publish","format-standard","hentry","category-win32-api"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/24","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=24"}],"version-history":[{"count":5,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/24\/revisions"}],"predecessor-version":[{"id":458,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/24\/revisions\/458"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}