wxNotebook not shown on Windows. Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
denormal
In need of some credit
In need of some credit
Posts: 2
Joined: Sun Apr 21, 2019 2:20 pm

wxNotebook not shown on Windows.

Post by denormal »

The code works on Linux (Debian) but on Windows no notebook control is shown, just a blank background. I've tried to simplify the problem by adding an example from the wiki to my 'register_book_ctrl' class which displays on Debian but not Windows.

Code: Select all

register_book_ctrl::register_book_ctrl(wxWindow* parent, std::shared_ptr<sys_thread> sys) : 
		wxWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS|wxBORDER_SIMPLE)
{
	wxNotebook* myNotebook = new wxNotebook(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_MULTILINE);
	wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
	sizer->Add(myNotebook, 1, wxEXPAND | wxALL, 0);

	myNotebook->AddPage(new wxNotebookPage(myNotebook, -1), L"TEST RECOMMENDATIONS 1");
	myNotebook->AddPage(new wxNotebookPage(myNotebook, -1), L"TEST RECOMMENDATIONS 2");
	myNotebook->AddPage(new wxNotebookPage(myNotebook, -1), L"TEST RECOMMENDATIONS 3");
	myNotebook->AddPage(new wxNotebookPage(myNotebook, -1), L"TEST RECOMMENDATIONS 4");
	myNotebook->AddPage(new wxNotebookPage(myNotebook, -1), L"TEST RECOMMENDATIONS 5");
	myNotebook->AddPage(new wxNotebookPage(myNotebook, -1), L"TEST RECOMMENDATIONS 6");
	myNotebook->Layout();

	sizer->Layout();
	SetSizer(sizer);
	Centre(wxBOTH);
}
The parent wxWindow passed is actually a panel. The code that creates it is part of the constructor of a wxFrame.

Code: Select all

cpu_debugger::cpu_debugger(std::shared_ptr<sys_thread> sys, const wxSize& size) : 
		wxFrame(NULL, wxID_ANY, L"Debugger", wxDefaultPosition,size,wxRESIZE_BORDER|wxCLOSE_BOX|wxCAPTION|wxSYSTEM_MENU), 
		m_sys_thread(sys)
{
	init_command_map();

	init_sys_thread_handlers();

	m_sys_thread->enable_instruction_breakpoints(true);

	this->SetSizeHints(wxDefaultSize, wxDefaultSize);

	wxPanel* panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("panel"));

	m_main_sizer = new wxBoxSizer(wxVERTICAL);

	wxBoxSizer* main_vertical_0;
	{
		main_vertical_0 = new wxBoxSizer(wxHORIZONTAL);

		m_cpu_regs_book_ctrl = new register_book_ctrl(panel, sys);
		main_vertical_0->Add(m_cpu_regs_book_ctrl, 3, wxEXPAND | wxALL, 0);

		m_cpu_disasm_ctrl = new disasm_view_ctrl(panel, sys);
		main_vertical_0->Add(m_cpu_disasm_ctrl, 5, wxEXPAND | wxALL, 0);

		m_main_sizer->Add(main_vertical_0, 5, wxEXPAND, 5);
	}

	wxBoxSizer* main_vertical_1;
	{
		main_vertical_1 = new wxBoxSizer(wxHORIZONTAL);

		m_memory_view_ctrl = new memory_view_ctrl(panel, sys);
		main_vertical_1->Add(m_memory_view_ctrl, 1, wxEXPAND, 0);

		m_main_sizer->Add(main_vertical_1, 3, wxEXPAND, 5);		
	}

	wxFlexGridSizer* main_vertical_bottom;
	{
		main_vertical_bottom = new wxFlexGridSizer(0, 2, 0, 0 );
		main_vertical_bottom->AddGrowableCol(0);
		main_vertical_bottom->SetFlexibleDirection(wxBOTH);
		main_vertical_bottom->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);

		m_cmd_text_ctrl = new command_text_ctrl(panel, this);
		main_vertical_bottom->Add(m_cmd_text_ctrl, 0, wxALL|wxEXPAND, 5);

		m_cmd_enter = new wxButton(panel, wxID_ANY, wxT("Enter"), wxDefaultPosition, wxDefaultSize, 0);
		main_vertical_bottom->Add(m_cmd_enter, 0, wxALL, 5 );

		m_main_sizer->Add(main_vertical_bottom, 1, wxALL|wxEXPAND, 0);
	}

	panel->SetSizer(m_main_sizer);
	panel->Layout();

	panel->Centre(wxBOTH);
}
The WxWidgets notebook sample works just fine and i will continue investigating but i'm at a loss here.
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: wxNotebook not shown on Windows.

Post by catalin »

The parent of the notebook must be 'this', not 'parent'.
denormal
In need of some credit
In need of some credit
Posts: 2
Joined: Sun Apr 21, 2019 2:20 pm

Re: wxNotebook not shown on Windows.

Post by denormal »

catalin wrote: Sun Apr 21, 2019 6:14 pm The parent of the notebook must be 'this', not 'parent'.
That was it! Thank you.
Post Reply