wxFrame maximize bug

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

wxFrame maximize bug

Post by Ronald »

Code: Select all

MainFrame * main_frame = new MainFrame(nullptr, wxID_ANY, L"Title", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxMAXIMIZE);
main_frame->Show();
The frame itself shows as maximized, but with offsets (at least 5 pixels) to the left and top.

wxWidgets 3.1.2

BTW, no this bug in wxWidgets 3.1.1
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFrame maximize bug

Post by doublemax »

Which platform? I can't reproduce this under Windows.
Use the source, Luke!
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: wxFrame maximize bug

Post by Ronald »

doublemax wrote:Which platform?
Windows 10 Pro N AMD64
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: wxFrame maximize bug

Post by Ronald »

doublemax wrote:I can't reproduce this under Windows.

Code: Select all

bool TheApp::OnInit()
{
	wxFrame * main_frame = new wxFrame(nullptr, wxID_ANY, L"TheApp", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxMAXIMIZE);
	main_frame->Centre(wxBOTH); // this line causes the problem
	main_frame->Show();
	return true;
}
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFrame maximize bug

Post by doublemax »

Strangely enough, when i test this under Windows 10 (was using 7 before), the wxMAXIMIZE flag is completely ignored.

What happens if you explicitly call Maximize()?
Use the source, Luke!
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: wxFrame maximize bug

Post by Ronald »

doublemax wrote: What happens if you explicitly call Maximize()?
no problem when call Maximize either before or after or without Centre(wxBOTH)
Nunki
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 235
Joined: Fri Sep 14, 2012 8:26 am
Location: Kontich, Belgium
Contact:

Re: wxFrame maximize bug

Post by Nunki »

Hi Guys,

If I may add to the confusion... recently we stumbled upon a similar problem. My application likes to store its position and size in an xml file when closing the application. So I can restart the application restoring the same location and size when you last left the application. That works fine, when I maximize the applications main window (MDI application) it works fine too. But when I restart the application the size of the window is too big, some 15 pixels (lines) of the bottom are now obscured behind the taskbar. Re-applying the maximize button, restores all back to normal.
So something's off somehow in reporting the size of a window when maximized. Now I stumbled upon the fact that when you right click on the taskbar (Win10 pro) and you uncheck the 'lock all taskbars' feature, the problem disappears and all works fine. So either this is a bug in windows or somewhere in wxWidgets (somewhere deep I assume).

Hope this shines some extra light on this matter.

regards,
Nunki
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFrame maximize bug

Post by doublemax »

Regardless of if there's a bug somewhere, you shouldn't store the maximized size of a window. You should only store the un-maximized size and a "maximized" flag separately. Otherwise the you (and the user) lose the information of the unmaximized size (the size the window gets when the user un-maximized it).
Use the source, Luke!
rando
Knows some wx things
Knows some wx things
Posts: 35
Joined: Fri Nov 09, 2018 9:11 pm

Re: wxFrame maximize bug

Post by rando »

Code: Select all

bool TheApp::OnInit()
{
	wxFrame * main_frame = new wxFrame(nullptr, wxID_ANY, L"TheApp", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxMAXIMIZE);
	main_frame->Centre(wxBOTH); // this line causes the problem
	main_frame->Show();
	return true;
}
You don't need to (shouldn't ?) call Centre() on a maximized window. I'm guessing something in the Center() code is confused when it tries to compute the offsets to center a maximized window.
Mick P.
Earned some good credits
Earned some good credits
Posts: 145
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: wxFrame maximize bug

Post by Mick P. »

[DELETING: See next post, oops.]
Last edited by Mick P. on Thu Sep 05, 2019 6:06 pm, edited 1 time in total.
Mick P.
Earned some good credits
Earned some good credits
Posts: 145
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: wxFrame maximize bug

Post by Mick P. »

Okay, I figured out the problem, that might be the same as the OP's.

I noticed when testing that the window for split second would sometimes be maximized (depending on timing) but then get kicked out.

What is required is inside any window sizing events you have to test IsMaximized and change the behavior to not do anything, because changing the size kicks it out of maximized state. In hindsight it seems obvious, but you wouldn't think of it. Both cases where my events change the size from inside the sizing events were hacks to workaround other quirks.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxFrame maximize bug

Post by ONEEYEMAN »

Hi,
Care to post some code?

Thank you.
Mick P.
Earned some good credits
Earned some good credits
Posts: 145
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: wxFrame maximize bug

Post by Mick P. »

ONEEYEMAN wrote: Fri Sep 06, 2019 3:04 pm Hi,
Care to post some code?

Thank you.
if(!frame.IsMaximized())
{
//do...
}
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxFrame maximize bug

Post by ONEEYEMAN »

Hi,
And how the call to IsMaximised () related to Maximise () problem this thread is about?

Thank you.
Post Reply