wxApp not exitting when wxDialog closed for wxApp-wxDialog

61 views
Skip to first unread message

Xu, Ming (NIH/NLM/NCBI) [F]

unread,
May 7, 2006, 12:52:42 PM5/7/06
to wx-u...@lists.wxwidgets.org

Hi,

I try to use wxApp with wxDialog. At wxApp's OnInti, a wxDialog derived
object creared, show and also SetTopWindow(the dialog ptr).
the app is invoked via command line, the dialog popped up but when
the dialog is closed, the app doesn't exit. if I put a wxFrme derived
object instead, after I close the popped up the frame object window,
the app does exit.

could some one tell me how ?

regards

ming

Marcin Simonides

unread,
May 7, 2006, 1:56:01 PM5/7/06
to wx-u...@lists.wxwidgets.org

Dialogs don't get destroyed automatically on close.

See: http://www.wxwidgets.org/technote/dlgbased.htm
There's a paragraph entitled: "Closing the application".

In short: you should call Destroy() instead of Close(), when you want to
quit.

I haven't tried it myself :)
--
Marcin Simonides

BobR

unread,
May 7, 2006, 3:30:11 PM5/7/06
to wx-u...@lists.wxwidgets.org

"Xu, Ming (NIH/NLM/NCBI) [F]" wrote in message ...


>Hi,
>I try to use wxApp with wxDialog. At wxApp's OnInti, a wxDialog derived
>object creared, show and also SetTopWindow(the dialog ptr).

>could some one tell me how ?

bool MyApp::OnInit(){
BwxTimeDlg BTDlg(0, "BwxTimeDlg BTDlg");
BTDlg.ShowModal();
return false; // <----- note the 'false' here.
} //MyApp::OnInit()

If you return 'true' from 'OnInit()', it signals the program to keep running.

--
Bob R
POVrookie

Xu, Ming (NIH/NLM/NCBI) [F]

unread,
May 7, 2006, 8:57:00 PM5/7/06
to wx-u...@lists.wxwidgets.org, BobR
thanks, Bob.

return TRUE at MyApp::OnInit(){... return TRUE }
for wxFrame derived object is OK, but wxDialog derived
object must return FALSE. I thoguht they are both derived
from wxWindow so should work the same way, when the derived
wxWindow object exits, how is wxApp::OnExit called ? it seems
wxFrame calls wxApp::OnExit in some way but wxDialog doesn't.

regards

ming

--
Bob R
POVrookie

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org

winmail.dat
Reply all
Reply to author
Forward
0 new messages