wxButton not visible in 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
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

wxButton not visible in Windows

Post by pbneves »

Hi,

Why this code is working in Linux but when compiled in Windows the button is not displayed?
One curious thing is when i click on the space where the button should by displayed it respond to the event (Showing a dialog)?

Code: Select all

void SwbPanel::DoTitle()
{
	wxWindow *parent;

	//Botão de filtro
	if ( m_splitter )
	{
		parent = m_leftWindow;
	}
	else
	{
		parent = this;
	}
	m_btnFiltro = new wxButton(parent, ID_btn_filtros, wxT("Filtros"));
	
	wxBitmap bmpFilter(filter32_xpm, wxBITMAP_TYPE_XPM);
	m_btnFiltro->SetBitmap(bmpFilter, wxTOP);
	m_titleSizer->Add(m_btnFiltro, 0, wxEXPAND);
	
	//Titulo
	m_lblNameSizer = new wxBoxSizer(wxHORIZONTAL);
	wxStaticText *lbl3 = new wxStaticText(parent, wxID_ANY, m_titulo, wxDefaultPosition, wxSize (-1,-1), wxST_ELLIPSIZE_END);
	wxFont font(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
	lbl3->SetForegroundColour(*wxBLUE);
	lbl3->SetFont(font);
	lbl3->SetLabel(m_titulo + m_nomeEmpresa);
	m_lblNameSizer->Add(lbl3, 1, wxALIGN_LEFT | wxALL, 5);
	m_titleSizer->Add(m_lblNameSizer, 1, wxALIGN_LEFT | wxALL, 5);
}
Thanks.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxButton not visible in Windows

Post by ONEEYEMAN »

Hi,
What is the context of this function?
What compiler do you use?
What wx version do you use?
Did you try to run the debugger and see where it fails?

Thank you.
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: wxButton not visible in Windows

Post by pbneves »

ONEEYEMAN wrote: Tue Sep 21, 2021 3:58 pm Hi,
What is the context of this function?
What compiler do you use?
What wx version do you use?
Did you try to run the debugger and see where it fails?

Thank you.
Hi,

This function is used is a family of classes derived from wxPanel where I use it to draw the common widgets of that classes, and the common elements are a button with an image and a wxStatictText with a title.
In Linux I use both GCC and clang with wxWidgets version 3.0.5. In Windows 10 I'm using mingw-64 with wxWidgets version 3.0.4.
This is not a running error where I can trace it with the debugger, but it seems to be a rendering issue.
If I compile the code at Linux the panel will look like
linux.png
linux.png (25.26 KiB) Viewed 5572 times
But when I run the app in Windows, the look of the frame is
Windows1.png
Windows1.png (17.83 KiB) Viewed 5572 times
After clicking the zone where the button should appear (it responds to the event normaly even that it was not displayed correctly) the look of the frame became like
Windows2.png
Windows2.png (16.98 KiB) Viewed 5572 times
Thank you
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxButton not visible in Windows

Post by ONEEYEMAN »

Hi,
Something that you didn't show prevent the button from being displayed.
Start by commenting out some functions on the frame, until it shows.

Thank you.
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: wxButton not visible in Windows

Post by pbneves »

ONEEYEMAN wrote: Wed Sep 22, 2021 12:16 pm Hi,
Something that you didn't show prevent the button from being displayed.
Start by commenting out some functions on the frame, until it shows.

Thank you.
Thank you Oneeyeman, you're right.
Thanks for pointing me the right direction.
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: wxButton not visible in Windows

Post by pbneves »

I'm sorry but I have to came back to this post :(
I've manage to solve some of the problems but there are others that persist.
This code is in one class that is derived. In one of the subclasses all the widgets are in a panel, but in others I need to use a splitter so the panel is the father of the splitter and the widgets are positioned in the splitter windows.
The problem apears to be in this code:

Code: Select all

void SwbPanel::CreateSplitterWidgets()
{
	//spliter
	if ( m_verticalSplitter )
	{
		m_splitter->SplitVertically( m_leftWindow, m_rightWindow, -200 );
	}
	else
	{
		m_splitter->SplitHorizontally( m_leftWindow, m_rightWindow, -200 );
	}

	//Botão de filtro
	DoTitle();
	m_leftMainSizer->Add(m_headerSizer, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxBOTTOM | wxEXPAND, 20 );
	

	//DataView com os dados
	if ( m_dataView != NULL )
	{
		m_dataViewSizer->Add( m_dataView, 1, wxEXPAND );
	}
	m_leftMainSizer->Add(m_dataViewSizer, 1, wxEXPAND);

	
	//Detalhe da transação
	if ( m_documentDetail != NULL )
	{
		m_rightMainSizer->Add(m_documentDetail, 1, wxEXPAND);
	}
	if ( m_transactionDetail != NULL )
	{
		m_rightMainSizer->Add(m_transactionDetail, 1, wxEXPAND);
	}
	
	SetLblNumRegistos();
	m_rightWindow->SetSizer(m_rightMainSizer);
	m_leftWindow->SetSizer(m_leftMainSizer);
	m_mainSizer->Add( m_splitter, 1, wxEXPAND );
	SetSizer(m_mainSizer);
}

void SwbPanel::DoTitle()
{
	wxWindow *parent;

	//Botão de filtro
	if ( m_splitter )
	{
		parent = m_leftWindow;
	}
	else
	{
		parent = this;
	}
	m_btnFiltro = new wxButton(parent, ID_btn_filtros, wxT("Filtros"));
	
	wxBitmap bmpFilter(filter32_xpm, wxBITMAP_TYPE_XPM);
	m_btnFiltro->SetBitmap(bmpFilter, wxTOP);
	
	//Titulo
	m_lblNameSizer = new wxBoxSizer(wxHORIZONTAL);
	wxStaticText *lbl3 = new wxStaticText(parent, wxID_ANY, m_titulo, wxDefaultPosition, wxSize (-1,-1), wxST_ELLIPSIZE_END);
	wxFont font(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
	lbl3->SetForegroundColour(*wxBLUE);
	lbl3->SetFont(font);
	lbl3->SetLabel(m_titulo + m_nomeEmpresa);

	//Nº registos
	m_lblNumRegistos = new wxStaticText(parent, wxID_ANY, wxT("Nº Registos: "));
    
	m_lblNameSizer->Add(lbl3, 1, wxALIGN_LEFT | wxALL, 5);
	m_titleSizer->Add(m_btnFiltro, 0, wxEXPAND);
	m_titleSizer->Add(m_lblNameSizer, 1, wxALIGN_LEFT | wxALL, 5);
	m_headerSizer->Add(m_titleSizer, 0, wxALIGN_LEFT | wxALL | wxEXPAND, 5);
	m_headerSizer->Add(m_lblNumRegistos, 0, wxALIGN_LEFT | wxLEFT, 5);
}
The lbl3, m_lblNumRegistos and the m_btnFiltro are all in the same sizer so why only the button is not displayed? And why is displayed when I compile the code on Linux and not on Windows?
I've found the problem on the subclass not using splitter, but on this one it is driving me nuts!
Any help will be appreciated.
Thanks,
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxButton not visible in Windows

Post by doublemax »

Usually you get that kind of error if the button and the panel it's on top of are siblings instead of parent and child. And the difference in behavior between Linux and Windows would be the different order in which controls are painted.

But i don't see that in your code, and i don't see any other obvious mistake either. And as sizer code is always a little hard to follow, i'd need a minimal, but complete and compilable sample to try it out myself. For that you should delete everything that's not necessary to create the error.
Use the source, Luke!
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: wxButton not visible in Windows

Post by pbneves »

Thank you doublemax.
I'm working in a such sample to post.
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: wxButton not visible in Windows

Post by pbneves »

doublemax wrote: Fri Oct 01, 2021 2:05 pm Usually you get that kind of error if the button and the panel it's on top of are siblings instead of parent and child. And the difference in behavior between Linux and Windows would be the different order in which controls are painted.

But i don't see that in your code, and i don't see any other obvious mistake either. And as sizer code is always a little hard to follow, i'd need a minimal, but complete and compilable sample to try it out myself. For that you should delete everything that's not necessary to create the error.
Doublemax, here it is a minimal sample as you requested.
Thanks.
Attachments
buttonErr.7z
(8.44 KiB) Downloaded 81 times
User avatar
doublemax@work
Super wx Problem Solver
Super wx Problem Solver
Posts: 474
Joined: Wed Jul 29, 2020 6:06 pm
Location: NRW, Germany

Re: wxButton not visible in Windows

Post by doublemax@work »

Works fine for me under Windows.

However, i used wxWidgets 3.1.5 with Visual Studio. I don't think the compiler matters, but the wxWidgets version may. Can you try with 3.1.5?

SnapShot_211004_145423.png
SnapShot_211004_145423.png (10.75 KiB) Viewed 5013 times
User avatar
doublemax@work
Super wx Problem Solver
Super wx Problem Solver
Posts: 474
Joined: Wed Jul 29, 2020 6:06 pm
Location: NRW, Germany

Re: wxButton not visible in Windows

Post by doublemax@work »

I took another look at the screenshots in your first post and it seems that the executable doesn't have a manifest.

I don't know how to add that when using MinGW, but i'm sure Google will find something. I'm almost certain this will solve the issue.
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: wxButton not visible in Windows

Post by pbneves »

doublemax@work wrote: Mon Oct 04, 2021 12:55 pm Works fine for me under Windows.

However, i used wxWidgets 3.1.5 with Visual Studio. I don't think the compiler matters, but the wxWidgets version may. Can you try with 3.1.5?


SnapShot_211004_145423.png
I develop mainly in Manjaro Linux where 3.1.5 is not an option :( and windows is only a form of share my app.
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: wxButton not visible in Windows

Post by pbneves »

doublemax@work wrote: Mon Oct 04, 2021 1:14 pm I took another look at the screenshots in your first post and it seems that the executable doesn't have a manifest.

I don't know how to add that when using MinGW, but i'm sure Google will find something. I'm almost certain this will solve the issue.
I don't know about manifest, so I'll search about it.
Thanks for the clue and I will give some feedback.
User avatar
doublemax@work
Super wx Problem Solver
Super wx Problem Solver
Posts: 474
Joined: Wed Jul 29, 2020 6:06 pm
Location: NRW, Germany

Re: wxButton not visible in Windows

Post by doublemax@work »

I just tested with wx 3.0.5 under Windows and it looked fine, too. It's most likely the missing manifest.
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: wxButton not visible in Windows

Post by pbneves »

Thank you, once more, doublemax.
You're absolutely wright. Adding a resource file solved the problem.
I've used the samples.rc file available with the samples and in Codelite all that is needed is to add this file to the project.
Post Reply