3.1.5: wxButton no longer changes size to fit labels on Windows 10, build 19042

205 views
Skip to first unread message

Randalph

unread,
Apr 23, 2021, 10:35:12 AM4/23/21
to wx-u...@googlegroups.com
I switched from 3.1.3 to 3.1.5, running on Windows 10 build 19042. In both my own code and in the wxWidgets Dialogs sample (Generic dialogs, Modal) buttons are no longer sized to fit the label text. In addition, when I specify wxBU_EXACTFIT the button no longer displays at all. If I switch back to 3.1.3 and rebuild my apps and the wxWidgets sample the buttons once again resize as expected, and display with wxBU_EXACTFIT set.

What I'm wondering is if by any chance I'm doing something wrong with my builds of wxWidgets. I'm using the vc16 solution file. I make three changes to msw\setup.h:

#define wxUSE_COMPILER_TLS 2
#define WXWIN_COMPATIBILITY_3_0 0
#define wxUSE_JOYSTICK            0

Aside from that, I make no changes. I can't think of why any of those settings would affect button sizing.

I do know there's something odd with fonts on my system -- in both 3.1.3 and 3.1.5, most of the time I get an unhelpful return of -1 if I try to launch Font picker, though every once in a while it will suddenly work fine.

Anyways, once I get a chance, I'll step into the wxWidgets code in the debugger -- it looks like there have been several recent changes to button sizing for Windows, so I'll see if I can't spot the problem. In the meantime, I wanted to check to see if anyone else has run into it, and/or has suggestions for workarounds or where to look for the root of the problem.
Message has been deleted

Vadim Zeitlin

unread,
Apr 23, 2021, 5:24:41 PM4/23/21
to wx-u...@googlegroups.com
On Fri, 23 Apr 2021 07:30:59 -0700 Randalph wrote:

R> I switched from 3.1.3 to 3.1.5, running on Windows 10 build 19042. In both
R> my own code and in the wxWidgets Dialogs sample (Generic dialogs, Modal)
R> buttons are no longer sized to fit the label text.

I don't see anything wrong with the buttons in dialog in the sample with
3.1.5, could you please show what do you see in it?

R> In addition, when I specify wxBU_EXACTFIT the button no longer displays
R> at all.

I don't see this in the widgets sample neither, does it happen for you
there?

R> If I switch back to 3.1.3 and rebuild my apps and the wxWidgets sample
R> the buttons once again resize as expected, and display with
R> wxBU_EXACTFIT set.

It would be great if you could please find when exactly did this change,
e.g. by running git-bisect.

R> What I'm wondering is if by any chance I'm doing something wrong with my
R> builds of wxWidgets. I'm using the vc16 solution file. I make three changes
R> to msw\setup.h:
R>
R> #define wxUSE_COMPILER_TLS 2

This is unrelated, but we should make this the default now...

R> #define WXWIN_COMPATIBILITY_3_0 0
R> #define wxUSE_JOYSTICK 0
R>
R> Aside from that, I make no changes. I can't think of why any of those
R> settings would affect button sizing.

Me neither.

R> I do know there's something odd with fonts on my system -- in both 3.1.3
R> and 3.1.5, most of the time I get an unhelpful return of -1 if I try to
R> launch Font picker, though every once in a while it will suddenly work fine.

This is getting curiosier and curiosier... I'd be very interested to know
where does this -1 come from exactly, i.e. which API function exactly fails
for you?

R> Anyways, once I get a chance, I'll step into the wxWidgets code in the
R> debugger -- it looks like there have been several recent changes to button
R> sizing for Windows, so I'll see if I can't spot the problem. In the
R> meantime, I wanted to check to see if anyone else has run into it, and/or
R> has suggestions for workarounds or where to look for the root of the
R> problem.

There are not supposed to be any button sizing regressions in 3.1.5. This
doesn't mean there are none, of course, but I don't see any in my
(admittedly cursory) testing, so any additional information would be very
welcome. Please check if you see any errors about Win32 API functions
failures in the debug output (e.g. just run the program under debugger and
keep an eye on the output window).

Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Randalph

unread,
Apr 24, 2021, 12:31:17 AM4/24/21
to wx-u...@googlegroups.com
3_1_3:
image.png
3_1_5:
image.png

These two screen shots are from the Dialogs->Generic Dialogs-Modal Dialog command from the dialogs sample. I just tested this on a different computer running an older build of Windows 10, and it also exhibited the same problem -- but it's also using a build I created on that computer (same sources, same setup.h modification).

I just tested this again on the dlls that came with the github release -- so these are not the ones that I built -- and the problem exists with those as well. That at least means it's not an issue with my slightly customized build.

I'll start tomorrow running all of this under the debugger and see if I can spot the failure, and if not, I'll follow your suggestion and start working back through the history to see if I can find which change caused the break.


Vadim Zeitlin

unread,
Apr 24, 2021, 5:23:55 AM4/24/21
to wx-u...@googlegroups.com
On Fri, 23 Apr 2021 21:31:04 -0700 Randalph wrote:

R> 3_1_3:
R> image.png
R> 3_1_5:
R> image.png

Thanks, this is definitely wrong, of course, but I just don't see it here.
I forgot to ask: what DPI scaling do you use? Is it the same for both
machines where you observe the problem and do you still see it even with
100% scaling?

Eric Jensen

unread,
Apr 24, 2021, 5:31:52 AM4/24/21
to Vadim Zeitlin
Hello Vadim,

Saturday, April 24, 2021, 11:23:53 AM, you wrote:

VZ> On Fri, 23 Apr 2021 21:31:04 -0700 Randalph wrote:

R>> 3_1_3:
R>> image.png
R>> 3_1_5:
R>> image.png

VZ> Thanks, this is definitely wrong, of course, but I just don't see it here.
VZ> I forgot to ask: what DPI scaling do you use? Is it the same for both
VZ> machines where you observe the problem and do you still see it even with
VZ> 100% scaling?

VZ> Thanks,
VZ> VZ

These Win95 style buttons look like the manifest is missing.

Eric



--

d0

unread,
Apr 24, 2021, 9:08:39 AM4/24/21
to wx-u...@googlegroups.com
Perhaps the fonts problem is connected to this? There's probably a GetTextExtent call somewhere to figure out how large the label is. If this is fails, because the font couldn't be loaded, it would probably explain why all buttons are the default size in your 3_1_5 screenshot.

Cheers, Marian

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to wx-users+u...@googlegroups.com
or visit http://groups.google.com/group/wx-users
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/CAHmEKeq_nXEkYfdS-cA5CqVLvsrVWTR-o1%2BSJ1rqJ1j1exF-MQ%40mail.gmail.com.

Randalph

unread,
Apr 24, 2021, 9:11:51 AM4/24/21
to wx-u...@googlegroups.com
The problem is in msw/anybutton.cpp -- DoGetBestSize() is calling ::SendMessage(GetHwnd(), BCM_GETIDEALSIZE... without checking the return. In my case, the return is FALSE, and size.Set() is called with an invalid (zero) idealSize. If I change that function by moving idealSize outside of the conditional, and add a check for the return from ::SendMessage then the problem goes away:

    SIZE idealSize = { 0, 0 };
    if ( !IsOwnerDrawn() && ShowsLabel() && ::SendMessage(GetHwnd(), BCM_GETIDEALSIZE, 0, (LPARAM)&idealSize))

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+u...@googlegroups.com
or visit http://groups.google.com/group/wx-users
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.

Randalph

unread,
Apr 24, 2021, 9:22:48 AM4/24/21
to wx-u...@googlegroups.com
Just verified that the above change also fixed the problem with setting wxBU_EXACTFIT causing the button not to draw at all.

For reasons not related to this issue, I don't normally use a manifest -- perhaps that is why BCM_GETIDEALSIZE is failing? 

Vadim Zeitlin

unread,
Apr 24, 2021, 10:02:41 AM4/24/21
to wx-u...@googlegroups.com
On Sat, 24 Apr 2021 06:22:35 -0700 Randalph wrote:

R> Just verified that the above change also fixed the problem with setting
R> wxBU_EXACTFIT causing the button not to draw at all.

Thanks for debugging this, the reason for the problem seems pretty clear
now and https://github.com/wxWidgets/wxWidgets/pull/2346 should fix it --
please let me know if you still have any problems with it.

R> For reasons not related to this issue, I don't normally use a manifest --
R> perhaps that is why BCM_GETIDEALSIZE is failing?

Yes, absolutely. And while you definitely should use the manifest (if only
because, as you can see, problems that appear only when not using it are so
easy to overlook...), we still support not using it, so this needs to be
fixed.

Thanks again!

Randalph

unread,
Apr 24, 2021, 2:12:16 PM4/24/21
to wx-u...@googlegroups.com
Fairly moot given your fix, but I did some further testing and just adding a manifest file did not change the problem -- the only time I could get the :SendMessage call to work was when version 6 Visual Style was set. I notice that Visual Studio still creates a new desktop app using version 5 of commctrl giving the 3D buttons, so it requires extra work to switch to version 6 visual style.

Vadim Zeitlin

unread,
Apr 24, 2021, 2:15:31 PM4/24/21
to wx-u...@googlegroups.com
On Sat, 24 Apr 2021 11:12:03 -0700 Randalph wrote:

R> Fairly moot given your fix, but I did some further testing and just adding
R> a manifest file did not change the problem -- the only time I could get the
R> :SendMessage call to work was when version 6 Visual Style was set.

Yes, sorry, "not using a manifest" was a shortcut for "not using a
manifest enabling visual styles". Just adding a manifest not doing anything
was never going to change much, the difference is between the buttons in
comctl32.dll v6 supporting BCM_GETIDEALSIZE and the old implementation in
comctl32.dll v5 not supporting it.

R> I notice that Visual Studio still creates a new desktop app using
R> version 5 of commctrl giving the 3D buttons, so it requires extra work
R> to switch to version 6 visual style.

It really shouldn't require any extra work at all, you just need to
include wx/msw/wx.rc from your own .rc file.

Regards,
Reply all
Reply to author
Forward
0 new messages