]>
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"
22 #include "wx/dialog.h"
23 #include "wx/msgdlg.h"
26 #include "wx/msw/private.h"
30 #include "wx/msw/wince/missing.h"
33 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
35 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
36 const wxString
& message
,
37 const wxString
& caption
,
39 const wxPoint
& WXUNUSED(pos
))
44 SetMessageDialogStyle(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 const long wxStyle
= GetMessageDialogStyle();
67 if (wxStyle
& wxYES_NO
)
69 #if !(defined(__SMARTPHONE__) && defined(__WXWINCE__))
70 if (wxStyle
& wxCANCEL
)
71 msStyle
= MB_YESNOCANCEL
;
73 #endif // !(__SMARTPHONE__ && __WXWINCE__)
76 if (wxStyle
& wxNO_DEFAULT
)
77 msStyle
|= MB_DEFBUTTON2
;
82 if (wxStyle
& wxCANCEL
)
83 msStyle
= MB_OKCANCEL
;
87 if (wxStyle
& wxICON_EXCLAMATION
)
88 msStyle
|= MB_ICONEXCLAMATION
;
89 else if (wxStyle
& wxICON_HAND
)
90 msStyle
|= MB_ICONHAND
;
91 else if (wxStyle
& wxICON_INFORMATION
)
92 msStyle
|= MB_ICONINFORMATION
;
93 else if (wxStyle
& wxICON_QUESTION
)
94 msStyle
|= MB_ICONQUESTION
;
96 if ( wxStyle
& wxSTAY_ON_TOP
)
97 msStyle
|= MB_TOPMOST
;
100 msStyle
|= MB_APPLMODAL
;
102 msStyle
|= MB_TASKMODAL
;
104 // do show the dialog
105 int msAns
= MessageBox(hWnd
, m_message
.c_str(), m_caption
.c_str(), msStyle
);
110 wxFAIL_MSG(_T("unexpected ::MessageBox() return code"));