Re: Problem loading .xrc file

Vadim Zeitlin <[email protected]> Wed, 20 Aug 2025 16:56:21 +0200
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
On Wed, 20 Aug 2025 09:11:50 +0100 Tim Burgess wrote:

TB> I've been taking inspiration from the XRC sample, particularly the code for
TB> derived classes, but get the following:
TB> 
TB>  
TB> 
TB> wxWidgets Debug Alert
TB> 
TB> A debugging check in this application has failed.
TB> 
TB> C:\Users\Tim\p\wxWidgets\src\msw\window.cpp(1293): assert "!m_oldWndProc"
TB> failed in wxWindow::SubclassWin(): subclassing window twice? 
TB> 
TB>  
TB> 
TB> When my code executes:
TB> 
TB>  
TB> 
TB> wxXmlResource::Get()->LoadDialog(this, parent, "myDlg");
TB> 
TB>  
TB> 
TB> within the constructor of my derived dialog.

 You need to use the default constructor when using LoadDialog(), as it
creates the window. You must be using the non-default wxDialog ctor which
also does it — resulting in the window being created twice.

 Assert should ideally be more clear, but I'm not sure if it can't happen
in other situations, which would make it misleading to say that it's due to
creating the window twice.

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
              https://www.tt-solutions.com/
signature.asc (application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQQx+vLQdOwioQqkxtoG6kHeT2wehgUCaKXiFQAKCRAG6kHeT2we
hosLAJ9ThnNtgnCe7ioezwAWg0XexNPuFACdGt1WkPM9qO+oTavPfttq7mYKsjY=
=IGW4
-----END PGP SIGNATURE-----