]>
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"
26 #include "wx/dialog.h"
27 #include "wx/msgdlg.h"
30 #include "wx/msw/private.h"
32 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
34 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
35 const wxString
& message
,
36 const wxString
& caption
,
38 const wxPoint
& WXUNUSED(pos
))
42 m_dialogStyle
= style
;
46 int wxMessageDialog::ShowModal()
48 if ( !wxTheApp
->GetTopWindow() )
50 // when the message box is shown from wxApp::OnInit() (i.e. before the
51 // message loop is entered), this must be done or the next message box
52 // will never be shown - just try putting 2 calls to wxMessageBox() in
54 while ( wxTheApp
->Pending() )
59 if (m_parent
) hWnd
= (HWND
) m_parent
->GetHWND();
60 unsigned int msStyle
= MB_OK
;
61 if (m_dialogStyle
& wxYES_NO
)
63 if (m_dialogStyle
& wxCANCEL
)
64 msStyle
= MB_YESNOCANCEL
;
68 if (m_dialogStyle
& wxNO_DEFAULT
)
69 msStyle
|= MB_DEFBUTTON2
;
72 if (m_dialogStyle
& wxOK
)
74 if (m_dialogStyle
& wxCANCEL
)
75 msStyle
= MB_OKCANCEL
;
79 if (m_dialogStyle
& wxICON_EXCLAMATION
)
80 msStyle
|= MB_ICONEXCLAMATION
;
81 else if (m_dialogStyle
& wxICON_HAND
)
82 msStyle
|= MB_ICONHAND
;
83 else if (m_dialogStyle
& wxICON_INFORMATION
)
84 msStyle
|= MB_ICONINFORMATION
;
85 else if (m_dialogStyle
& wxICON_QUESTION
)
86 msStyle
|= MB_ICONQUESTION
;
89 msStyle
|= MB_APPLMODAL
;
91 msStyle
|= MB_TASKMODAL
;
93 int msAns
= MessageBox(hWnd
, (LPCTSTR
)m_message
.c_str(),
94 (LPCTSTR
)m_caption
.c_str(), msStyle
);