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
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

wxFrame maximize bug

Post by Ronald » Sat Dec 15, 2018 6:51 am

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: 13127
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFrame maximize bug

Post by doublemax » Sat Dec 15, 2018 9:52 am

Which platform? I can't reproduce this under Windows.
Use the source, Luke!

Ronald
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

Re: wxFrame maximize bug

Post by Ronald » Sat Dec 15, 2018 4:40 pm

doublemax wrote:Which platform?
Windows 10 Pro N AMD64

Ronald
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

Re: wxFrame maximize bug

Post by Ronald » Tue Dec 18, 2018 5:13 am

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: 13127
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFrame maximize bug

Post by doublemax » Tue Dec 18, 2018 10:08 am

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
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

Re: wxFrame maximize bug

Post by Ronald » Tue Dec 18, 2018 11:54 am

doublemax wrote: What happens if you explicitly call Maximize()?
no problem when call Maximize either before or after or without Centre(wxBOTH)

Nunki
I live to help wx-kind
I live to help wx-kind
Posts: 191
Joined: Fri Sep 14, 2012 8:26 am
Location: Kontich, Belgium
Contact:

Re: wxFrame maximize bug

Post by Nunki » Sat Jan 12, 2019 2:13 pm

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: 13127
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFrame maximize bug

Post by doublemax » Sat Jan 12, 2019 2:25 pm

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
Earned a small fee
Earned a small fee
Posts: 24
Joined: Fri Nov 09, 2018 9:11 pm

Re: wxFrame maximize bug

Post by rando » Tue Jan 15, 2019 9:25 pm

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.

Post Reply