Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TButton Image no longer shows during runtime (10.2.3)


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Apr 18, 2018 4:49 AM Last Post By: Bart Kindt
Bart Kindt

Posts: 33
Registered: 12/16/07
TButton Image no longer shows during runtime (10.2.3)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 5, 2018 2:06 AM
After I upgraded from Delphi XE7 to 10.2, I find that all my TButton's which are linked to a TImagelist no longer show any Icon! The Icon DOES show at design time.
The problem seems to be with the Themes: My program does NOT use Themes (and for some good reasons).

If I enable Themes, the Icon does show.

How can I make the Icon work again on the TButton when Themes are not enabled? As said, it worked okay under XE7.

Bart

--
---
Bart Kindt
CEO & Developer
SARTrack Limited New Zealand
http://www.sartrack.nz

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TButton Image no longer shows during runtime (10.2.3)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 5, 2018 9:31 AM   in response to: Bart Kindt in response to: Bart Kindt
Bart Kindt wrote:

After I upgraded from Delphi XE7 to 10.2, I find that all my
TButton's which are linked to a TImagelist no longer show any Icon!
The Icon DOES show at design time. The problem seems to be with the
Themes: My program does NOT use Themes (and for some good reasons).

That explains it then, since showing an image on a standard TButton via
an ImageList is a feature of Win32 Visual Styles:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb773175.aspx

How can I make the Icon work again on the TButton when Themes are not
enabled?

You can't. You will have to use TBitBtn or TSpeedButton instead, or a
3rd party button.

As said, it worked okay under XE7.

I doubt that, considering that TButton uses the Win32 BCM_SETIMAGELIST
message to associate the ImageList with the underlying HWND:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb775975.aspx

Note To use this message, you must provide a manifest specifying
Comclt32.dll version 6.0. For more information on manifests, see
Enabling Visual Styles.

The implementation of the TButton.Images property hasn't changed since
it was first added in Delphi 2009 (except for when the
StylusHotImageIndex property was added in Delphi XE).

So, the more likely scenario is that your XE7 project had Win32 Visual
Styles enabled, since that is the only way that the TButton.Images
property would work. Even with VCL Styles enabled (which were added in
XE2), you still need Win32 Visual Styles enabled in order for the
HWND's associated ImageList to operate correctly.

--
Remy Lebeau (TeamB)
Bart Kindt

Posts: 33
Registered: 12/16/07
Re: TButton Image no longer shows during runtime (10.2.3)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 18, 2018 4:49 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thanks Remy,

Only just now found your answer as I no longer get an email notification...

Bart

---
Bart Kindt
CEO & Developer
SARTrack Limited New Zealand
http://www.sartrack.nz

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02