+ template <typename WPARAM_T, typename LPARAM_T>\r
+ void commandNotify(HWND i_hwnd, UINT i_message, WPARAM_T i_wParam,\r
+ LPARAM_T i_lParam)\r
+ {\r
+ Acquire b(&m_log, 0);\r
+ HWND hf = m_hwndFocus;\r
+ if (!hf)\r
+ return;\r
+\r
+ if (GetWindowThreadProcessId(hf, NULL) ==\r
+ GetWindowThreadProcessId(m_hwndAssocWindow, NULL))\r
+ return; // inhibit the investigation of MADO TSUKAI NO YUUTSU\r
+\r
+ const _TCHAR *target = NULL;\r
+ int number_target = 0;\r
+\r
+ if (i_hwnd == hf)\r
+ target = _T("ToItself");\r
+ else if (i_hwnd == GetParent(hf))\r
+ target = _T("ToParentWindow");\r
+ else {\r
+ // Function::toMainWindow\r
+ HWND h = hf;\r
+ while (true) {\r
+ HWND p = GetParent(h);\r
+ if (!p)\r
+ break;\r
+ h = p;\r
+ }\r
+ if (i_hwnd == h)\r
+ target = _T("ToMainWindow");\r
+ else {\r
+ // Function::toOverlappedWindow\r
+ HWND h = hf;\r
+ while (h) {\r
+#ifdef MAYU64\r
+ LONG_PTR style = GetWindowLongPtr(h, GWL_STYLE);\r
+#else\r
+ LONG style = GetWindowLong(h, GWL_STYLE);\r
+#endif\r
+ if ((style & WS_CHILD) == 0)\r
+ break;\r
+ h = GetParent(h);\r
+ }\r
+ if (i_hwnd == h)\r
+ target = _T("ToOverlappedWindow");\r
+ else {\r
+ // number\r
+ HWND h = hf;\r
+ for (number_target = 0; h; number_target ++, h = GetParent(h))\r
+ if (i_hwnd == h)\r
+ break;\r
+ return;\r
+ }\r
+ }\r
+ }\r
+\r
+ m_log << _T("&PostMessage(");\r
+ if (target)\r
+ m_log << target;\r
+ else\r
+ m_log << number_target;\r
+ m_log << _T(", ") << i_message\r
+ << _T(", 0x") << std::hex << i_wParam\r
+ << _T(", 0x") << i_lParam << _T(") # hwnd = ")\r
+ << reinterpret_cast<int>(i_hwnd) << _T(", ")\r
+ << _T("message = ") << std::dec;\r
+ if (i_message == WM_COMMAND)\r
+ m_log << _T("WM_COMMAND, ");\r
+ else if (i_message == WM_SYSCOMMAND)\r
+ m_log << _T("WM_SYSCOMMAND, ");\r
+ else\r
+ m_log << i_message << _T(", ");\r
+ m_log << _T("wNotifyCode = ") << HIWORD(i_wParam) << _T(", ")\r
+ << _T("wID = ") << LOWORD(i_wParam) << _T(", ")\r
+ << _T("hwndCtrl = 0x") << std::hex << i_lParam << std::dec << std::endl;\r
+ }\r