]> git.saurik.com Git - wxWidgets.git/blame - src/msw/msgdlg.cpp
added some utils (tex2rtf, helpgen, makegen) to make system
[wxWidgets.git] / src / msw / msgdlg.cpp
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: msgdlg.cpp
3// Purpose: wxMessageDialog
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
0d7ea902 9// Licence: wxWindows license
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "msgdlg.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
0d7ea902
VZ
24 #include "wx/defs.h"
25 #include "wx/utils.h"
26 #include "wx/dialog.h"
27 #include "wx/msgdlg.h"
2bda0e17
KB
28#endif
29
30#include "wx/msw/private.h"
31
2bda0e17 32IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
2bda0e17 33
0d7ea902
VZ
34wxMessageDialog::wxMessageDialog(wxWindow *parent,
35 const wxString& message,
36 const wxString& caption,
37 long style,
38 const wxPoint& WXUNUSED(pos))
2bda0e17
KB
39{
40 m_caption = caption;
41 m_message = message;
42 m_dialogStyle = style;
43 m_parent = parent;
44}
45
0d7ea902 46int wxMessageDialog::ShowModal()
2bda0e17 47{
0d7ea902
VZ
48 if ( !wxTheApp->GetTopWindow() )
49 {
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
53 // OnInit() to see it
54 while ( wxTheApp->Pending() )
55 wxTheApp->Dispatch();
56 }
93c95e18 57
0d7ea902
VZ
58 HWND hWnd = 0;
59 if (m_parent) hWnd = (HWND) m_parent->GetHWND();
60 unsigned int msStyle = MB_OK;
61 if (m_dialogStyle & wxYES_NO)
62 {
63 if (m_dialogStyle & wxCANCEL)
64 msStyle = MB_YESNOCANCEL;
65 else
66 msStyle = MB_YESNO;
93c95e18 67
0d7ea902
VZ
68 if (m_dialogStyle & wxNO_DEFAULT)
69 msStyle |= MB_DEFBUTTON2;
70 }
71
72 if (m_dialogStyle & wxOK)
73 {
74 if (m_dialogStyle & wxCANCEL)
75 msStyle = MB_OKCANCEL;
76 else
77 msStyle = MB_OK;
78 }
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;
2bda0e17 87
0d7ea902
VZ
88 if (hWnd)
89 msStyle |= MB_APPLMODAL;
90 else
91 msStyle |= MB_TASKMODAL;
93c95e18 92
0d7ea902
VZ
93 int msAns = MessageBox(hWnd, (LPCTSTR)m_message.c_str(),
94 (LPCTSTR)m_caption.c_str(), msStyle);
95 int ans = wxOK;
96 switch (msAns)
97 {
98 case IDCANCEL:
99 ans = wxID_CANCEL;
100 break;
101 case IDOK:
102 ans = wxID_OK;
103 break;
104 case IDYES:
105 ans = wxID_YES;
106 break;
107 case IDNO:
108 ans = wxID_NO;
109 break;
110 }
111 return ans;
2bda0e17
KB
112}
113