24小时热门版块排行榜    

Znn3bq.jpeg
查看: 1590  |  回复: 1

zyj8119

木虫 (著名写手)

[交流] 【转帖】Delphi2010软键盘(TTouchKeyboard)用法示例 已有1人参与

代码文件:
CODE:
unit Unit1; 
 
interface 
 
uses 
 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 
 end 
end

回复此楼
好好学习,天天向上。
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wd0001

新虫 (小有名气)


小木虫: 金币+0.5, 给个红包,谢谢回帖
好高端大气上档次的样子
2楼2014-02-21 22:07:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zyj8119 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 河北省自然科学基金 +5 Peterchao 2026-05-18 8/400 2026-05-24 11:58 by 晓晓爱翠翠
[考博] 云南大学材料与能源学院解琳课题组钙钛矿博士招生 +4 光伏爱好者 2026-05-17 7/350 2026-05-24 10:20 by 光伏爱好者
[基金申请] 西安交大新媒学院副院长用撤稿论文结题 +3 bjvtcliu 2026-05-24 5/250 2026-05-24 10:16 by kudofaye
[教师之家] 论文撤稿了 +3 bjvtcliu 2026-05-24 5/250 2026-05-24 10:06 by Equinoxhua
[教师之家] 某211大学教师把个人教师官方主页改成:我跑了我跑了我跑了!官宣跑路! +4 zju2000 2026-05-21 5/250 2026-05-24 09:35 by songwz
[考博] 26/27申博自荐 10+4 ZXW0202 2026-05-22 9/450 2026-05-24 08:47 by bjvtcliu
[硕博家园] 售SCI一区T0P文章,我:8.O.5.5.1.O.5.4,科目齐全,可+急 +3 hvkbtfonbv 2026-05-23 3/150 2026-05-24 08:01 by 9ps9vgkqva
[硕博家园] 售SCI一区T0P文章,我:8.O.5.5.1.O.5.4,科目齐全,可+急 +3 pmo95bazuy 2026-05-23 7/350 2026-05-24 06:35 by fpo5ljpv91
[基金申请] 揭秘青基评审内幕:几个A才能顺利中标 +3 国自然国社科中 2026-05-23 4/200 2026-05-23 15:37 by 2000zf36392
[基金申请] 青B发送上会通知了吗 +5 chemBioBro 2026-05-22 7/350 2026-05-23 12:35 by zhuifengzhy
[论文投稿] 投稿求助,期刊 +4 希冀,有书读 2026-05-20 8/400 2026-05-22 10:16 by 希冀,有书读
[文学芳草园] 献血感触 +7 呀呀好傻 2026-05-19 13/650 2026-05-21 20:15 by 呀呀好傻
[基金申请] 面上本子正文33页,违规吗?会被低分嘛? +14 1234567wang 2026-05-17 16/800 2026-05-21 17:58 by 脆脆的饼干
[基金申请] 国自然评分 +4 无名者登山 2026-05-20 5/250 2026-05-21 16:35 by swuq
[基金申请] 国自然上会要求 +7 无名者登山 2026-05-18 11/550 2026-05-21 15:50 by draco1987
[基金申请] 提交了我也来说说感想 +9 fummck 2026-05-20 10/500 2026-05-21 14:17 by draco1987
[基金申请] 评审有感 +15 popular289 2026-05-18 26/1300 2026-05-21 10:35 by 西葫芦炒鸡蛋
[有机交流] 反应很差,大量原料没有反应 5+3 Mr.Zot 2026-05-19 8/400 2026-05-20 22:19 by Equinoxhua
[考博] 如果工作了想读博,可以边工作边读全日制嘛? 30+3 铁达火车 2026-05-18 5/250 2026-05-20 09:33 by tfang
[考博] 博士申请 +5 星…… 2026-05-18 6/300 2026-05-18 23:49 by 糊糊涂涂好
信息提示
请填处理意见