1

The missing buttons appear back on screen when I move a mouse over them or invalidate/repaint the whole form by code. I have made a fix that if ALT-key is pressed (to show shortcuts) these are repainted but problem appears even randomly when ALT is not down.

When I remove the manifest file below the buttons appear ok. The manifest is needed so that old style buttons look circular.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32"
                    name="xxxx"
                    version="6.0.0.0"
                    processorArchitecture="x86"
                    publicKeyToken="6595b64144ccf1df"
  />
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32"
                        name="Microsoft.Windows.Common-Controls"
                        version="6.0.0.0"
                        processorArchitecture="X86"
                        publicKeyToken="6595b64144ccf1df"
                        language="*"
      />
    </dependentAssembly>
  </dependency>
</assembly>
Tom
  • 6,725
  • 24
  • 95
  • 159
  • Is this really what you want to give us? We just create a new project in D7, include your manifest and then can reproduce your problem? Unbound to any Windows version and if/which themes are active? I'm asking because I have themes disabled in Win7. Sure your ALT-fix is not the culprit? – AmigoJack Feb 18 '22 at 13:12
  • Technically, buttons aren't "common controls" in the Win32 sense. – Andreas Rejbrand Feb 18 '22 at 13:14
  • Please see the correct solution posted by Dalija – Tom Feb 18 '22 at 13:42

1 Answers1

2

Delphi 7 does not respond to WM_UPDATEUISTATE message

You can fix that by patching TWinControl with following code.

TWinControl = class(TControl)
private    
  procedure WMUpdateUIState(var Message: TMessage); message WM_UPDATEUISTATE;
...
end;

procedure TWinControl.WMUpdateUIState(var Message: TMessage);
begin
  DefWindowProc(Handle, Message.Msg, Message.WParam, Message.LParam);
  Invalidate;
end;
Dalija Prasnikar
  • 27,212
  • 44
  • 82
  • 159
  • You can probably solve issue by adding above code to each form, if you cannot patch TWinControl for some reason, but I didn't included that as part of the answer because I cannot test that since I currently don't have Delphi 7 installed. I used above code successfully on up to windows 10 (not tested on Windows 11) – Dalija Prasnikar Feb 18 '22 at 13:18
  • Excellent Answer, it works with recursion – Tom Feb 18 '22 at 13:29
  • @Tom Please **do not** edit your own code into answers of others! – AmigoJack Feb 18 '22 at 14:25
  • Looks similar to [TEdit Labels are not displaying (Windows 7/Vista only)](https://stackoverflow.com/a/43528855/4299358)'s answer. – AmigoJack Feb 18 '22 at 19:35
  • @Tom I rolled back your edit. It is perfectly acceptable that you add separate answer that extends or is based upon some other answer. – Dalija Prasnikar Feb 19 '22 at 09:13