+ HWND hWnd = 0;
+ ULONG ulStyle = MB_OK;
+ int nAns = wxOK;
+ const long lStyle = GetMessageDialogStyle();
+
+ if (!wxTheApp->GetTopWindow())
+ {
+ //
+ // when the message box is shown from wxApp::OnInit() (i.e. before the
+ // message loop is entered), this must be done or the next message box
+ // will never be shown - just try putting 2 calls to wxMessageBox() in
+ // OnInit() to see it
+ //
+ while (wxTheApp->Pending())
+ wxTheApp->Dispatch();
+ }
+
+ if (m_parent)
+ hWnd = (HWND) m_parent->GetHWND();
+ else
+ hWnd = HWND_DESKTOP;
+ if (lStyle & wxYES_NO)
+ {
+ if (lStyle & wxCANCEL)
+ ulStyle = MB_YESNOCANCEL;
+ else
+ ulStyle = MB_YESNO;
+
+ if (lStyle & wxNO_DEFAULT)
+ ulStyle |= MB_DEFBUTTON2;
+ }
+
+ if (lStyle & wxOK)
+ {
+ if (lStyle & wxCANCEL)
+ ulStyle = MB_OKCANCEL;
+ else
+ ulStyle = MB_OK;
+ }
+ if (lStyle & wxICON_EXCLAMATION)
+ ulStyle |= MB_ICONEXCLAMATION;
+ else if (lStyle & wxICON_HAND)
+ ulStyle |= MB_ICONHAND;
+ else if (lStyle & wxICON_INFORMATION)
+ ulStyle |= MB_ICONEXCLAMATION;
+ else if (lStyle & wxICON_QUESTION)
+ ulStyle |= MB_ICONQUESTION;
+
+ if (hWnd != HWND_DESKTOP)
+ ulStyle |= MB_APPLMODAL;
+ else
+ ulStyle |= MB_SYSTEMMODAL;
+
+ //
+ // This little line of code is get message boxes under OS/2 to
+ // behve like the other ports. In OS/2 if the parent is a window
+ // it displays, clipped, in the window. This centers it on the
+ // desktop, like the other ports but still allows control over modality
+ //
+ hWnd = HWND_DESKTOP;