Problem loading .xrc file

52 views
Skip to first unread message

Tim Burgess

unread,
Aug 20, 2025, 4:11:56 AMAug 20
to wx-u...@googlegroups.com

Hi,

 

I’ve been taking inspiration from the XRC sample, particularly the code for derived classes, but get the following:

 

wxWidgets Debug Alert

A debugging check in this application has failed.

C:\Users\Tim\p\wxWidgets\src\msw\window.cpp(1293): assert "!m_oldWndProc" failed in wxWindow::SubclassWin(): subclassing window twice?

 

When my code executes:

 

wxXmlResource::Get()->LoadDialog(this, parent, "myDlg");

 

within the constructor of my derived dialog.

 

Googling this message and some variations on it didn’t give me any hits to help me understand the issue.

 

I’d be grateful for any advice as to how to tackle this.

 

Best wishes.

 

Tim

 

Vadim Zeitlin

unread,
Aug 20, 2025, 10:56:30 AMAug 20
to wx-u...@googlegroups.com
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/

Quentin Cosendey

unread,
Aug 21, 2025, 12:26:51 AMAug 21
to wx-u...@googlegroups.com
Hello,

I have quite a simple and classic dialog box with text fields,
checkboxes and buttons. Everything works as expected as long as the app
is in light or unspecified appearance mode.
However, when the app is in dark mode, checkboxes are notified as
buttons by screen readers (Jaws and NVDA), and their state checked or
unchecked isn't announced. They continue to work properly, i.e. the
state correctly switches when clicking or pressing space, but they keep
being indicated as buttons without state. So screen reader users can no
longer know that they are checkboxes, and if they are checked or not.

Am I missing something ? Should I do something special for dark mode ?
Is that a limitation of dark mode ? Or this is just a bug ?

I'm using WXWidgets developement / master branch, last updated about
10-15 days ago, on Windows 11.
There was no problem with version 3.2.

I activate dark mode with:
SetAppearance(Appearance::Dark);
in wxApp::OnInit, according to user configuration.

My dialog box is pretty simple, some example code:

ConnectDialog::ConnectDialog (App& app0):
wxDialog(nullptr, wxID_ANY,
U(translate("connTitle")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE),
app(app0)
{
auto usernameLabel = new wxStaticText(this, wxID_ANY,
U(translate("login")));
username = new wxTextCtrl(this, ID_USERNAME, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0);
auto passwordLabel = new wxStaticText(this, wxID_ANY,
U(translate("password")));
password = new wxTextCtrl(this, ID_PASSWORD, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
rememberMe = new wxCheckBox(this, ID_REMEMBERME,
U(translate("rememberpassword")));
autologin = new wxCheckBox(this, ID_AUTOLOGIN,
U(translate("useAutoLogin")));
auto connectBtn = new wxButton(this, wxID_OK, U(translate("connection")));

...

auto dlgSizer = new wxFlexGridSizer(2, 5, 5);
dlgSizer->Add(usernameLabel, 0);
dlgSizer->Add(username, 0, wxEXPAND);
dlgSizer->Add(passwordLabel, 0);
dlgSizer->Add(password, 0, wxEXPAND);
dlgSizer->Add(new wxStaticText(this, wxID_ANY, wxEmptyString), 0);
dlgSizer->Add(rememberMe, 0, wxEXPAND);
dlgSizer->Add(new wxStaticText(this, wxID_ANY, wxEmptyString), 0);
dlgSizer->Add(autologin, 0, wxEXPAND);
dlgSizer->Add(connectBtn, 0);

...

SetSizerAndFit(dlgSizer);

username->SetFocus();
}


Thank you for your help.


P.S. Sorry if you get this message multiple times. It seems that it
didn't go through on previous attempt.

timbu...@gmail.com

unread,
Aug 21, 2025, 5:16:22 AMAug 21
to wx-u...@googlegroups.com
OK, got it.

Many thanks for the clarification.

All the best.

Tim


-----Original Message-----
From: wx-u...@googlegroups.com <wx-u...@googlegroups.com> On Behalf Of Vadim Zeitlin
Sent: 20 August 2025 15:56
To: wx-u...@googlegroups.com
Subject: Re: Problem loading .xrc file

On Wed, 20 Aug 2025 09:11:50 +0100 Tim Burgess wrote:

TB> I've been taking inspiration from the XRC sample, particularly the
TB> code for derived classes, but get the following:

Quentin Cosendey

unread,
Aug 21, 2025, 3:52:37 PMAug 21
to wx-u...@googlegroups.com
Hello,

I have quite a simple and classic dialog box with text fields,
checkboxes and buttons. Everything works as expected as long as the app
is in light or unspecified appearance mode.
However, when the app is in dark mode, checkboxes are notified as
buttons by screen readers (Jaws and NVDA), and their state checked or
unchecked isn't announced. They continue to work properly, i.e. the
state correctly switches when clicking or pressing space, but they keep
being indicated as buttons without state. So screen reader users can no
longer know that they are checkboxes, and if they are checked or not.

Am I missing something ? Is that a limitation of dark mode ? Or this is
just a bug ?

I'm using WXWidgets developement / master branch, last updated about
10-15 days ago, on Windows 11.
There was no problem with version 3.2.

I activate dark mode with:
SetAppearance(Appearance::Dark);
in wxApp::OnInit, according to user configuration.

My dialog box is pretty simple, some example code:

MyDialog::MyDialog (App& app0):
wxDialog(nullptr, wxID_ANY,
U(translate("MyDialogTitle")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE),
app(app0)
{
auto label1 = new wxStaticText(this, wxID_ANY, U(translate("label1")));
field1 = new wxTextCtrl(this, ID_FIELD1, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0);
auto label2 = new wxStaticText(this, wxID_ANY, U(translate("label2")));
field2 = new wxTextCtrl(this, ID_FIELD2, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0);
checkbox1 = new wxCheckBox(this, ID_CHECKBOX1, U(translate("checkbox1")));
checkbox2 = new wxCheckBox(this, ID_CHECKBOX2, U(translate("checkbox2")));
auto okBtn = new wxButton(this, wxID_OK, U(translate("Continue")));

...

auto dlgSizer = new wxFlexGridSizer(2, 5, 5);
dlgSizer->Add(label1, 0);
dlgSizer->Add(field1, 0, wxEXPAND);
dlgSizer->Add(label2, 0);
dlgSizer->Add(field2, 0, wxEXPAND);
dlgSizer->Add(new wxStaticText(this, wxID_ANY, wxEmptyString), 0);
dlgSizer->Add(checkbox1, 0, wxEXPAND);
dlgSizer->Add(new wxStaticText(this, wxID_ANY, wxEmptyString), 0);
dlgSizer->Add(checkbox2, 0, wxEXPAND);
dlgSizer->Add(okBtn, 0);

...

SetSizerAndFit(dlgSizer);

...

Tim Burgess

unread,
Aug 26, 2025, 9:31:02 AMAug 26
to wx-u...@googlegroups.com
Hi,

I now have this solved - thanks.

However, I have another issue based around my lack of understanding of how the cusclass.* files work with the XRC demo.

In cusclass.xrc there is:

<object class="unknown" name="custom_control_placeholder">

I understand that this is to provide a space where an object of a custom class can be inserted. What I don't understand is how the c++ code decides to insert a particular custom class into this space, as nothing in the c++ code references either "unknown" or " custom_control_placeholder ".

In my own code I have custom classes derived from wxPane for each page of a wxNotebook and the cusclass example requires me to:

1 - Insert something like:
wxDECLARE_DYNAMIC_CLASS(Page1Class);

into the top of each of my custom class definitions.

2 - Insert lines like:

wxIMPLEMENT_DYNAMIC_CLASS(Page1Class, wxPanel);

for each of my custom classes.

3 - Modify the constructors of each of my custom classes to reflect the default constructor for wxPane.

I suppose I could just about accept that all of this within cusclass performs some sort of magic to bind any object with a class "unknown" to the provided MyResizableListCtrl class, but that wouldn't provide a mechanism to handle multiple custom classes.

I know I'm missing something, but just can't spot it.

Help!

Tim



-----Original Message-----
From: wx-u...@googlegroups.com <wx-u...@googlegroups.com> On Behalf Of Vadim Zeitlin
Sent: 20 August 2025 15:56
To: wx-u...@googlegroups.com
Subject: Re: Problem loading .xrc file

On Wed, 20 Aug 2025 09:11:50 +0100 Tim Burgess wrote:

TB> I've been taking inspiration from the XRC sample, particularly the
TB> code for derived classes, but get the following:
which provides a space to insert an object of a custom class. However, I don't see "unknown" or ""

Vadim Zeitlin

unread,
Aug 26, 2025, 7:40:55 PMAug 26
to wx-u...@googlegroups.com
On Tue, 26 Aug 2025 14:30:51 +0100 Tim Burgess wrote:

TB> In cusclass.xrc there is:
TB>
TB> <object class="unknown" name="custom_control_placeholder">
TB>
TB> I understand that this is to provide a space where an object of a custom class can be inserted. What I don't understand is how the c++ code decides to insert a particular custom class into this space, as nothing in the c++ code references either "unknown" or " custom_control_placeholder ".

C++ definitely does reference it using AttachUnknownControl(), see the code in samples/xrc/myframe.cpp.
Reply all
Reply to author
Forward
0 new messages