]>
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 wxWindow
*winTop
= 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
63 hWnd
= GetHwndOf(m_parent
);
65 hWnd
= GetHwndOf(winTop
);
67 // translate wx style in MSW
68 unsigned int msStyle
= MB_OK
;
69 if (m_dialogStyle
& wxYES_NO
)
71 if (m_dialogStyle
& wxCANCEL
)
72 msStyle
= MB_YESNOCANCEL
;
76 if (m_dialogStyle
& wxNO_DEFAULT
)
77 msStyle
|= MB_DEFBUTTON2
;
80 if (m_dialogStyle
& wxOK
)
82 if (m_dialogStyle
& wxCANCEL
)
83 msStyle
= MB_OKCANCEL
;
87 if (m_dialogStyle
& wxICON_EXCLAMATION
)
88 msStyle
|= MB_ICONEXCLAMATION
;
89 else if (m_dialogStyle
& wxICON_HAND
)
90 msStyle
|= MB_ICONHAND
;
91 else if (m_dialogStyle
& wxICON_INFORMATION
)
92 msStyle
|= MB_ICONINFORMATION
;
93 else if (m_dialogStyle
& wxICON_QUESTION
)
94 msStyle
|= MB_ICONQUESTION
;
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"));