{"id":270,"date":"2014-05-04T11:30:13","date_gmt":"2014-05-04T02:30:13","guid":{"rendered":"https:\/\/prg.waou.biz\/?p=270"},"modified":"2018-03-03T08:39:43","modified_gmt":"2018-03-02T23:39:43","slug":"%e8%b5%b7%e5%8b%95%e4%b8%ad%e3%81%ae%e3%82%a6%e3%82%a3%e3%83%b3%e3%83%89%e3%82%a6%e3%82%92%e5%88%97%e6%8c%99","status":"publish","type":"post","link":"https:\/\/prg.waou.biz\/?p=270","title":{"rendered":"\u8d77\u52d5\u4e2d\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u5217\u6319"},"content":{"rendered":"\n<pre class=\"lang:default decode:true \" >\/\/ EnumWindows().cpp :\r\n\r\n\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30a8\u30f3\u30c8\u30ea \u30dd\u30a4\u30f3\u30c8\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\r\n\/\/\r\n\r\n#include \"stdafx.h\"\r\n#include \"EnumWindows().h\"\r\n\r\n#define MAX_LOADSTRING 100\r\n\r\n\/\/ \u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570:\r\nHINSTANCE hInst; \/\/ \u73fe\u5728\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\r\nTCHAR szTitle[MAX_LOADSTRING]; \/\/ \u30bf\u30a4\u30c8\u30eb \u30d0\u30fc\u306e\u30c6\u30ad\u30b9\u30c8\r\nTCHAR szWindowClass[MAX_LOADSTRING]; \/\/ \u30e1\u30a4\u30f3 \u30a6\u30a3\u30f3\u30c9\u30a6 \u30af\u30e9\u30b9\u540d\r\n\r\n\/\/ \u3053\u306e\u30b3\u30fc\u30c9 \u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u542b\u307e\u308c\u308b\u95a2\u6570\u306e\u5ba3\u8a00\u3092\u8ee2\u9001\u3057\u307e\u3059:\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(HINSTANCE hInstance,\r\nHINSTANCE hPrevInstance,\r\nLPTSTR lpCmdLine,\r\nint nCmdShow)\r\n{\r\nUNREFERENCED_PARAMETER(hPrevInstance);\r\nUNREFERENCED_PARAMETER(lpCmdLine);\r\n\r\n\/\/ TODO: \u3053\u3053\u306b\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\nMSG msg;\r\nHACCEL hAccelTable;\r\n\r\n\/\/ \u30b0\u30ed\u30fc\u30d0\u30eb\u6587\u5b57\u5217\u3092\u521d\u671f\u5316\u3057\u3066\u3044\u307e\u3059\u3002\r\nLoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);\r\nLoadString(hInstance, IDC_ENUMWINDOWS, szWindowClass, MAX_LOADSTRING);\r\nMyRegisterClass(hInstance);\r\n\r\n\/\/ \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u521d\u671f\u5316\u3092\u5b9f\u884c\u3057\u307e\u3059:\r\nif (!InitInstance (hInstance, nCmdShow))\r\n{\r\nreturn FALSE;\r\n}\r\n\r\nhAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_ENUMWINDOWS));\r\n\r\n\/\/ \u30e1\u30a4\u30f3 \u30e1\u30c3\u30bb\u30fc\u30b8 \u30eb\u30fc\u30d7:\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\nBOOL CALLBACK EnumWindowsProc(HWND hwnd , LPARAM lp) {\r\nTCHAR strWindowText[1024];\r\nGetWindowText(hwnd , strWindowText , 1024);\r\nif (strWindowText[0] == 0) return TRUE;\r\n\r\nSendMessage((HWND)lp , LB_ADDSTRING , 0 , (long)strWindowText);\r\nreturn TRUE;\r\n}\r\n\r\n\/\/\r\n\/\/ \u95a2\u6570: MyRegisterClass()\r\n\/\/\r\n\/\/ \u76ee\u7684: \u30a6\u30a3\u30f3\u30c9\u30a6 \u30af\u30e9\u30b9\u3092\u767b\u9332\u3057\u307e\u3059\u3002\r\n\/\/\r\n\/\/ \u30b3\u30e1\u30f3\u30c8:\r\n\/\/\r\n\/\/ \u3053\u306e\u95a2\u6570\u304a\u3088\u3073\u4f7f\u3044\u65b9\u306f\u3001'RegisterClassEx' \u95a2\u6570\u304c\u8ffd\u52a0\u3055\u308c\u305f\r\n\/\/ Windows 95 \u3088\u308a\u524d\u306e Win32 \u30b7\u30b9\u30c6\u30e0\u3068\u4e92\u63db\u3055\u305b\u308b\u5834\u5408\u306b\u306e\u307f\u5fc5\u8981\u3067\u3059\u3002\r\n\/\/ \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u3001\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\r\n\/\/ \u6b63\u3057\u3044\u5f62\u5f0f\u306e\u5c0f\u3055\u3044\u30a2\u30a4\u30b3\u30f3\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u3001\r\n\/\/ \u3053\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002\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_ENUMWINDOWS));\r\nwcex.hCursor = LoadCursor(NULL, IDC_ARROW);\r\nwcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);\r\nwcex.lpszMenuName = MAKEINTRESOURCE(IDC_ENUMWINDOWS);\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\/\/ \u95a2\u6570: InitInstance(HINSTANCE, int)\r\n\/\/\r\n\/\/ \u76ee\u7684: \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 \u30cf\u30f3\u30c9\u30eb\u3092\u4fdd\u5b58\u3057\u3066\u3001\u30e1\u30a4\u30f3 \u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\r\n\/\/\r\n\/\/ \u30b3\u30e1\u30f3\u30c8:\r\n\/\/\r\n\/\/ \u3053\u306e\u95a2\u6570\u3067\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 \u30cf\u30f3\u30c9\u30eb\u3092\u4fdd\u5b58\u3057\u3001\r\n\/\/ \u30e1\u30a4\u30f3 \u30d7\u30ed\u30b0\u30e9\u30e0 \u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u4f5c\u6210\u304a\u3088\u3073\u8868\u793a\u3057\u307e\u3059\u3002\r\n\/\/\r\nBOOL InitInstance(HINSTANCE hInstance, int nCmdShow)\r\n{\r\nHWND hWnd;\r\n\r\nhInst = hInstance; \/\/ \u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u51e6\u7406\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002\r\n\r\nhWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,\r\n600, 0, 800, 900, 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\/\/ \u95a2\u6570: WndProc(HWND, UINT, WPARAM, LPARAM)\r\n\/\/\r\n\/\/ \u76ee\u7684: \u30e1\u30a4\u30f3 \u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51e6\u7406\u3057\u307e\u3059\u3002\r\n\/\/\r\n\/\/ WM_COMMAND - \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 \u30e1\u30cb\u30e5\u30fc\u306e\u51e6\u7406\r\n\/\/ WM_PAINT - \u30e1\u30a4\u30f3 \u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u63cf\u753b\r\n\/\/ WM_DESTROY - \u4e2d\u6b62\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u3066\u623b\u308b\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\nstatic HWND hList;\r\n\r\nswitch (message)\r\n{\r\ncase WM_CREATE:\r\nhList = CreateWindow(\r\nTEXT(\"LISTBOX\") , NULL ,\r\nWS_CHILD | WS_VISIBLE | LBS_STANDARD ,\r\n0 , 0 , 400 ,600 , hWnd , (HMENU)1 ,\r\n((LPCREATESTRUCT)(lParam))-&gt;hInstance , NULL\r\n);\r\nEnumWindows(EnumWindowsProc , (LPARAM)hList);\r\n\r\ncase WM_COMMAND:\r\nwmId = LOWORD(wParam);\r\nwmEvent = HIWORD(wParam);\r\n\/\/ \u9078\u629e\u3055\u308c\u305f\u30e1\u30cb\u30e5\u30fc\u306e\u89e3\u6790:\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: \u63cf\u753b\u30b3\u30fc\u30c9\u3092\u3053\u3053\u306b\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044...\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\/\/ \u30d0\u30fc\u30b8\u30e7\u30f3\u60c5\u5831\u30dc\u30c3\u30af\u30b9\u306e\u30e1\u30c3\u30bb\u30fc\u30b8 \u30cf\u30f3\u30c9\u30e9\u30fc\u3067\u3059\u3002\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<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ EnumWindows().cpp : \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30a8\u30f3\u30c8\u30ea \u30dd\u30a4\u30f3\u30c8\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002 \/\/ #include &#8220;stdafx.h&#8221; #include &#8220;EnumWindows().h&#8221; #define MAX [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_lightning_design_setting":[],"footnotes":""},"categories":[17],"tags":[],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-windowsapi"],"_links":{"self":[{"href":"https:\/\/prg.waou.biz\/index.php?rest_route=\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prg.waou.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prg.waou.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prg.waou.biz\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/prg.waou.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=270"}],"version-history":[{"count":5,"href":"https:\/\/prg.waou.biz\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":829,"href":"https:\/\/prg.waou.biz\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions\/829"}],"wp:attachment":[{"href":"https:\/\/prg.waou.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prg.waou.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prg.waou.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}