]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/msgdlg.cpp
3 // Purpose: wxMessageDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/msgdlg.h"
24 #include "wx/dialog.h"
27 #include "wx/msw/private.h"
31 #include "wx/msw/wince/missing.h"
34 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
36 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
37 const wxString
& message
,
38 const wxString
& caption
,
40 const wxPoint
& WXUNUSED(pos
))
45 SetMessageDialogStyle(style
);
48 int wxMessageDialog::ShowModal()
50 if ( !wxTheApp
->GetTopWindow() )
52 // when the message box is shown from wxApp::OnInit() (i.e. before the
53 // message loop is entered), this must be done or the next message box
54 // will never be shown - just try putting 2 calls to wxMessageBox() in
56 while ( wxTheApp
->Pending() )
60 // use the top level window as parent if none specified
62 m_parent
= FindSuitableParent();
63 HWND hWnd
= m_parent
? GetHwndOf(m_parent
) : NULL
;
65 // translate wx style in MSW
66 unsigned int msStyle
= MB_OK
;
67 const long wxStyle
= GetMessageDialogStyle();
68 if (wxStyle
& wxYES_NO
)
70 #if !(defined(__SMARTPHONE__) && defined(__WXWINCE__))
71 if (wxStyle
& wxCANCEL
)
72 msStyle
= MB_YESNOCANCEL
;
74 #endif // !(__SMARTPHONE__ && __WXWINCE__)
77 if (wxStyle
& wxNO_DEFAULT
)
78 msStyle
|= MB_DEFBUTTON2
;
83 if (wxStyle
& wxCANCEL
)
84 msStyle
= MB_OKCANCEL
;
88 if (wxStyle
& wxICON_EXCLAMATION
)
89 msStyle
|= MB_ICONEXCLAMATION
;
90 else if (wxStyle
& wxICON_HAND
)
91 msStyle
|= MB_ICONHAND
;
92 else if (wxStyle
& wxICON_INFORMATION
)
93 msStyle
|= MB_ICONINFORMATION
;
94 else if (wxStyle
& wxICON_QUESTION
)
95 msStyle
|= MB_ICONQUESTION
;
97 if ( wxStyle
& wxSTAY_ON_TOP
)
98 msStyle
|= MB_TOPMOST
;
101 msStyle
|= MB_APPLMODAL
;
103 msStyle
|= MB_TASKMODAL
;
105 // do show the dialog
106 int msAns
= MessageBox(hWnd
, m_message
.c_str(), m_caption
.c_str(), msStyle
);
111 wxFAIL_MSG(_T("unexpected ::MessageBox() return code"));