每日程炼-delphi2010 键盘控件(TTouchKeyboard)

简介:

程序员职业之路已经完成了 ~今天开始每日一练,收集和向网络学习,提高自己。
delphi2010有一个新加的控件号称是 TTouchKeyboard, 触屏控件。

—————————————————————————————————————–

代码部分:
———————————————————————————————————————

 
[delphi] view plain copy
print ?
  1. unit Unit1;  
  2.   
  3. interface  
  4.   
  5. uses  
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  
  7.   Dialogs, Keyboard, StdCtrls, TeCanvas;  
  8.   
  9. type  
  10.   TForm1 = class(TForm)  
  11.    TouchKeyboard1: TTouchKeyboard;  
  12.     Edit1: TEdit;  
  13.     Memo1: TMemo;  
  14.     CheckBox1: TCheckBox;  
  15.     CheckBox2: TCheckBox;  
  16.     CheckBox3: TCheckBox;  
  17.     ButtonColor1: TButtonColor;  
  18.     ButtonColor2: TButtonColor;  
  19.   
  20.     procedure CheckBox1Click(Sender: TObject);  
  21.     procedure FormCreate(Sender: TObject);  
  22.     procedure ButtonColor1Click(Sender: TObject);  
  23.     procedure ButtonColor2Click(Sender: TObject);  
  24.     procedure CheckBox2Click(Sender: TObject);  
  25.     procedure CheckBox3Click(Sender: TObject);  
  26.   private  
  27.     { Private declarations }  
  28.   public  
  29.     { Public declarations }  
  30.   end;  
  31.   
  32. var  
  33.   Form1: TForm1;  
  34.   
  35. implementation  
  36.   
  37. {$R *.dfm}  
  38.   
  39. procedure TForm1.ButtonColor1Click(Sender: TObject);  
  40. begin  
  41.   TouchKeyboard1.GradientStart := TButtonColor(Sender).SymbolColor;  
  42. end;  
  43.   
  44. procedure TForm1.ButtonColor2Click(Sender: TObject);  
  45. begin  
  46.    TouchKeyboard1.GradientEnd := TButtonColor(Sender).SymbolColor;  
  47. end;  
  48.   
  49. procedure TForm1.CheckBox1Click(Sender: TObject);  
  50. begin  
  51.   case CheckBox1.Checked of  
  52.     True: TouchKeyboard1.DrawingStyle := TCustomTouchKeyboard.TDrawingStyle.dsGradient;  
  53.     False: TouchKeyboard1.DrawingStyle := TCustomTouchKeyboard.TDrawingStyle.dsNormal;  
  54.   end{注意 TDrawingStyle 类型是定义在 TCustomTouchKeyboard 内部的}  
  55.   
  56.   case CheckBox1.Checked of  
  57.     True: CheckBox1.Caption := 'DrawingStyle := dsGradient';  
  58.     False: CheckBox1.Caption := 'DrawingStyle := dsNormal';  
  59.   end;  
  60.   
  61. end;  
  62.   
  63.   
  64. procedure TForm1.CheckBox2Click(Sender: TObject);  
  65. begin  
  66.    case CheckBox2.Checked of  
  67.     True: begin  
  68.       TouchKeyboard1.Layout := 'NumPad';  
  69.       TouchKeyboard1.Width := 180;  
  70.       TouchKeyboard1.Height := 150;  
  71.       CheckBox2.Caption := 'Layout := NumPad';  
  72.     end;  
  73.     False: begin  
  74.       TouchKeyboard1.Layout := 'Standard';  
  75.       TouchKeyboard1.Width := 550;  
  76.       TouchKeyboard1.Height := 180;  
  77.       CheckBox2.Caption := 'Layout := Standard';  
  78.     end{注意: 这里的 Layout 属性是个字符串}  
  79.   end;  
  80.   
  81. end;  
  82.   
  83. procedure TForm1.CheckBox3Click(Sender: TObject);  
  84. begin  
  85.    case CheckBox3.Checked of  
  86.     True: begin  
  87.       TouchKeyboard1.CaptionOverrides.SetCaption('Esc''退出');  
  88.       TouchKeyboard1.CaptionOverrides.SetCaption('Backspace''退格');  
  89.       TouchKeyboard1.CaptionOverrides.SetCaption('Del''删除');  
  90.       TouchKeyboard1.CaptionOverrides.SetCaption('Enter''回车');  
  91.       {Esc Backspace Tab Del Caps Enter LeftShift RightShift LeftCtrl LeftAlt RightAlt RightCtrl}  
  92.     end;  
  93.     False: TouchKeyboard1.CaptionOverrides.Clear;  
  94.   end;  
  95.   TouchKeyboard1.Redraw; {重绘}  
  96.   
  97. end;  
  98.   
  99. procedure TForm1.FormCreate(Sender: TObject);  
  100. begin  
  101.   Memo1.Font.Color := clBlue;  
  102.   Memo1.Font.Size := 12;  
  103.   Memo1.ScrollBars := ssBoth;  
  104.   
  105.   Edit1.Font.Color := clRed;  
  106.   Edit1.Font.Size := 12;  
  107.   
  108.   CheckBox1.Caption := '背景色';  
  109.   CheckBox2.Caption := '大小键盘切换';  
  110.   CheckBox3.Caption := '功能键重命名';  
  111.   
  112. end;  
  113.   
  114. end.  

------------------------------------------------------------------------------------
窗体部分
-------------------------------------------------------------------------------------
[delphi] view plain copy
print ?
  1. object Form1: TForm1  
  2.   Left = 0  
  3.   Top = 0  
  4.   Caption = #24858#20154#31508#35760'-www.foolcode.com'  
  5.   ClientHeight = 336  
  6.   ClientWidth = 564  
  7.   Color = clBtnFace  
  8.   Font.Charset = DEFAULT_CHARSET  
  9.   Font.Color = clWindowText  
  10.   Font.Height = -11  
  11.   Font.Name = 'Tahoma'  
  12.   Font.Style = []  
  13.   OldCreateOrder = False  
  14.   OnCreate = FormCreate  
  15.   PixelsPerInch = 96  
  16.   TextHeight = 13  
  17.   object TouchKeyboard1: TTouchKeyboard  
  18.     Left = 8  
  19.     Top = 148  
  20.     Width = 550  
  21.     Height = 180  
  22.     GradientEnd = clSilver  
  23.     GradientStart = clGray  
  24.     Layout = 'Standard'  
  25.   end  
  26.   object Memo1: TMemo  
  27.     Left = 8  
  28.     Top = 43  
  29.     Width = 297  
  30.     Height = 99  
  31.     ImeName = #20013#25991'('#31616#20307') - '#25628#29399#25340#38899#36755#20837#27861  
  32.     Lines.Strings = (  
  33.       'Memo1')  
  34.     TabOrder = 1  
  35.   end  
  36.   object Edit1: TEdit  
  37.     Left = 8  
  38.     Top = 8  
  39.     Width = 297  
  40.     Height = 21  
  41.     ImeName = #20013#25991'('#31616#20307') - '#25628#29399#25340#38899#36755#20837#27861  
  42.     TabOrder = 2  
  43.     Text = 'Edit1'  
  44.   end  
  45.   object ButtonColor1: TButtonColor  
  46.     Left = 327  
  47.     Top = 43  
  48.     Width = 102  
  49.     Caption = 'ButtonColor1'  
  50.     TabOrder = 3  
  51.     OnClick = ButtonColor1Click  
  52.   end  
  53.   object ButtonColor2: TButtonColor  
  54.     Left = 454  
  55.     Top = 41  
  56.     Width = 102  
  57.     Caption = 'ButtonColor2'  
  58.     TabOrder = 4  
  59.     OnClick = ButtonColor2Click  
  60.   end  
  61.   object CheckBox1: TCheckBox  
  62.     Left = 327  
  63.     Top = 10  
  64.     Width = 223  
  65.     Height = 17  
  66.     Caption = 'CheckBox1'  
  67.     TabOrder = 5  
  68.     OnClick = CheckBox1Click  
  69.   end  
  70.   object CheckBox2: TCheckBox  
  71.     Left = 327  
  72.     Top = 88  
  73.     Width = 194  
  74.     Height = 17  
  75.     Caption = 'CheckBox2'  
  76.     TabOrder = 6  
  77.     OnClick = CheckBox2Click  
  78.   end  
  79.   object CheckBox3: TCheckBox  
  80.     Left = 327  
  81.     Top = 111  
  82.     Width = 194  
  83.     Height = 17  
  84.     Caption = 'CheckBox3'  
  85.     TabOrder = 7  
  86.     OnClick = CheckBox3Click  
  87.   end  
  88. end  
目录
相关文章
陈伟视频-创建ActiveX控件(54、55)
陈伟视频-创建ActiveX控件(54、55)
|
C#
C# WPF 中用代码模拟鼠标和键盘的操作
原文:C# WPF 中用代码模拟鼠标和键盘的操作   原文地址   C#开发者都知道,在Winform开发中,SendKeys类提供的方法是很实用的。
2144 0
|
测试技术
艾伟:WinForm控件开发总结(二)------使用和调试自定义控件
在上一篇文章里我们创建了一个简单的控件FirstControl,现在我来介绍一下怎么使用和调试自己的控件。我希望将过程写的尽可能的详细,让想学习控件开发的朋友容易上手,高手们见谅。       在同一个solution里添加一个Windows Application工程(在Solution Explorer里右键点击CustomControlSample solution选择Add->New Project…),命名为TestControl。
864 0
|
C#
WPF中桌面屏保的制作(主要代码)
原文:WPF中桌面屏保的制作(主要代码) 制作要点:(1) 使用System.Windows.Threading.DispatcherTimer;(2) 将Window属性设置为:      this.WindowState = WindowState.Maximized;      this.WindowStyle = WindowStyle.None;      this.ResizeMode = ResizeMode.NoResize;(3) 按ESC键时,关闭窗口。
809 0
|
C# 前端开发
WPF编游戏系列 之二 图标效果
原文:WPF编游戏系列 之二 图标效果        本篇将要实现图标的两个效果:1. 显示图标标签,2. 图标模糊效果。在上一篇中提到Image没有HTML 的Title属性(在MSDN中也没找到类似的属性),所以本篇将自行制作一个标签,它的功能是当鼠标移动到图标上方时会显示该图标的Tag说明,并且该图标模糊显示,如下图对比所示。
727 0
|
供应链 数据可视化 UED