- int x_offset,y_offset ;
- int display_width, display_height;
- int width, height, x, y;
- wxWindow *parent = GetParent();
- if ((direction & wxCENTER_FRAME) && parent)
- {
- parent->GetPosition(&x_offset,&y_offset) ;
- parent->GetSize(&display_width,&display_height) ;
- }
- else
- {
- wxDisplaySize(&display_width, &display_height);
- x_offset = 0 ;
- y_offset = 0 ;
- }
-
- GetSize(&width, &height);
- GetPosition(&x, &y);
-
- if (direction & wxHORIZONTAL)
- x = (int)((display_width - width)/2);
- if (direction & wxVERTICAL)
- y = (int)((display_height - height)/2);
-
- SetSize(x+x_offset, y+y_offset, width, height);
-}
+ if (!bShow)
+ {
+ //
+ // If we had disabled other app windows, reenable them back now because
+ // if they stay disabled Windows will activate another window (one
+ // which is enabled, anyhow) and we will lose activation. We really don't
+ // do this in OS/2 since PM does this for us.
+ //
+ if (m_pWindowDisabler)
+ {
+ delete m_pWindowDisabler;
+ m_pWindowDisabler = NULL;
+ }
+ if ( m_modalData )
+ m_modalData->ExitLoop();
+ }
+
+ //
+ // ShowModal() may be called for already shown dialog
+ //
+ if (!wxDialogBase::Show(bShow) && !(bShow && IsModal()))
+ {
+ //
+ // Nothing to do
+ //
+ return FALSE;
+ }
+
+ if (bShow)
+ {
+ // dialogs don't get WM_SIZE message after creation unlike most (all?)
+ // other windows and so could start their life non laid out correctly
+ // if we didn't call Layout() from here
+ //
+ // NB: normally we should call it just the first time but doing it
+ // every time is simpler than keeping a flag
+// Layout();
+
+ //
+ // Usually will result in TransferDataToWindow() being called
+ //
+ InitDialog();
+ }
+
+ if (GetTitle().c_str())
+ ::WinSetWindowText((HWND)GetHwnd(), GetTitle().c_str());
+ if (IsModal())
+ {
+ if (bShow)
+ {
+ //
+ // Modal dialog needs a parent window, so try to find one
+ //
+ if (!GetParent())
+ {
+ wxWindow* pParent = wxTheApp->GetTopWindow();
+
+ if ( pParent && pParent != this && pParent->IsShown() )
+ {
+ //
+ // Use it
+ //
+ m_parent = pParent;
+
+ }
+ }
+ DoShowModal();
+ }
+ }
+ return TRUE;
+} // end of wxDialog::Show