博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Delphi 2010 新增功能之: 软键盘、触摸键盘(TTouchKeyboard)
阅读量:6316 次
发布时间:2019-06-22

本文共 4422 字,大约阅读时间需要 14 分钟。

  hot3.png

本例效果动画图(因不是触摸屏, 只能用鼠标测试一下):
26153351_MoF7.gif

代码文件:

unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls, Keyboard, TeCanvas;type  TForm1 = class(TForm)    TouchKeyboard1: TTouchKeyboard;    Edit1: TEdit;    Memo1: TMemo;    CheckBox1: TCheckBox;    CheckBox2: TCheckBox;    CheckBox3: TCheckBox;    ButtonColor1: TButtonColor;    ButtonColor2: TButtonColor;    procedure FormCreate(Sender: TObject);    procedure CheckBox1Click(Sender: TObject);    procedure CheckBox2Click(Sender: TObject);    procedure CheckBox3Click(Sender: TObject);    procedure ButtonColor1Click(Sender: TObject);    procedure ButtonColor2Click(Sender: TObject);  end;var  Form1: TForm1;implementation{$R *.dfm}//是否要背景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.ButtonColor1Click(Sender: TObject);begin  TouchKeyboard1.GradientStart := TButtonColor(Sender).SymbolColor;end;//背景过渡色 - 终止色procedure TForm1.ButtonColor2Click(Sender: TObject);begin  TouchKeyboard1.GradientEnd := TButtonColor(Sender).SymbolColor;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;//更换键名显示, 这在设计时通过 KeyCaptions 属性调整更方便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.
窗体文件:

object Form1: TForm1  Left = 0  Top = 0  Caption = 'Form1'  ClientHeight = 336  ClientWidth = 566  Color = clBtnFace  Font.Charset = DEFAULT_CHARSET  Font.Color = clWindowText  Font.Height = -11  Font.Name = 'Tahoma'  Font.Style = []  OldCreateOrder = False  OnCreate = FormCreate  PixelsPerInch = 96  TextHeight = 13  object TouchKeyboard1: TTouchKeyboard    Left = 8    Top = 148    Width = 550    Height = 180    GradientEnd = clSilver    GradientStart = clGray    Layout = 'Standard'  end  object Memo1: TMemo    Left = 8    Top = 43    Width = 297    Height = 99    Lines.Strings = (      'Memo1')    TabOrder = 1  end  object Edit1: TEdit    Left = 8    Top = 8    Width = 297    Height = 21    TabOrder = 2    Text = 'Edit1'  end  object ButtonColor1: TButtonColor    Left = 327    Top = 43    Width = 102    Caption = 'ButtonColor1'    TabOrder = 3    OnClick = ButtonColor1Click  end  object ButtonColor2: TButtonColor    Left = 448    Top = 43    Width = 102    Caption = 'ButtonColor2'    TabOrder = 4    OnClick = ButtonColor2Click  end  object CheckBox1: TCheckBox    Left = 327    Top = 10    Width = 223    Height = 17    Caption = 'CheckBox1'    TabOrder = 5    OnClick = CheckBox1Click  end  object CheckBox2: TCheckBox    Left = 327    Top = 88    Width = 194    Height = 17    Caption = 'CheckBox2'    TabOrder = 6    OnClick = CheckBox2Click  end  object CheckBox3: TCheckBox    Left = 327    Top = 111    Width = 194    Height = 17    Caption = 'CheckBox3'    TabOrder = 7    OnClick = CheckBox3Click  endend

转载于:https://my.oschina.net/hermer/blog/319827

你可能感兴趣的文章
zabbix入门到高级
查看>>
通过python获取服务器所有信息
查看>>
php上传大文件配置
查看>>
Win8 Metro(C#)数字图像处理--2.45图像雾化效果算法
查看>>
k3cloud设置同一单据的单据头字段各行合并显示
查看>>
Linux日志管理
查看>>
Gitlab完整搭建手册+排错
查看>>
简述计算机从加电到启动系统时主板的工作流程
查看>>
js页面缓存问题
查看>>
QRCode.js:使用 JavaScript 生成二维码
查看>>
SQL语言的CASE语句备忘
查看>>
Fatal error LNK1168: cannot open *.exe file for writing
查看>>
JVM的内存区域划分
查看>>
郁闷得发展方向
查看>>
linux内核编程笔记【原创】
查看>>
ORA-02085: database link %s connects to %s 解决思路
查看>>
DB2常用命令
查看>>
HTTP Server Error 500 内部服务器错误
查看>>
让树莓派说出自己的IP地址
查看>>
转--发布js支持Firefox的加入收藏代码
查看>>