]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/msgdlg.cpp
6ea59bcfddb6699e697080d8250d9294882e49b2
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"
35 #include "wx/msw/wince/missing.h"
38 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
40 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
41 const wxString
& message
,
42 const wxString
& caption
,
44 const wxPoint
& WXUNUSED(pos
))
47 // check for common programming errors
48 if ( (style
& wxID_OK
) == wxID_OK
)
50 // programmer probably confused wxID_OK with wxOK. Correct one is wxOK.
51 wxFAIL_MSG( _T("wxMessageBox: Did you mean wxOK (and not wxID_OK)?") );
57 m_dialogStyle
= style
;
61 int wxMessageDialog::ShowModal()
63 if ( !wxTheApp
->GetTopWindow() )
65 // when the message box is shown from wxApp::OnInit() (i.e. before the
66 // message loop is entered), this must be done or the next message box
67 // will never be shown - just try putting 2 calls to wxMessageBox() in
69 while ( wxTheApp
->Pending() )
73 // use the top level window as parent if none specified
75 m_parent
= FindSuitableParent();
76 HWND hWnd
= m_parent
? GetHwndOf(m_parent
) : NULL
;
78 // translate wx style in MSW
79 unsigned int msStyle
= MB_OK
;
80 if (m_dialogStyle
& wxYES_NO
)
82 if (m_dialogStyle
& wxCANCEL
)
83 msStyle
= MB_YESNOCANCEL
;
87 if (m_dialogStyle
& wxNO_DEFAULT
)
88 msStyle
|= MB_DEFBUTTON2
;
91 if (m_dialogStyle
& wxOK
)
93 if (m_dialogStyle
& wxCANCEL
)
94 msStyle
= MB_OKCANCEL
;
98 if (m_dialogStyle
& wxICON_EXCLAMATION
)
99 msStyle
|= MB_ICONEXCLAMATION
;
100 else if (m_dialogStyle
& wxICON_HAND
)
101 msStyle
|= MB_ICONHAND
;
102 else if (m_dialogStyle
& wxICON_INFORMATION
)
103 msStyle
|= MB_ICONINFORMATION
;
104 else if (m_dialogStyle
& wxICON_QUESTION
)
105 msStyle
|= MB_ICONQUESTION
;
107 if ( m_dialogStyle
& wxSTAY_ON_TOP
)
108 msStyle
|= MB_TOPMOST
;
111 msStyle
|= MB_APPLMODAL
;
113 msStyle
|= MB_TASKMODAL
;
115 // do show the dialog
116 int msAns
= MessageBox(hWnd
, m_message
.c_str(), m_caption
.c_str(), msStyle
);
121 wxFAIL_MSG(_T("unexpected ::MessageBox() return code"));