Re: Managing modeless document windows
Vadim Zeitlin <[email protected]>
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
On Sun, 02 Apr 2023 04:54:21 -0700 Kenneth Porter wrote:
KP> I'm looking for an idiom for handling document window lifetimes. I want to
KP> be able to spawn frames independent of the main application frame but have
KP> them clean up properly when the app exits.
Just to clarify: if they're really independent, you're going to have to
close all of them to make the application exit. If you want them to get
closed automatically when the main frame is closed, they would need to use
the main frame as their parent and so not be really independent any more.
KP> It seems like I should hold a container of document frame pointers in the
KP> main frame, and the close event in the document frames should be forwarded
KP> to the app frame so that it can destroy the document frame and remove its
KP> pointer from its container. Is there another approach I should consider?
I would hold the global container (probably a map indexed by the document
identity, whatever it is) in YourApp, i.e. wxApp-derived class and remove
the document frames from it when they're closed/destroyed, i.e. in their
own wxEVT_CLOSE_WINDOW handler/dtor.
You could also consider using the wx docview framework in its SDI version
for this, as it provides quite a few of things useful for document-oriented
applications.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
signature.asc
(application/pgp-signature, 196 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) iEYEABECAAYFAmQraDYACgkQBupB3k9sHoYlNQCfRpyGgfU8Qz5n42nGGsMXBwj0 wX8AoIeWFWxR/8LNMEDXsS0CaTxrdxcP =379y -----END PGP SIGNATURE-----