3

I created the manifest file for my Delphi 6 application so it can display controls according to the theme defined by Windows (controls 6.0). Everything looks fine, except TBitBtn component, which is displayed using the legacy theme:

Legacy TBitBtn

The behavior is the same on Windows XP and Windows 7, regardless of the current theme, even when no image is assigned to the TBitBtn component.

Now, when I put a regular TButton component on a form, it displays OK. If I then programmatically set an image to this button in runtime (using SendMessage(Handle, BM_SETIMAGE, IMAGE_ICON, LPARAM(Icon))), it immediately reverts its style to the legacy one.

Is there a way to either make TBitBtn use a proper style, or to display glyph on a regular TButton without reverting to the legacy one in Delphi 6?

adlabac
  • 416
  • 4
  • 12
  • 1
    I would not count on `BM_SETIMAGE` with WinXP (with or without setting `BS_ICON` style). It does not works as expected! with Win7 there should not be any problem. – kobik Dec 03 '14 at 14:35
  • You are right - it removed the caption but it displayed the image (and reverted the style). WM_SETICON did not work. – adlabac Dec 03 '14 at 14:39

1 Answers1

5

In Delphi 6 it is not enough just to add the comctl32 v6 manifest. You also need to modify the VCL to be theme aware. The TBitBtn control is a VCL implemented control that, in its Delphi 6 incarnation, does not know anything about XP themes.

The standard way to deal with this is to add some third party software that performs the magic. That's the XP theme manager from Mike Lischke.

Here's a screenshot from a Delphi 6 application that includes the theme manager:

enter image description here

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 3
    Thanks for the answer. What puzzles me is why `TButton` reverts to legacy in runtime when I set the image to it. – adlabac Dec 03 '14 at 13:20
  • 1
    I guess the VCL takes over painting for whatever reason. Again, theme manager fixes that. That said, in my tests, I don't observe the behaviour that you report. – David Heffernan Dec 03 '14 at 13:26
  • `TButton` or `TBitBtn` behaviour? Delphi 6? – adlabac Dec 03 '14 at 13:58
  • This comment thread is all about `TButton`. Anyway, I think I answered your question, no? – David Heffernan Dec 03 '14 at 14:00
  • Yes, I am aware of theme manager, but in that case I will have to include Theme Manager DLL with all my applications, right? I would rather stay with the legacy look. – adlabac Dec 03 '14 at 14:21
  • No you do not need to include any extra DLLs. Just a handful of Pascal files that you compile into your program. I'm surprised that you don't consider your question to have been answered. Never mind. – David Heffernan Dec 03 '14 at 14:23
  • Oh, OK, thanks - I'll give it a try. The reason I suspected the DLL is required is becuse the page you linked says "The themes DLL is dynamically loaded to avoid breaking applications on older Windows systems." and also, Theme Explorer aplication requires ThemedDLL.dll to work. Of course I will select the best answer, just give me some time to try what you suggested and and to consider other responses, if any. – adlabac Dec 03 '14 at 14:51
  • That text is referring to the system DLL that is part of the Windows theme API, `uxtheme.dll`. – David Heffernan Dec 03 '14 at 14:56