[wxMSW], [wx3.1.1], This problem drove me mad, (wxButton, uxTheme, manifest) !!

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
tomay3000
Earned some good credits
Earned some good credits
Posts: 132
Joined: Mon Apr 24, 2017 4:23 am

[wxMSW], [wx3.1.1], This problem drove me mad, (wxButton, uxTheme, manifest) !!

Post by tomay3000 » Thu Nov 22, 2018 1:37 am

Hello,
I tried to apply a skin (Codejock Skin Framework) to a wxWidgets application using a Simple dll, and it worked without problems until I tried to add some wxButtons with icons loaded from resource to the application, then I noticed the button is drawing expanded and without the icon on it.
When I remove the skin from loading in the application initialization it works without issues.
And if I don't assign the button an icon it works without issues also.

The attached screenshots illustrates this.
Untitled.jpg
Untitled.jpg (33.28 KiB) Viewed 392 times
Untitled 2.jpg
Untitled 2.jpg (14.23 KiB) Viewed 392 times
Untitled 3.jpg
Untitled 3.jpg (12.19 KiB) Viewed 378 times
What could be the cause of the problem ?

I must have the skin framework in the application.

Thank you for your understanding.
Last edited by tomay3000 on Thu Nov 22, 2018 11:14 am, edited 1 time in total.

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

Re: [wxMSW], [wx3.1.1], This problem drove me mad, (wxButton, uxTheme, manifest) !!

Post by doublemax » Thu Nov 22, 2018 11:03 am

Labeling the screenshots would have been helpful...

I assume:
1) wxButton with bitmap, without the theme DLL
2) the same with theme DLL
3) wxButton without bitmap, with theme DLL

I have no explanation for the stretched button in #2 (is it in a sizer? Maybe the best-size calculation fails)

But when you add a bitmap to a button, it will become "userdrawn" internally and i guess this interferes with the theme DLL.

As the theme DLL probably only works with 100% custom controls, I don't think there is a solution for this.
Use the source, Luke!

tomay3000
Earned some good credits
Earned some good credits
Posts: 132
Joined: Mon Apr 24, 2017 4:23 am

Re: [wxMSW], [wx3.1.1], This problem drove me mad, (wxButton, uxTheme, manifest) !!

Post by tomay3000 » Thu Nov 22, 2018 12:02 pm

doublemax wrote: Labeling the screenshots would have been helpful...
Sorry for that. #-o
doublemax wrote: I assume:
1) wxButton with bitmap, without the theme DLL
2) the same with theme DLL
3) wxButton without bitmap, with theme DLL
Your assumption is correct. =D>
doublemax wrote: I have no explanation for the stretched button in #2
Me neither I have now idea.
doublemax wrote: (is it in a sizer? Maybe the best-size calculation fails)
Yes it is in a sizer. a wxBoxSizer in a wxPanel.
doublemax wrote: But when you add a bitmap to a button, it will become "userdrawn" internally and i guess this interferes with the theme DLL.
AH! interference, I am afraid of this.
doublemax wrote: As the theme DLL probably only works with 100% custom controls, I don't think there is a solution for this.
There should be a workaround, Either I use the button without the bitmap and the theme DLL, OR the button with the bitmap and without the theme DLL.
But I want both the button with the bitmap and the theme DLL :mrgreen:
Either I override wxButton drawing and I delay the bitmap drawing to the end (which I haven't tried), or there is something I don't catch here.

This is all because the wxWidgets Creators / Developers / Maintainers did not count the possibility of using a theme DLL when they designed wxButton to have a bitmap in it and use userdrawn incorrectly. :!:

Do you have any hint on how I can make it possible ?

Thank you for your understanding.

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

Re: [wxMSW], [wx3.1.1], This problem drove me mad, (wxButton, uxTheme, manifest) !!

Post by doublemax » Thu Nov 22, 2018 1:50 pm

This is all because the wxWidgets Creators / Developers / Maintainers did not count the possibility of using a theme DLL when they designed wxButton to have a bitmap in it and use userdrawn incorrectly.
In their defense, that's a very rare requirement and on top of that, i'm not even sure what could be done about it.

I can only suggest to ask in the wx-users group where you can reach the wx developers. This here is a user forum. https://groups.google.com/forum/?hl=en& ... m/wx-users

Asking the creator of the theme DLL might also be worth a try.
Use the source, Luke!

tomay3000
Earned some good credits
Earned some good credits
Posts: 132
Joined: Mon Apr 24, 2017 4:23 am

Re: [wxMSW], [wx3.1.1], This problem drove me mad, (wxButton, uxTheme, manifest) !!

Post by tomay3000 » Thu Nov 22, 2018 4:30 pm

Thank you, I will try to do my best to make it possible.

tomay3000
Earned some good credits
Earned some good credits
Posts: 132
Joined: Mon Apr 24, 2017 4:23 am

Re: [wxMSW], [wx3.1.1], This problem drove me mad, (wxButton, uxTheme, manifest) !!

Post by tomay3000 » Sun Dec 02, 2018 5:10 am

I found the origin of the problem:
There were never a check of the return value of the GetThemeMargins() API, which in my case it was not returning S_OK, and therefore the pMargins struct members contained invalid values of the theme margins that caused that drawing behavior.

I have made a pull request in github to fix this, https://github.com/wxWidgets/wxWidgets/pull/1036.

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

Re: [wxMSW], [wx3.1.1], This problem drove me mad, (wxButton, uxTheme, manifest) !!

Post by doublemax » Sun Dec 02, 2018 3:02 pm

Interesting. Thanks for the feedback.
Use the source, Luke!

Post Reply