{"id":142,"date":"2000-05-04T00:00:00","date_gmt":"2000-05-03T15:00:00","guid":{"rendered":"http:\/\/localhost\/blog\/?p=131"},"modified":"2014-08-14T15:58:43","modified_gmt":"2014-08-14T06:58:43","slug":"ime%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/denasu.com\/blog\/2000\/05\/diary142","title":{"rendered":"IME\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"<p>IME \u306e\u4f7f\u7528\u3002<\/p>\n<pre class=\"brush:cpp\">\r\nvoid CXXXView::OnImeStartComposition(WPARAM wParam, LPARAM lParam)\r\n{\r\n    COMPOSITIONFORM cpf;\r\n    HIMC hIMC;\r\n\r\n    \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u30cf\u30f3\u30c9\u30eb\u3092\u53d6\u5f97\r\n    HWND hWnd = GetSafeHwnd();\r\n    if(!hWnd)\r\n    {\r\n        return;\r\n    }\r\n\r\n    \/\/ IME \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u5f97\u308b\r\n    hIMC = ::ImmGetContext(hWnd);\r\n    if(!hIMC)\r\n    {\r\n        return;\r\n    }\r\n\r\n    \/\/ CompositionWinow\r\n    cpf.dwStyle = CFS_POINT;\r\n    cpf.ptCurrentPos.x = GetCaretPos().x;\r\n    cpf.ptCurrentPos.y = GetCaretPos().y;\r\n\r\n    \/\/ \u30d5\u30a9\u30f3\u30c8\r\n    LOGFONT logFont;\r\n    m_font.GetLogFont(&amp;logFont);\r\n\r\n    ::ImmSetCompositionFont(hIMC, &amp;logFont);\r\n    ::ImmSetCompositionWindow(hIMC, &amp;cpf);\r\n\r\n    \/\/ IME \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u89e3\u653e\r\n    ::ImmReleaseContext(hWnd, hIMC);\r\n\r\n    \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\r\n    DefWindowProc(WM_IME_STARTCOMPOSITION, wParam, lParam);\r\n}\r\n\r\nvoid CXXXView::OnImeChar(WPARAM wParam, LPARAM lParam)\r\n{\r\n    \/\/ \u4f55\u3082\u3057\u306a\u3044\r\n}\r\n\r\nvoid CXXXView::OnImeComposition(WPARAM wParam, LPARAM lParam)\r\n{\r\n    if(lParam &amp; GCS_RESULTSTR)\r\n    {\r\n        COMPOSITIONFORM cpf;\r\n        HIMC hIMC;\r\n\r\n        \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u30cf\u30f3\u30c9\u30eb\u3092\u53d6\u5f97\r\n        HWND hWnd = GetSafeHwnd();\r\n        if(!hWnd)\r\n        {\r\n            return;\r\n        }\r\n\r\n        \/\/ IME \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u5f97\u308b\r\n        hIMC = ::ImmGetContext(hWnd);\r\n        if(!hIMC)\r\n        {\r\n            return;\r\n        }\r\n\r\n        \/\/ \u6587\u5b57\u5217\u306e\u53d6\u5f97\r\n        int nSize = ::ImmGetCompositionString(hIMC, GCS_RESULTSTR, NULL, 0);\r\n        char *buf = new char[nSize + 1];\r\n        ::ImmGetCompositionString(hIMC, GCS_RESULTSTR, buf, nSize);\r\n        buf[nSize] = '';\r\n\r\n        \/\/ IME \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u89e3\u653e\r\n        ::ImmReleaseContext(hWnd, hIMC);\r\n\r\n        \/\/ \u5165\u529b\r\n        Input(buf);\r\n        delete [] buf;\r\n\r\n        \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u79fb\u52d5\r\n        cpf.dwStyle = CFS_POINT;\r\n        cpf.ptCurrentPos.x = GetCaretPos().x;\r\n        cpf.ptCurrentPos.y = GetCaretPos().y;\r\n\r\n        ::ImmSetCompositionWindow(hIMC, &amp;cpf);\r\n    }\r\n\r\n    \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\r\n    DefWindowProc(WM_IME_COMPOSITION, wParam, lParam);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>IME \u306e\u4f7f\u7528\u3002 void CXXXView::OnImeStartComposition(WPARAM wParam, LPARAM lParam) { COMPOSITIONFORM cpf; HIMC hIMC; \/\/ \u30a6\u30a3\u30f3\u30c9\u30a6\u30cf\u30f3\u30c9\u30eb\u3092\u53d6\u5f97 HWND hWnd = GetSafeHwnd(); if(!hWnd) { return; } \/\/ IME \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u5f97\u308b hIMC = ::ImmGetContext(hWnd); if(!hIMC) { return; } \/\/ CompositionWinow cpf.dwStyle = CFS_POINT; cpf.ptCurrentPos.x = GetCaretPos().x; cpf.ptCurrentPos.y = GetCaretPos().y; \/\/ \u30d5\u30a9\u30f3\u30c8 LOGFONT logFont; m_font.GetLogFont(&amp;logFont); ::ImmSetCompositionFont(hIMC, &amp;logFont); ::ImmSetCompositionWindow(hIMC, &amp;cpf); \/\/ IME \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u89e3\u653e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[22],"class_list":["post-142","post","type-post","status-publish","format-standard","hentry","category-programming","tag-win32"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4ZThs-2i","_links":{"self":[{"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/posts\/142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/comments?post=142"}],"version-history":[{"count":2,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/posts\/142\/revisions"}],"predecessor-version":[{"id":2514,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/posts\/142\/revisions\/2514"}],"wp:attachment":[{"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/media?parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/categories?post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/denasu.com\/blog\/wp-json\/wp\/v2\/tags?post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}