]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
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_lDialogStyle
= lStyle
;
50 m_pParent
= NULL
; // pParent;
51 } // end of wxMessageDialog::wxMessageDialog
53 int wxMessageDialog::ShowModal()
56 ULONG ulStyle
= MB_OK
;
59 if (!wxTheApp
->GetTopWindow())
62 // when the message box is shown from wxApp::OnInit() (i.e. before the
63 // message loop is entered), this must be done or the next message box
64 // will never be shown - just try putting 2 calls to wxMessageBox() in
67 while (wxTheApp
->Pending())
72 hWnd
= (HWND
) m_pParent
->GetHWND();
75 if (m_lDialogStyle
& wxYES_NO
)
77 if (m_lDialogStyle
& wxCANCEL
)
78 ulStyle
= MB_YESNOCANCEL
;
82 if (m_lDialogStyle
& wxNO_DEFAULT
)
83 ulStyle
|= MB_DEFBUTTON2
;
86 if (m_lDialogStyle
& wxOK
)
88 if (m_lDialogStyle
& wxCANCEL
)
89 ulStyle
= MB_OKCANCEL
;
93 if (m_lDialogStyle
& wxICON_EXCLAMATION
)
94 ulStyle
|= MB_ICONEXCLAMATION
;
95 else if (m_lDialogStyle
& wxICON_HAND
)
96 ulStyle
|= MB_ICONHAND
;
97 else if (m_lDialogStyle
& wxICON_INFORMATION
)
98 ulStyle
|= MB_ICONEXCLAMATION
;
99 else if (m_lDialogStyle
& wxICON_QUESTION
)
100 ulStyle
|= MB_ICONQUESTION
;
102 if (hWnd
!= HWND_DESKTOP
)
103 ulStyle
|= MB_APPLMODAL
;
105 ulStyle
|= MB_SYSTEMMODAL
;
108 // This little line of code is get message boxes under OS/2 to
109 // behve like the other ports. In OS/2 if the parent is a window
110 // it displays, clipped, in the window. This centers it on the
111 // desktop, like the other ports but still allows control over modality
115 ULONG ulAns
= ::WinMessageBox( hWnd
117 ,(PSZ
)m_sMessage
.c_str()
118 ,(PSZ
)m_sCaption
.c_str()
139 } // end of wxMessageDialog::ShowModal