]> git.saurik.com Git - wxWidgets.git/blob - src/msw/msgdlg.cpp
some compilation fixes for mingw32 and not only
[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 IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
41
42 wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
43 long style, const wxPoint& pos)
44 {
45 m_caption = caption;
46 m_message = message;
47 m_dialogStyle = style;
48 m_parent = parent;
49 }
50
51 int wxMessageDialog::ShowModal(void)
52 {
53 HWND hWnd = 0;
54 if (m_parent) hWnd = (HWND) m_parent->GetHWND();
55 unsigned int msStyle = MB_OK;
56 if (m_dialogStyle & wxYES_NO)
57 {
58 if (m_dialogStyle & wxCANCEL)
59 msStyle = MB_YESNOCANCEL;
60 else
61 msStyle = MB_YESNO;
62
63 if (m_dialogStyle & wxNO_DEFAULT)
64 msStyle |= MB_DEFBUTTON2;
65 }
66
67 if (m_dialogStyle & wxOK)
68 {
69 if (m_dialogStyle & wxCANCEL)
70 msStyle = MB_OKCANCEL;
71 else
72 msStyle = MB_OK;
73 }
74 if (m_dialogStyle & wxICON_EXCLAMATION)
75 msStyle |= MB_ICONEXCLAMATION;
76 else if (m_dialogStyle & wxICON_HAND)
77 msStyle |= MB_ICONHAND;
78 else if (m_dialogStyle & wxICON_INFORMATION)
79 msStyle |= MB_ICONINFORMATION;
80 else if (m_dialogStyle & wxICON_QUESTION)
81 msStyle |= MB_ICONQUESTION;
82
83 if (hWnd)
84 msStyle |= MB_APPLMODAL;
85 else
86 msStyle |= MB_TASKMODAL;
87
88 int msAns = MessageBox(hWnd, (LPCTSTR)(const wxChar *)m_message, (LPCTSTR)(const wxChar *)m_caption, msStyle);
89 int ans = wxOK;
90 switch (msAns)
91 {
92 case IDCANCEL:
93 ans = wxID_CANCEL;
94 break;
95 case IDOK:
96 ans = wxID_OK;
97 break;
98 case IDYES:
99 ans = wxID_YES;
100 break;
101 case IDNO:
102 ans = wxID_NO;
103 break;
104 }
105 return ans;
106 }
107