Support Forums > WinFBX - Windows Framework for FreeBASIC

CXpButton

<< < (2/12) > >>

Josť Roca:
Tip:

To solve the problem of different icon sizes depending of the DPI setting, you could add fields in the property list for the wanted width and height of the icon and, in the generated code, use:


--- Code: ---pXpButton.SetImageSize pWindow.ScaleX(width), pWindow.ScaleY(height)

--- End code ---

This way, the icon will we draw with the same relative size.

Paul Squires:

--- Quote from: Josť Roca on June 16, 2018, 12:44:11 PM ---Tip:

To solve the problem of different icon sizes depending of the DPI setting, you could add fields in the property list for the wanted width and height of the icon and, in the generated code, use:


--- Code: ---pXpButton.SetImageSize pWindow.ScaleX(width), pWindow.ScaleY(height)

--- End code ---

This way, the icon will we draw with the same relative size.


--- End quote ---
Sounds good. I will have those settings in the designer for sure. How about icon transparency... for example, when you use your gdi functions to load a png from the resource file and convert them to icon format would we lose and background transparency? Could, say, the topmost left pixel become the color used for transparency? It would be very versatile if you can load images of any type from the resource file and display in the button such that it blends nicely with whatever color the button is currently using as a background.

Josť Roca:
PNG icons support transparency. Therefore you only need to use SetImageFromFile or SetImageFromRes. Nothing else. Gone are the times of bitmaps with a pink background :)

They also support the alpha channel.

Josť Roca:
What I can't get is to change the background color permanently. Since the control is not ownerdraw, it does not receive the WM_CTLCOLORBTN message and Windows reverts to the system colors as soon at it processes DefWindowProcW. You may need a different control.

I will add the new SetImage functions to the original CXpButton as an improvement.

Paul Squires:
Would forcing a setting where the control does not check for m_bIsThemed (basically set it be false) and then set properties to replace calls like GetSysColorBrush(COLOR_BTNFACE) to our own defined colors. Basically, ensure that the control draws using the GDI sections of the CXpButton.UxDrawPushButton function rather than the theme portions? Would that work?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version