• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi制作软键盘

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

 

 

 
 

{

作者: han

日期: 2006.06.02

}

unit softkey;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, RxGIF, ExtCtrls;

type

Tkeyfrm = class(TForm)

img0: TImage;

img5: TImage;

img4: TImage;

img3: TImage;

img8: TImage;

img9: TImage;

img7: TImage;

img2: TImage;

img1: TImage;

img6: TImage;

imgtg: TImage;

imgyc: TImage;

procedure WMActivate(var Message: TMessage); message WM_ACTIVATE;

procedure imgtgClick(Sender: TObject);

procedure imgycClick(Sender: TObject);

procedure OnNumClick(Sender: TObject);

private

{ Private declarations }

procedure Sendkeys(Hz: longint; state: longint=0);

public

{ Public declarations }

HActWin,Hself: Longint;

end;

var

keyfrm: Tkeyfrm;

implementation

{$R *.dfm}

{ Tkeyfrm }

{-------------------------------------------------------------------------------

过程名: Tkeyfrm.Sendkeys

参数: Hz: Longint; State: Longint=0

返回值: 无

说明: 发送键盘消息函数

-------------------------------------------------------------------------------}

procedure Tkeyfrm.Sendkeys(Hz: Longint; State: Longint=0);

var

FocusHld,WindowHld: hwnd;

ThreadId: dword;

begin

WindowHld := GetForegroundWindow;

ThreadId := GetWindowThreadProcessId(WindowHld,nil);

AttachThreadInput(GetCurrentThreadId,ThreadId,True);

FocusHld := GetFocus;

if FocusHld = 0 then Exit;

PostMessage(FocusHld,WM_KEYDOWN,$+Hz,0);

end;

{-------------------------------------------------------------------------------

过程名: Tkeyfrm.OnNumClick

参数: Sender: TObject

返回值: 无

说明: 键盘消息

-------------------------------------------------------------------------------}

procedure Tkeyfrm.OnNumClick(Sender: TObject);

var

tmp: string;

i: Integer;

begin

tmp:= Copy(TImage(Sender).Name,Length(TImage(Sender).Name),1);

i:= StrToInt(tmp);

SetActiveWindow(HActWin);

case i of

0: Sendkeys(48);

1: Sendkeys(49);

2: Sendkeys(50);

3: Sendkeys(51);

4: Sendkeys(52);

5: Sendkeys(53);

6: Sendkeys(54);

7: Sendkeys(55);

8: Sendkeys(56);

9: Sendkeys(57);

end;

end;

{-------------------------------------------------------------------------------

过程名: Tkeyfrm.WMActivate

参数: var Message: TMessage

返回值: 无

说明: 消息回调函数

-------------------------------------------------------------------------------}

procedure Tkeyfrm.WMActivate(var Message: TMessage);

begin

if Message.wParam = WA_CLICKACTIVE then

begin

if (HActWin <> message.lParam) and (message.lParam <> Hself) then

HActWin := message.lParam;

end;

end;

procedure Tkeyfrm.imgtgClick(Sender: TObject);

begin

SetActiveWindow(HActWin);

Sendkeys(8);

end;

procedure Tkeyfrm.imgycClick(Sender: TObject);

begin

Self.Hide;

end;

end.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
MATLAB中均值、方差、均方差的计算方法发布时间:2022-07-18
下一篇:
一个用于专利下载的Delphi源代码程序发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap