]>
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 #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
)) 
  49     SetMessageDialogStyle(style
); 
  52 int wxMessageDialog::ShowModal() 
  54     if ( !wxTheApp
->GetTopWindow() ) 
  56         // when the message box is shown from wxApp::OnInit() (i.e. before the 
  57         // message loop is entered), this must be done or the next message box 
  58         // will never be shown - just try putting 2 calls to wxMessageBox() in 
  60         while ( wxTheApp
->Pending() ) 
  64     // use the top level window as parent if none specified 
  66         m_parent 
= FindSuitableParent(); 
  67     HWND hWnd 
= m_parent 
? GetHwndOf(m_parent
) : NULL
; 
  69     // translate wx style in MSW 
  70     unsigned int msStyle 
= MB_OK
; 
  71     const long wxStyle 
= GetMessageDialogStyle(); 
  72     if (wxStyle 
& wxYES_NO
) 
  74 #if !(defined(__SMARTPHONE__) && defined(__WXWINCE__)) 
  75         if (wxStyle 
& wxCANCEL
) 
  76             msStyle 
= MB_YESNOCANCEL
; 
  78 #endif // !(__SMARTPHONE__ && __WXWINCE__) 
  81         if (wxStyle 
& wxNO_DEFAULT
) 
  82             msStyle 
|= MB_DEFBUTTON2
; 
  87         if (wxStyle 
& wxCANCEL
) 
  88             msStyle 
= MB_OKCANCEL
; 
  92     if (wxStyle 
& wxICON_EXCLAMATION
) 
  93         msStyle 
|= MB_ICONEXCLAMATION
; 
  94     else if (wxStyle 
& wxICON_HAND
) 
  95         msStyle 
|= MB_ICONHAND
; 
  96     else if (wxStyle 
& wxICON_INFORMATION
) 
  97         msStyle 
|= MB_ICONINFORMATION
; 
  98     else if (wxStyle 
& wxICON_QUESTION
) 
  99         msStyle 
|= MB_ICONQUESTION
; 
 101     if ( wxStyle 
& wxSTAY_ON_TOP 
) 
 102         msStyle 
|= MB_TOPMOST
; 
 105         msStyle 
|= MB_APPLMODAL
; 
 107         msStyle 
|= MB_TASKMODAL
; 
 109     // do show the dialog 
 110     int msAns 
= MessageBox(hWnd
, m_message
.c_str(), m_caption
.c_str(), msStyle
); 
 115             wxFAIL_MSG(_T("unexpected ::MessageBox() return code"));