Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: TTouchKeyboard Button Farbe ändern

  Alt 22. Mai 2019, 15:45
Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Touch.Keyboard;

type
  TTouchKeyboard = class(Vcl.Touch.Keyboard.TTouchKeyboard)
  end;

  TMyKeyboardButton = class(Vcl.Touch.Keyboard.TCustomKeyboardButton)
  public
    procedure Paint(Canvas: TCustomCanvas = nil); override;
  end;

  TForm1 = class(TForm)
    TouchKeyboard1: TTouchKeyboard;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TKeyboardButton }

procedure TMyKeyboardButton.Paint(Canvas: TCustomCanvas);
var
  LCanvas: TCanvas;
  LRect: TRect;
begin
  inherited Paint(Canvas); // optional, wenn man nicht alles selber machen möchte

  if Canvas <> nil then
    LCanvas := Canvas as TCanvas
  else
    LCanvas := TTouchKeyboard(Parent).Canvas;

  // ab hier kann wild drauflos gemalt werden.
  LRect := ClientRect;
  LCanvas.Ellipse(LRect.Left, LRect.Top, LRect.Width, LRect.Bottom);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  TouchKeyboard1.DefaultButtonClass := TMyKeyboardButton; // eigene Buttonableitung als zu erzeugene "Tastatur"-Buttons anmelden
end;

end.
  Mit Zitat antworten Zitat