Forum > CustomDrawn
[SOLVED] TButton's missing caption bugfix
(1/1)
lagprogramming:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---class procedure TCDWSButton.InjectCDControl(const AWinControl: TWinControl; var ACDControlField: TCDControl);begin TCDIntfButton(ACDControlField).LCLControl := TCustomButton(AWinControl); ACDControlField.Caption := AWinControl.Caption; ACDControlField.Parent := AWinControl; ACDControlField.Align := alClient; {$ifdef VerboseCDInjectedControlNames}ACDControlField.Name := 'CustomDrawnInternal_' + AWinControl.Name;{$endif}end;
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---class function TCDWSButton.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLHandle;var lCDWinControl: TCDWinControl;begin Result := TCDWSWinControl.CreateHandle(AWinControl, AParams); lCDWinControl := TCDWinControl(Result); lCDWinControl.CDControl := TCDIntfButton.Create(AWinControl);end; 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.
AlexTP:
Posted to https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40638
Applied today.
Navigation
[0] Message Index