Recent

Author Topic: [SOLVED] TButton's missing caption bugfix  (Read 899 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 403
[SOLVED] TButton's missing caption bugfix
« on: December 09, 2023, 11:09:53 am »
Add a tbutton on a form. In linux-customdrawn the caption of the tbutton doesn't appear. To fix this bug update the following routines with the following content.
Code: Pascal  [Select][+][-]
  1. class procedure TCDWSButton.InjectCDControl(const AWinControl: TWinControl; var ACDControlField: TCDControl);
  2. begin
  3.   TCDIntfButton(ACDControlField).LCLControl := TCustomButton(AWinControl);
  4.   ACDControlField.Caption := AWinControl.Caption;
  5.   ACDControlField.Parent := AWinControl;
  6.   ACDControlField.Align := alClient;
  7.   {$ifdef VerboseCDInjectedControlNames}ACDControlField.Name := 'CustomDrawnInternal_' + AWinControl.Name;{$endif}
  8. end;
  9.  
Code: Pascal  [Select][+][-]
  1. class function TCDWSButton.CreateHandle(const AWinControl: TWinControl;
  2.   const AParams: TCreateParams): TLCLHandle;
  3. var
  4.   lCDWinControl: TCDWinControl;
  5. begin
  6.   Result := TCDWSWinControl.CreateHandle(AWinControl, AParams);
  7.   lCDWinControl := TCDWinControl(Result);
  8.   lCDWinControl.CDControl := TCDIntfButton.Create(AWinControl);
  9. end;
  10.  
Now the caption of the button appears. It is not centered in the middle of the button, but that's a different bug.

A note:
lCDWinControl.CDControl := TCDXXX.Create(AWinControl); is the line that has to exist in createhandle according to commits like:
LCL-CustomDrawn: Starts BitBtn implementation
LCL-CustomDrawn: Adds initial TScrollBar and SpinEdit implementations

Here is a patch.
« Last Edit: December 12, 2023, 12:51:36 pm by lagprogramming »

AlexTP

  • Hero Member
  • *****
  • Posts: 2353
    • UVviewsoft
Re: TButton's missing caption bugfix
« Reply #1 on: December 12, 2023, 10:06:28 am »

 

TinyPortal © 2005-2018