]>
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 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() )
60 if (m_parent
) hWnd
= (HWND
) m_parent
->GetHWND();
61 unsigned int msStyle
= MB_OK
;
62 if (m_dialogStyle
& wxYES_NO
)
64 if (m_dialogStyle
& wxCANCEL
)
65 msStyle
= MB_YESNOCANCEL
;
69 if (m_dialogStyle
& wxNO_DEFAULT
)
70 msStyle
|= MB_DEFBUTTON2
;
73 if (m_dialogStyle
& wxOK
)
75 if (m_dialogStyle
& wxCANCEL
)
76 msStyle
= MB_OKCANCEL
;
80 if (m_dialogStyle
& wxICON_EXCLAMATION
)
81 msStyle
|= MB_ICONEXCLAMATION
;
82 else if (m_dialogStyle
& wxICON_HAND
)
83 msStyle
|= MB_ICONHAND
;
84 else if (m_dialogStyle
& wxICON_INFORMATION
)
85 msStyle
|= MB_ICONINFORMATION
;
86 else if (m_dialogStyle
& wxICON_QUESTION
)
87 msStyle
|= MB_ICONQUESTION
;
90 msStyle
|= MB_APPLMODAL
;
92 msStyle
|= MB_TASKMODAL
;
94 int msAns
= MessageBox(hWnd
, (LPCTSTR
)m_message
.c_str(),
95 (LPCTSTR
)m_caption
.c_str(), msStyle
);