Home > Back-end >  Sometimes Common-Controls are missing from the form run-time (Tbutton, Radio, checkbox, etc) when D7
Sometimes Common-Controls are missing from the form run-time (Tbutton, Radio, checkbox, etc) when D7

Time:02-19

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>

CodePudding user response:

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;

When added to a form, use this:

Procedure DoInvalidate( aWinControl: TWInControl );   Var
    i: Integer;
    ctrl: TControl;   Begin
    for i:= 0 to aWinControl.Controlcount-1 do begin
      ctrl:= aWinControl.Controls[i];
      if ctrl Is TWinControl then
        DoInvalidate( TWincontrol( ctrl ));
    end;
    aWinControl.Invalidate;   End;
  • Related