]> git.saurik.com Git - wxWidgets.git/blob - src/msw/msgdlg.cpp
added a WXDLLEXPORT
[wxWidgets.git] / src / msw / msgdlg.cpp
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
9 // Licence: wxWindows license
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
24 #include <stdio.h>
25 #include "wx/defs.h"
26 #include "wx/utils.h"
27 #include "wx/dialog.h"
28 #include "wx/msgdlg.h"
29 #endif
30
31 #include "wx/msw/private.h"
32
33 #include <math.h>
34 #include <stdlib.h>
35 #include <string.h>
36
37 #define wxDIALOG_DEFAULT_X 300
38 #define wxDIALOG_DEFAULT_Y 300
39
40 #if !USE_SHARED_LIBRARY
41 IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
42 #endif
43
44 wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
45 long style, const wxPoint& pos)
46 {
47 m_caption = caption;
48 m_message = message;
49 m_dialogStyle = style;
50 m_parent = parent;
51 }
52
53 int wxMessageDialog::ShowModal(void)
54 {
55 HWND hWnd = 0;
56 if (m_parent) hWnd = (HWND) m_parent->GetHWND();
57 unsigned int msStyle = MB_OK;
58 if (m_dialogStyle & wxYES_NO)
59 {
60 if (m_dialogStyle & wxCANCEL)
61 msStyle = MB_YESNOCANCEL;
62 else
63 msStyle = MB_YESNO;
64
65 if (m_dialogStyle & wxNO_DEFAULT)
66 msStyle |= MB_DEFBUTTON2;
67 }
68
69 if (m_dialogStyle & wxOK)
70 {
71 if (m_dialogStyle & wxCANCEL)
72 msStyle = MB_OKCANCEL;
73 else
74 msStyle = MB_OK;
75 }
76 if (m_dialogStyle & wxICON_EXCLAMATION)
77 msStyle |= MB_ICONEXCLAMATION;
78 else if (m_dialogStyle & wxICON_HAND)
79 msStyle |= MB_ICONHAND;
80 else if (m_dialogStyle & wxICON_INFORMATION)
81 msStyle |= MB_ICONINFORMATION;
82 else if (m_dialogStyle & wxICON_QUESTION)
83 msStyle |= MB_ICONQUESTION;
84
85 if (hWnd)
86 msStyle |= MB_APPLMODAL;
87 else
88 msStyle |= MB_TASKMODAL;
89
90 int msAns = MessageBox(hWnd, (LPCTSTR)(const wxChar *)m_message, (LPCTSTR)(const wxChar *)m_caption, msStyle);
91 int ans = wxOK;
92 switch (msAns)
93 {
94 case IDCANCEL:
95 ans = wxID_CANCEL;
96 break;
97 case IDOK:
98 ans = wxID_OK;
99 break;
100 case IDYES:
101 ans = wxID_YES;
102 break;
103 case IDNO:
104 ans = wxID_NO;
105 break;
106 }
107 return ans;
108 }
109