2022年6月1日 星期三

Delphi TButton How to make Delphi TButton control stay pressed?

 https://stackoverflow.com/questions/46934591/how-to-make-delphi-tbutton-control-stay-pressed

   Vcl.Themes,
  Vcl.Styles ;

StyleAPI

StyleElements

FInternalImageList 

TSeStyle

procedure TSysStyleHook.UpdateColors;
begin
  if (OverrideEraseBkgnd) or (OverridePaint) then
    Color := StyleServices.GetStyleColor(scWindow)
  else
    Color := clBtnFace;
  if OverrideFont then
    FontColor := StyleServices.GetSystemColor(clWindowText)
  else
    FontColor := clBlack;
end;

procedure TSysStyleHook.SetStyleElements(Value: TStyleElements);
begin
  if Value <> FStyleElements then
    begin
      FStyleElements := Value;
      OverridePaint := (seClient in FStyleElements);
      // OverrideEraseBkgnd := OverridePaint;
      OverridePaintNC := (seBorder in FStyleElements);
      OverrideFont := (seFont in FStyleElements);
    end;
end;


      TCustomButton = class(TButtonControl)

FImages: TCustomImageList;
    FInternalImageList: TImageList;


procedure TCustomButton.SetImages(const Value: TCustomImageList);


procedure TCustomButton.UpdateImages;
begin
  if CheckWin32Version(5, 1) and (FImageIndex <> -1) then
  begin
    FInternalImageList.Clear;
    // PBS_NORMAL
    FInternalImageList.AddImage(FImages, FImageIndex);
    // PBS_HOT
    if FHotImageIndex <> -1 then
      FInternalImageList.AddImage(FImages, FHotImageIndex)
    else
      FInternalImageList.AddImage(FImages, FImageIndex);
    // PBS_PRESSED
    if FPressedImageIndex <> -1 then
      FInternalImageList.AddImage(FImages, FPressedImageIndex)
    else

TButtonImageList BUTTON_IMAGELIST


https://docs.microsoft.com/zh-tw/windows/win32/api/commctrl/nf-commctrl-imagelist_replace

ImageList_Replace function (commctrl.h)

hbmImage

Type: HBITMAP

A handle to the bitmap that contains the image.

hbmMask

Type: HBITMAP

https://theroadtodelphi.com/category/vcl-styles/

https://delphiaball.co.uk/2014/10/22/adding-vcl-styles-runtime/

https://github.com/RRUZ/vcl-styles-utils

https://stackoverflow.com/questions/14031125/styling-only-one-vcl-component-in-delphi

https://theroadtodelphi.com/2012/02/06/changing-the-color-of-edit-controls-with-vcl-styles-enabled/

https://blogs.embarcadero.com/vcl-per-control-styles-coming-in-rad-studio-10-4/

沒有留言: