From 18d014e3ed78e09a4c538d889073bf7e307ac275 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sat, 15 Apr 2000 10:25:08 +0000 Subject: [PATCH] Added WinMessageBox() code, mainly from the Windows version. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7173 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/msgdlg.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/os2/msgdlg.cpp b/src/os2/msgdlg.cpp index e1cf166e2a..72a71bbece 100644 --- a/src/os2/msgdlg.cpp +++ b/src/os2/msgdlg.cpp @@ -46,7 +46,58 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, cons int wxMessageDialog::ShowModal() { - // TODO - return wxID_CANCEL; + HWND hWnd = 0; + if (m_parent) hWnd = (HWND) m_parent->GetHWND(); + unsigned int msStyle = MB_OK; + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + msStyle = MB_YESNOCANCEL; + else + msStyle = MB_YESNO; + + if (m_dialogStyle & wxNO_DEFAULT) + msStyle |= MB_DEFBUTTON2; + } + + if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + msStyle = MB_OKCANCEL; + else + msStyle = MB_OK; + } + if (m_dialogStyle & wxICON_EXCLAMATION) + msStyle |= MB_ICONEXCLAMATION; + else if (m_dialogStyle & wxICON_HAND) + msStyle |= MB_ICONHAND; + else if (m_dialogStyle & wxICON_INFORMATION) + msStyle |= MB_INFORMATION; + else if (m_dialogStyle & wxICON_QUESTION) + msStyle |= MB_ICONQUESTION; + + if (hWnd) + msStyle |= MB_APPLMODAL; + else + msStyle |= MB_SYSTEMMODAL; + + int msAns = WinMessageBox(HWND_DESKTOP, hWnd, m_message.c_str(), m_caption.c_str(), 0, msStyle | MB_MOVEABLE); + int ans = wxOK; + switch (msAns) + { + case MBID_CANCEL: + ans = wxID_CANCEL; + break; + case MBID_OK: + ans = wxID_OK; + break; + case MBID_YES: + ans = wxID_YES; + break; + case MBID_NO: + ans = wxID_NO; + break; + } + return ans; }