]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/msgdlg.cpp
3 // Purpose: wxMessageDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/msgdlg.h"
26 #include "wx/dialog.h"
29 #include "wx/msw/private.h"
33 #include "wx/msw/wince/missing.h"
36 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
38 int wxMessageDialog::ShowModal()
40 if ( !wxTheApp
->GetTopWindow() )
42 // when the message box is shown from wxApp::OnInit() (i.e. before the
43 // message loop is entered), this must be done or the next message box
44 // will never be shown - just try putting 2 calls to wxMessageBox() in
46 while ( wxTheApp
->Pending() )
50 // use the top level window as parent if none specified
52 m_parent
= FindSuitableParent();
53 HWND hWnd
= m_parent
? GetHwndOf(m_parent
) : NULL
;
55 // translate wx style in MSW
56 unsigned int msStyle
= MB_OK
;
57 const long wxStyle
= GetMessageDialogStyle();
58 if (wxStyle
& wxYES_NO
)
60 #if !(defined(__SMARTPHONE__) && defined(__WXWINCE__))
61 if (wxStyle
& wxCANCEL
)
62 msStyle
= MB_YESNOCANCEL
;
64 #endif // !(__SMARTPHONE__ && __WXWINCE__)
67 if (wxStyle
& wxNO_DEFAULT
)
68 msStyle
|= MB_DEFBUTTON2
;
73 if (wxStyle
& wxCANCEL
)
74 msStyle
= MB_OKCANCEL
;
78 if (wxStyle
& wxICON_EXCLAMATION
)
79 msStyle
|= MB_ICONEXCLAMATION
;
80 else if (wxStyle
& wxICON_HAND
)
81 msStyle
|= MB_ICONHAND
;
82 else if (wxStyle
& wxICON_INFORMATION
)
83 msStyle
|= MB_ICONINFORMATION
;
84 else if (wxStyle
& wxICON_QUESTION
)
85 msStyle
|= MB_ICONQUESTION
;
87 if ( wxStyle
& wxSTAY_ON_TOP
)
88 msStyle
|= MB_TOPMOST
;
91 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
92 msStyle
|= MB_RTLREADING
| MB_RIGHT
;
96 msStyle
|= MB_APPLMODAL
;
98 msStyle
|= MB_TASKMODAL
;
100 // per MSDN documentation for MessageBox() we can prefix the message with 2
101 // right-to-left mark characters to tell the function to use RTL layout
102 // (unfortunately this only works in Unicode builds)
103 wxString message
= GetFullMessage();
105 if ( wxTheApp
->GetLayoutDirection() == wxLayout_RightToLeft
)
107 // NB: not all compilers support \u escapes
108 static const wchar_t wchRLM
= 0x200f;
109 message
.Prepend(wxString(wchRLM
, 2));
111 #endif // wxUSE_UNICODE
113 // do show the dialog
114 int msAns
= MessageBox(hWnd
, message
.wx_str(), m_caption
.wx_str(), msStyle
);
119 wxFAIL_MSG(_T("unexpected ::MessageBox() return code"));
138 #endif // wxUSE_MSGDLG