]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "msgdlg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/dialog.h"
28 #include "wx/msgdlg.h"
31 #include "wx/msw/private.h"
33 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
35 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
36 const wxString
& message
,
37 const wxString
& caption
,
39 const wxPoint
& WXUNUSED(pos
))
43 m_dialogStyle
= style
;
47 int wxMessageDialog::ShowModal()
49 if ( !wxTheApp
->GetTopWindow() )
51 // when the message box is shown from wxApp::OnInit() (i.e. before the
52 // message loop is entered), this must be done or the next message box
53 // will never be shown - just try putting 2 calls to wxMessageBox() in
55 while ( wxTheApp
->Pending() )
59 // use the top level window as parent if none specified
61 m_parent
= FindSuitableParent();
62 HWND hWnd
= m_parent
? GetHwndOf(m_parent
) : NULL
;
64 // translate wx style in MSW
65 unsigned int msStyle
= MB_OK
;
66 if (m_dialogStyle
& wxYES_NO
)
68 if (m_dialogStyle
& wxCANCEL
)
69 msStyle
= MB_YESNOCANCEL
;
73 if (m_dialogStyle
& wxNO_DEFAULT
)
74 msStyle
|= MB_DEFBUTTON2
;
77 if (m_dialogStyle
& wxOK
)
79 if (m_dialogStyle
& wxCANCEL
)
80 msStyle
= MB_OKCANCEL
;
84 if (m_dialogStyle
& wxICON_EXCLAMATION
)
85 msStyle
|= MB_ICONEXCLAMATION
;
86 else if (m_dialogStyle
& wxICON_HAND
)
87 msStyle
|= MB_ICONHAND
;
88 else if (m_dialogStyle
& wxICON_INFORMATION
)
89 msStyle
|= MB_ICONINFORMATION
;
90 else if (m_dialogStyle
& wxICON_QUESTION
)
91 msStyle
|= MB_ICONQUESTION
;
93 if ( m_dialogStyle
& wxSTAY_ON_TOP
)
94 msStyle
|= MB_TOPMOST
;
97 msStyle
|= MB_APPLMODAL
;
99 msStyle
|= MB_TASKMODAL
;
101 // do show the dialog
102 int msAns
= MessageBox(hWnd
, m_message
.c_str(), m_caption
.c_str(), msStyle
);
107 wxFAIL_MSG(_T("unexpected ::MessageBox() return code"));