Search code examples
delphimanifestdelphi-7

Sometimes Common-Controls are missing from the form run-time (Tbutton, Radio, checkbox, etc) when D7 exe has the manifest file


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>

Solution

  • 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;