{"id":34,"date":"2013-11-18T00:45:25","date_gmt":"2013-11-17T15:45:25","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=34"},"modified":"2019-06-27T10:25:15","modified_gmt":"2019-06-27T01:25:15","slug":"34","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=34","title":{"rendered":"Edit Program basic"},"content":{"rendered":"<p><a href=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2013\/11\/EditWnd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-35\" alt=\"EditWnd\" src=\"http:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2013\/11\/EditWnd-300x221.png\" width=\"300\" height=\"221\" srcset=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2013\/11\/EditWnd-300x221.png 300w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2013\/11\/EditWnd.png 374w\" 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 \u201cstdafx.h\u201d\r\n#include \u201cWin32Project3.h\u201d\r\n\r\n#define MAX_LOADSTRING 100\r\n\r\n\/\/ \uc804\uc5ed \ubcc0\uc218:\r\nHINSTANCE hInst; \/\/ \ud604\uc7ac \uc778\uc2a4\ud134\uc2a4\uc785\ub2c8\ub2e4.\r\nHWND hEditWnd; \/\/Edit \ud578\ub4e4\r\n\r\nTCHAR szTitle[MAX_LOADSTRING]; \/\/ \uc81c\ubaa9 \ud45c\uc2dc\uc904 \ud14d\uc2a4\ud2b8\uc785\ub2c8\ub2e4.\r\nTCHAR szWindowClass[MAX_LOADSTRING]; \/\/ \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 MyRegisterClass(HINSTANCE hInstance);\r\nBOOL InitInstance(HINSTANCE, int);\r\nLRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);\r\nINT_PTR CALLBACK About(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 = CS_HREDRAW | CS_VREDRAW;\r\nwcex.lpfnWndProc = WndProc;\r\nwcex.cbClsExtra = 0;\r\nwcex.cbWndExtra = 0;\r\nwcex.hInstance = hInstance;\r\nwcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WIN32PROJECT3));\r\nwcex.hCursor = LoadCursor(NULL, IDC_ARROW);\r\nwcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);\r\nwcex.lpszMenuName = MAKEINTRESOURCE(IDC_WIN32PROJECT3);\r\nwcex.lpszClassName = szWindowClass;\r\nwcex.hIconSm = 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 \u2013 \uc751\uc6a9 \ud504\ub85c\uadf8\ub7a8 \uba54\ub274\ub97c \ucc98\ub9ac\ud569\ub2c8\ub2e4.\r\n\/\/ WM_PAINT \u2013 \uc8fc \ucc3d\uc744 \uadf8\ub9bd\ub2c8\ub2e4.\r\n\/\/ WM_DESTROY \u2013 \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\nBOOL fSystemMenu = (BOOL)HIWORD(lParam);\r\nUINT uPos = (UINT)LOWORD(lParam);\r\nHMENU hmenuPopup = (HMENU) wParam;\r\n\r\nswitch (message)\r\n{\r\ncase WM_CREATE:\r\n\r\nRECT Rect;\r\nGetClientRect(hWnd, (LPRECT)&amp;Rect);\r\nhEditWnd = CreateWindow(TEXT(\u201cEdit\u201d), NULL, WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | WS_HSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL\r\n, 0, 0, (Rect.right \u2013 Rect.left), (Rect.bottom \u2013 Rect.top), hWnd, NULL, hInst, NULL);\r\n\r\nif (!hEditWnd)\r\n{\r\nDestroyWindow(hWnd);\r\nreturn -1;\r\n}\r\nbreak;\r\n\r\ncase WM_INITMENUPOPUP:\r\n\r\nif (fSystemMenu)\r\nbreak;\r\nif (uPos == 1)\r\n{\r\nBOOL bClip = FALSE, bSel = FALSE;\r\nDWORD dwSel;\r\n\r\nif (SendMessage(hEditWnd, EM_CANUNDO, 0, 0))\r\nEnableMenuItem(hmenuPopup, ID_UNDO, MF_BYCOMMAND | MF_ENABLED);\r\nelse\r\nEnableMenuItem(hmenuPopup, ID_UNDO, MF_BYCOMMAND | MF_GRAYED);\r\n\r\nif (OpenClipboard(hWnd))\r\n{\r\nHANDLE hClipData;\r\nhClipData = GetClipboardData(CF_TEXT);\r\nif (hClipData)\r\n{\r\nbClip = TRUE;\r\nCloseClipboard();\r\n}\r\nelse\r\nbClip = FALSE;\r\n}\r\nEnableMenuItem(hmenuPopup, ID_PASTE, MF_BYCOMMAND | (bClip) ? MF_ENABLED : MF_GRAYED);\r\ndwSel = SendMessage(hEditWnd, EM_GETSEL, NULL, NULL);\r\nbSel = (LOWORD(dwSel) != HIWORD(dwSel));\r\nEnableMenuItem(hmenuPopup, ID_COPY, MF_BYCOMMAND | (bSel) ? MF_ENABLED : MF_GRAYED);\r\nEnableMenuItem(hmenuPopup, ID_CUT, MF_BYCOMMAND | (bSel) ? MF_ENABLED : MF_GRAYED);\r\nEnableMenuItem(hmenuPopup, ID_DELETE, MF_BYCOMMAND | (bSel) ? MF_ENABLED : MF_GRAYED);\r\n\r\n}\r\nbreak;\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 ID_NEW:\r\nbreak;\r\ncase ID_OPEN:\r\nbreak;\r\ncase ID_SAVE:\r\nbreak;\r\ncase ID_SAVEAS:\r\nbreak;\r\ncase ID_PRINT:\r\nMessageBox(hWnd, TEXT(\u201c\uba85\ub839\uc774 \uad6c\ud604 \uc548\ub428\u201d), TEXT(\u201cEditor Sample\u201d), MB_ICONASTERISK | MB_OK);\r\nbreak;\r\ncase ID_UNDO:\r\nSendMessage(hEditWnd, WM_UNDO, 0, 0);\r\nbreak;\r\ncase ID_CUT:\r\nSendMessage(hEditWnd, WM_CUT, 0, 0);\r\nbreak;\r\ncase ID_COPY:\r\nSendMessage(hEditWnd, WM_COPY, 0, 0);\r\nbreak;\r\ncase ID_PASTE:\r\nSendMessage(hEditWnd, WM_PASTE, 0, 0);\r\nbreak;\r\ncase ID_DELETE:\r\nSendMessage(hEditWnd, WM_CLEAR, 0, 0);\r\nbreak;\r\ncase IDC_WIN32PROJECT3:\r\nif (HIWORD(wParam) == EN_ERRSPACE)\r\nMessageBox(hWnd, TEXT(\u201c\uba54\ubaa8\ub9ac \ubd80\uc871\u201d), TEXT(\u201cEditor Sample\u201d), MB_ICONHAND | MB_OK);\r\nbreak;\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_SETFOCUS:\r\nSetFocus(hEditWnd);\r\nbreak;\r\ncase WM_SIZE:\r\nMoveWindow(hEditWnd, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);\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\n\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 \u201cstdafx.h\u201d #include \u201cWin32Project3.h\u201d #define MAX_LOADSTRING 100 \/\/ \uc804\uc5ed \ubcc0\uc218: HINSTANCE hInst; \/\/ \ud604\uc7ac \uc778\uc2a4\ud134\uc2a4\uc785\ub2c8\ub2e4. HWND hEditWnd; \/\/Edit \ud578\ub4e4 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,\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=34\">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-34","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\/34","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=34"}],"version-history":[{"count":6,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":529,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions\/529"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}