- 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 ;
- }
+ wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
+
+ wxModalDialogs.Append(this);
+
+ wxWindow *parent = GetParent();
+
+ // remember where the focus was
+ wxWindow *winFocus = FindFocus();
+ if ( !winFocus )
+ {
+ winFocus = parent;
+ }
+ if ( !winFocus )
+ {
+ winFocus = wxTheApp->GetTopWindow();
+ }
+ // TODO : test whether parent gets disabled