本文整理自网络,侵删。
演示:
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Keyboard, StdCtrls, TeCanvas;
type TForm1 = class(TForm) TouchKeyboard1: TTouchKeyboard; Edit1: TEdit; Memo1: TMemo; CheckBox1: TCheckBox; CheckBox2: TCheckBox; CheckBox3: TCheckBox; ButtonColor1: TButtonColor; ButtonColor2: TButtonColor;
procedure CheckBox1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ButtonColor1Click(Sender: TObject); procedure ButtonColor2Click(Sender: TObject); procedure CheckBox2Click(Sender: TObject); procedure CheckBox3Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonColor1Click(Sender: TObject);begin TouchKeyboard1.GradientStart := TButtonColor(Sender).SymbolColor;end;
procedure TForm1.ButtonColor2Click(Sender: TObject);begin TouchKeyboard1.GradientEnd := TButtonColor(Sender).SymbolColor;end;
procedure TForm1.CheckBox1Click(Sender: TObject);begin case CheckBox1.Checked of True: TouchKeyboard1.DrawingStyle := TCustomTouchKeyboard.TDrawingStyle.dsGradient; False: TouchKeyboard1.DrawingStyle := TCustomTouchKeyboard.TDrawingStyle.dsNormal; end; {注意 TDrawingStyle 类型是定义在 TCustomTouchKeyboard 内部的}
case CheckBox1.Checked of True: CheckBox1.Caption := 'DrawingStyle := dsGradient'; False: CheckBox1.Caption := 'DrawingStyle := dsNormal'; end;
end;
procedure TForm1.CheckBox2Click(Sender: TObject);begin case CheckBox2.Checked of True: begin TouchKeyboard1.Layout := 'NumPad'; TouchKeyboard1.Width := 180; TouchKeyboard1.Height := 150; CheckBox2.Caption := 'Layout := NumPad'; end; False: begin TouchKeyboard1.Layout := 'Standard'; TouchKeyboard1.Width := 550; TouchKeyboard1.Height := 180; CheckBox2.Caption := 'Layout := Standard'; end; {注意: 这里的 Layout 属性是个字符串} end;
end;
procedure TForm1.CheckBox3Click(Sender: TObject);begin case CheckBox3.Checked of True: begin TouchKeyboard1.CaptionOverrides.SetCaption('Esc', '退出'); TouchKeyboard1.CaptionOverrides.SetCaption('Backspace', '退格'); TouchKeyboard1.CaptionOverrides.SetCaption('Del', '删除'); TouchKeyboard1.CaptionOverrides.SetCaption('Enter', '回车'); {Esc Backspace Tab Del Caps Enter LeftShift RightShift LeftCtrl LeftAlt RightAlt RightCtrl} end; False: TouchKeyboard1.CaptionOverrides.Clear; end; TouchKeyboard1.Redraw; {重绘}
end;
procedure TForm1.FormCreate(Sender: TObject);begin Memo1.Font.Color := clBlue; Memo1.Font.Size := 12; Memo1.ScrollBars := ssBoth;
Edit1.Font.Color := clRed; Edit1.Font.Size := 12;
CheckBox1.Caption := '背景色'; CheckBox2.Caption := '大小键盘切换'; CheckBox3.Caption := '功能键重命名';
end;
end.
相关阅读 >>
Delphi读取webbrowse中的图片显示在image中
Delphi windows 下用 Delphi 代码杀死进程,或者杀死自己
更多相关阅读请进入《Delphi》频道 >>