]> git.saurik.com Git - wxWidgets.git/blame - src/os2/msgdlg.cpp
Minor corrections to wxFlexGridSizer ctor documentation.
[wxWidgets.git] / src / os2 / msgdlg.cpp
CommitLineData
0e320a79 1/////////////////////////////////////////////////////////////////////////////
e5b50758 2// Name: src/os2/msgdlg.cpp
0e320a79 3// Purpose: wxMessageDialog
cdf1e714 4// Author: David Webster
0e320a79 5// Modified by:
cdf1e714 6// Created: 10/10/99
e5b50758 7// RCS-ID: $Id$
cdf1e714 8// Copyright: (c) David Webster
65571936 9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
cdf1e714
DW
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
246c5004
WS
15#include "wx/msgdlg.h"
16
cdf1e714 17#ifndef WX_PRECOMP
7520f3da
WS
18 #include <stdio.h>
19 #include "wx/utils.h"
20 #include "wx/dialog.h"
21 #include "wx/app.h"
7520f3da 22 #include "wx/math.h"
0e320a79
DW
23#endif
24
cdf1e714
DW
25#include "wx/os2/private.h"
26
cdf1e714
DW
27#include <stdlib.h>
28#include <string.h>
29
30#define wxDIALOG_DEFAULT_X 300
31#define wxDIALOG_DEFAULT_Y 300
0e320a79 32
0e320a79 33IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
0e320a79 34
0e320a79
DW
35int wxMessageDialog::ShowModal()
36{
f6bcfd97
BP
37 HWND hWnd = 0;
38 ULONG ulStyle = MB_OK;
39 int nAns = wxOK;
e5b50758 40 const long lStyle = GetMessageDialogStyle();
f6bcfd97
BP
41
42 if (!wxTheApp->GetTopWindow())
43 {
44 //
45 // when the message box is shown from wxApp::OnInit() (i.e. before the
46 // message loop is entered), this must be done or the next message box
47 // will never be shown - just try putting 2 calls to wxMessageBox() in
48 // OnInit() to see it
49 //
50 while (wxTheApp->Pending())
51 wxTheApp->Dispatch();
52 }
53
2afb9e16
VZ
54 if (m_parent)
55 hWnd = (HWND) m_parent->GetHWND();
f6bcfd97
BP
56 else
57 hWnd = HWND_DESKTOP;
e5b50758 58 if (lStyle & wxYES_NO)
f6bcfd97 59 {
e5b50758 60 if (lStyle & wxCANCEL)
f6bcfd97
BP
61 ulStyle = MB_YESNOCANCEL;
62 else
63 ulStyle = MB_YESNO;
64
e5b50758 65 if (lStyle & wxNO_DEFAULT)
f6bcfd97
BP
66 ulStyle |= MB_DEFBUTTON2;
67 }
68
e5b50758 69 if (lStyle & wxOK)
f6bcfd97 70 {
e5b50758 71 if (lStyle & wxCANCEL)
f6bcfd97
BP
72 ulStyle = MB_OKCANCEL;
73 else
74 ulStyle = MB_OK;
75 }
e5b50758 76 if (lStyle & wxICON_EXCLAMATION)
f6bcfd97 77 ulStyle |= MB_ICONEXCLAMATION;
e5b50758 78 else if (lStyle & wxICON_HAND)
f6bcfd97 79 ulStyle |= MB_ICONHAND;
e5b50758 80 else if (lStyle & wxICON_INFORMATION)
f6bcfd97 81 ulStyle |= MB_ICONEXCLAMATION;
e5b50758 82 else if (lStyle & wxICON_QUESTION)
f6bcfd97
BP
83 ulStyle |= MB_ICONQUESTION;
84
85 if (hWnd != HWND_DESKTOP)
86 ulStyle |= MB_APPLMODAL;
87 else
88 ulStyle |= MB_SYSTEMMODAL;
89
90 //
91 // This little line of code is get message boxes under OS/2 to
92 // behve like the other ports. In OS/2 if the parent is a window
93 // it displays, clipped, in the window. This centers it on the
94 // desktop, like the other ports but still allows control over modality
95 //
96 hWnd = HWND_DESKTOP;
97
98 ULONG ulAns = ::WinMessageBox( hWnd
99 ,hWnd
2afb9e16
VZ
100 ,GetFullMessage().c_str()
101 ,m_caption.c_str()
f6bcfd97
BP
102 ,0L
103 ,ulStyle);
104 switch (ulAns)
105 {
106 case MBID_CANCEL:
107 nAns = wxID_CANCEL;
108 break;
109 case MBID_OK:
110 nAns = wxID_OK;
111 break;
112 case MBID_YES:
113 nAns = wxID_YES;
114 break;
115 case MBID_NO:
116 nAns = wxID_NO;
117 break;
118 default:
119 nAns = wxID_CANCEL;
120 }
121 return nAns;
122} // end of wxMessageDialog::ShowModal