bool Alert::IsLinkButton(HWND button_handle) { std::vector<wchar_t> button_window_class(100); ::GetClassName(button_handle, &button_window_class[0], static_cast<int>(button_window_class.size())); if (wcscmp(&button_window_class[0], L"Button") == 0) { long window_long = ::GetWindowLong(button_handle, GWL_STYLE); long button_style = window_long & BS_TYPEMASK; return button_style == BS_COMMANDLINK; } return false; }
bool Alert::IsOKButton(HWND button_handle) { int control_id = ::GetDlgCtrlID(button_handle); if (control_id != 0) { return control_id == IDOK || control_id == IDYES || control_id == IDRETRY; } std::vector<wchar_t> button_window_class(100); ::GetClassName(button_handle, &button_window_class[0], static_cast<int>(button_window_class.size())); if (wcscmp(&button_window_class[0], L"Button") == 0) { long window_long = ::GetWindowLong(button_handle, GWL_STYLE); return (window_long & BS_DEFCOMMANDLINK) == BS_DEFCOMMANDLINK; } return false; }
bool Alert::IsCancelButton(HWND button_handle) { int control_id = ::GetDlgCtrlID(button_handle); if (control_id != 0) { return control_id == IDCANCEL || control_id == IDNO; } std::vector<wchar_t> button_window_class(100); ::GetClassName(button_handle, &button_window_class[0], static_cast<int>(button_window_class.size())); if (wcscmp(&button_window_class[0], L"Button") == 0) { long window_long = ::GetWindowLong(button_handle, GWL_STYLE); // The BS_DEFCOMMANDLINK mask includes BS_COMMANDLINK, but we // want only to match those without the default bits set. return (window_long & BS_DEFCOMMANDLINK) == BS_COMMANDLINK; } return false; }