Huge wxButtons in high DPI mode

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
User avatar
Qbort
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 07, 2019 8:38 pm

Huge wxButtons in high DPI mode

Post by Qbort » Thu Oct 10, 2019 5:03 pm

Hello,

I am exploring use of wxwidgets for high DPI monitors and have just found something which I'm not sure if is a bug or my poor coding. Should I report it as a bug or am I doing something wrong?

When compiling the below code with "High DPI awareness", I see two huge buttons (the size of the button in far exceeds the size of the text inside it):
highDPIawareness.png
highDPIawareness.png (4.75 KiB) Viewed 116 times
By comparison, when compiling without the "High DPI awareness" in the manifest, the buttons appear correctly sized for the display, but are blurry (also note the screen size is double):
noDPIawareness.png
noDPIawareness.png (7.89 KiB) Viewed 116 times
Code:

Code: Select all

#include "wx/wx.h"

class cApp : public wxApp
{
public:
	virtual bool OnInit();
};

wxIMPLEMENT_APP(cApp);

bool cApp::OnInit()
{
	wxFrame* frame = new wxFrame(nullptr, wxID_ANY, "Massive buttons?!", wxPoint(30, 30), wxSize(400,300));
	wxSizer* sz = new wxBoxSizer(wxVERTICAL);
	wxButton* butTop = new wxButton(frame, wxID_ANY,"test");
	wxButton* butTop1 = new wxButton(frame, wxID_ANY, "test1");

	sz->Add(butTop);
	sz->Add(butTop1);

	frame->SetSizer(sz);
	frame->Show();

	return true;
}
Details of my setup:
wxWidgets Version: GIT Master branch (as of 7th October 2019)
IDE/Compiler: Microsoft Visual Studio 2019
Platform: Windows 10

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2057
Joined: Sun Jan 03, 2010 5:45 pm

Re: Huge wxButtons in high DPI mode

Post by PB » Thu Oct 10, 2019 6:12 pm

I cannot confirm that
notmassivebuttons.png
notmassivebuttons.png (3.52 KiB) Viewed 105 times

wxWidgets: freshly checked out (9e8352b)
Win 10: 1903 (build 18362.388)
exe built with MSVS 2019, DPI Awareness set to High DPI aware
Resolution: 2560x1440, scaling at 125 %

Can you check out with today's master? I have been used a couple days old ones and did not notice any issues though.

EDIT
The buttons are actually larger then they should be. When you <Ctrl>+<Alt>+<Mouse Middleclick> the empty frame space, you get to see wxWidgets about dialog where the OK button is much less tall.

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

Re: Huge wxButtons in high DPI mode

Post by doublemax » Thu Oct 10, 2019 6:19 pm

I assume you were testing at 200% scaling?

I agree that the buttons are too big. I tested with 100 and 150%. At 100% the button gets a size of 88x26.
At 150% it should get around 132x39, but it gets 188x66 instead.
Use the source, Luke!

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2057
Joined: Sun Jan 03, 2010 5:45 pm

Re: Huge wxButtons in high DPI mode

Post by PB » Thu Oct 10, 2019 6:24 pm

doublemax, will you report it or should I?

I think this was introduced with changes related to Per Monitor V2 DPI Awareness.

EDIT
I have dual screen setup where my primary screen is at 125% while the other one is at default 100%. The size of the buttons also depends on which screen is the executable launched from, even when its main window always shows on the primary screen.

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

Re: Huge wxButtons in high DPI mode

Post by doublemax » Thu Oct 10, 2019 6:33 pm

@PB, please do report it.
Use the source, Luke!

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2057
Joined: Sun Jan 03, 2010 5:45 pm

Re: Huge wxButtons in high DPI mode

Post by PB » Thu Oct 10, 2019 6:54 pm


User avatar
Qbort
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 07, 2019 8:38 pm

Re: Huge wxButtons in high DPI mode

Post by Qbort » Thu Oct 10, 2019 8:09 pm

HI both,

Thank you for such quick replies! (And apologies for my slow response).

Yes, it was tested at 200% scaling. Thanks for creating the bug report.

Qbort.

Post Reply