]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/msgdlg.cpp
3 // Purpose: wxMessageDialog
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "msgdlg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
23 #include "wx/dialog.h"
25 #include "wx/msgdlg.h"
29 #include "wx/os2/private.h"
34 #define wxDIALOG_DEFAULT_X 300
35 #define wxDIALOG_DEFAULT_Y 300
37 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
39 wxMessageDialog::wxMessageDialog(
41 , const wxString
& rsMessage
42 , const wxString
& rsCaption
47 m_sCaption
= rsCaption
;
48 m_sMessage
= rsMessage
;
49 m_pParent
= NULL
; // pParent;
50 SetMessageDialogStyle(lStyle
);
51 } // end of wxMessageDialog::wxMessageDialog
53 int wxMessageDialog::ShowModal()
56 ULONG ulStyle
= MB_OK
;
58 const long lStyle
= GetMessageDialogStyle();
60 if (!wxTheApp
->GetTopWindow())
63 // when the message box is shown from wxApp::OnInit() (i.e. before the
64 // message loop is entered), this must be done or the next message box
65 // will never be shown - just try putting 2 calls to wxMessageBox() in
68 while (wxTheApp
->Pending())
73 hWnd
= (HWND
) m_pParent
->GetHWND();
76 if (lStyle
& wxYES_NO
)
78 if (lStyle
& wxCANCEL
)
79 ulStyle
= MB_YESNOCANCEL
;
83 if (lStyle
& wxNO_DEFAULT
)
84 ulStyle
|= MB_DEFBUTTON2
;
89 if (lStyle
& wxCANCEL
)
90 ulStyle
= MB_OKCANCEL
;
94 if (lStyle
& wxICON_EXCLAMATION
)
95 ulStyle
|= MB_ICONEXCLAMATION
;
96 else if (lStyle
& wxICON_HAND
)
97 ulStyle
|= MB_ICONHAND
;
98 else if (lStyle
& wxICON_INFORMATION
)
99 ulStyle
|= MB_ICONEXCLAMATION
;
100 else if (lStyle
& wxICON_QUESTION
)
101 ulStyle
|= MB_ICONQUESTION
;
103 if (hWnd
!= HWND_DESKTOP
)
104 ulStyle
|= MB_APPLMODAL
;
106 ulStyle
|= MB_SYSTEMMODAL
;
109 // This little line of code is get message boxes under OS/2 to
110 // behve like the other ports. In OS/2 if the parent is a window
111 // it displays, clipped, in the window. This centers it on the
112 // desktop, like the other ports but still allows control over modality
116 ULONG ulAns
= ::WinMessageBox( hWnd
118 ,(PSZ
)m_sMessage
.c_str()
119 ,(PSZ
)m_sCaption
.c_str()
140 } // end of wxMessageDialog::ShowModal