]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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
))
42 // check for common programming errors
43 if ( (style
& wxID_OK
) == wxID_OK
)
45 // programmer probably confused wxID_OK with wxOK. Correct one is wxOK.
46 wxFAIL_MSG( _T("wxMessageBox: Did you mean wxOK (and not wxID_OK)?") );
52 m_dialogStyle
= style
;
56 int wxMessageDialog::ShowModal()
58 if ( !wxTheApp
->GetTopWindow() )
60 // when the message box is shown from wxApp::OnInit() (i.e. before the
61 // message loop is entered), this must be done or the next message box
62 // will never be shown - just try putting 2 calls to wxMessageBox() in
64 while ( wxTheApp
->Pending() )
68 // use the top level window as parent if none specified
70 m_parent
= FindSuitableParent();
71 HWND hWnd
= m_parent
? GetHwndOf(m_parent
) : NULL
;
73 // translate wx style in MSW
74 unsigned int msStyle
= MB_OK
;
75 if (m_dialogStyle
& wxYES_NO
)
77 if (m_dialogStyle
& wxCANCEL
)
78 msStyle
= MB_YESNOCANCEL
;
82 if (m_dialogStyle
& wxNO_DEFAULT
)
83 msStyle
|= MB_DEFBUTTON2
;
86 if (m_dialogStyle
& wxOK
)
88 if (m_dialogStyle
& wxCANCEL
)
89 msStyle
= MB_OKCANCEL
;
93 if (m_dialogStyle
& wxICON_EXCLAMATION
)
94 msStyle
|= MB_ICONEXCLAMATION
;
95 else if (m_dialogStyle
& wxICON_HAND
)
96 msStyle
|= MB_ICONHAND
;
97 else if (m_dialogStyle
& wxICON_INFORMATION
)
98 msStyle
|= MB_ICONINFORMATION
;
99 else if (m_dialogStyle
& wxICON_QUESTION
)
100 msStyle
|= MB_ICONQUESTION
;
102 if ( m_dialogStyle
& wxSTAY_ON_TOP
)
103 msStyle
|= MB_TOPMOST
;
106 msStyle
|= MB_APPLMODAL
;
109 msStyle
|= MB_TASKMODAL
;
112 // do show the dialog
113 int msAns
= MessageBox(hWnd
, m_message
.c_str(), m_caption
.c_str(), msStyle
);
118 wxFAIL_MSG(_T("unexpected ::MessageBox() return code"));