我的触摸屏系统是ASP页面,下载了一个手写输入软件,由于200台触摸屏本身的问题,手写的功能几乎用不起来,我就用JS写了一个软键盘,所以现在需要能切换输入法的小程序,现在截面和切换的功能都出来了,就是不知道怎么实现切换好的输入法怎么应用在ASP的页面上,据说要调用API,我刚学DELPHI一天,嘿嘿,不会,望高手指点怎么实现,下面是我下载的代码,请多多指教:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,imm, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
function funOpenIME(PImeName:string):Boolean;
procedure pcdCloseIME;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
{-----------------------------------------------------------------------------
Procedure: TForm1.Button1Click
Author: puha
Date: 2005-4-30
Arguments: Sender: TObject
Result: None
功能: 取得输入法
-----------------------------------------------------------------------------}
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
ComboBox1.Items.Clear;
for i:=0 to Screen.Imes.Count-1 do
begin
ComboBox1.Items.Add(Screen.Imes[i]);
end;
ComboBox1.ItemIndex:=0;
end;{-----------------------------------------------------------------------------
Procedure: TForm1.Button2Click
Author: puha
Date: 2005-4-30
Arguments: Sender: TObject
Result: None
功能:
-----------------------------------------------------------------------------}
procedure TForm1.Button2Click(Sender: TObject);
begin
funOpenIME(ComboBox1.Text);
end;{-----------------------------------------------------------------------------
Procedure: TForm1.Button3Click
Author: puha
Date: 2005-4-30
Arguments: Sender: TObject
Result: None
功能:
-----------------------------------------------------------------------------}
procedure TForm1.Button3Click(Sender: TObject);
begin
pcdCloseIME;
end;{-----------------------------------------------------------------------------
Procedure: TForm1.funOpenIME
Author: puha
Date: 2005-4-30
Arguments: PImeName: string
Result: Boolean
功能: 打开指定名称的输入法
-----------------------------------------------------------------------------}
function TForm1.funOpenIME(PImeName: string): Boolean;
var
MyHKL:HKL;
i:integer;
begin
Result:=False;
if Trim(PImeName)='' then Exit;
if Screen.Imes.Count<=0 then Exit;
i:=Screen.Imes.IndexOf(PImeName);
if i<0 then
begin
ShowMessage('指定的"'+PImeName+'"输入法不存在');
Exit;
end;
MyHKL:=HKL(Screen.Imes.Objects[i]);
ActivateKeyboardLayout(MyHKL,KLF_ACTIVATE);
Result:=True;
end;
{-----------------------------------------------------------------------------
Procedure: TForm1.pcdCloseIME
Author: puha
Date: 2005-4-30
Arguments: None
Result: None
功能: //判断是否在中文状态,若是则关闭它
-----------------------------------------------------------------------------}
procedure TForm1.pcdCloseIME;
var
myhkl:hkl;
begin
myhkl:=GetKeyBoardLayOut(0);
if ImmIsIME(myhkl) then
immsimulateHotkey(handle,IME_CHotKey_IME_NonIME_Toggle);
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,imm, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
function funOpenIME(PImeName:string):Boolean;
procedure pcdCloseIME;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
{-----------------------------------------------------------------------------
Procedure: TForm1.Button1Click
Author: puha
Date: 2005-4-30
Arguments: Sender: TObject
Result: None
功能: 取得输入法
-----------------------------------------------------------------------------}
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
ComboBox1.Items.Clear;
for i:=0 to Screen.Imes.Count-1 do
begin
ComboBox1.Items.Add(Screen.Imes[i]);
end;
ComboBox1.ItemIndex:=0;
end;{-----------------------------------------------------------------------------
Procedure: TForm1.Button2Click
Author: puha
Date: 2005-4-30
Arguments: Sender: TObject
Result: None
功能:
-----------------------------------------------------------------------------}
procedure TForm1.Button2Click(Sender: TObject);
begin
funOpenIME(ComboBox1.Text);
end;{-----------------------------------------------------------------------------
Procedure: TForm1.Button3Click
Author: puha
Date: 2005-4-30
Arguments: Sender: TObject
Result: None
功能:
-----------------------------------------------------------------------------}
procedure TForm1.Button3Click(Sender: TObject);
begin
pcdCloseIME;
end;{-----------------------------------------------------------------------------
Procedure: TForm1.funOpenIME
Author: puha
Date: 2005-4-30
Arguments: PImeName: string
Result: Boolean
功能: 打开指定名称的输入法
-----------------------------------------------------------------------------}
function TForm1.funOpenIME(PImeName: string): Boolean;
var
MyHKL:HKL;
i:integer;
begin
Result:=False;
if Trim(PImeName)='' then Exit;
if Screen.Imes.Count<=0 then Exit;
i:=Screen.Imes.IndexOf(PImeName);
if i<0 then
begin
ShowMessage('指定的"'+PImeName+'"输入法不存在');
Exit;
end;
MyHKL:=HKL(Screen.Imes.Objects[i]);
ActivateKeyboardLayout(MyHKL,KLF_ACTIVATE);
Result:=True;
end;
{-----------------------------------------------------------------------------
Procedure: TForm1.pcdCloseIME
Author: puha
Date: 2005-4-30
Arguments: None
Result: None
功能: //判断是否在中文状态,若是则关闭它
-----------------------------------------------------------------------------}
procedure TForm1.pcdCloseIME;
var
myhkl:hkl;
begin
myhkl:=GetKeyBoardLayOut(0);
if ImmIsIME(myhkl) then
immsimulateHotkey(handle,IME_CHotKey_IME_NonIME_Toggle);
end;end.
解决方案 »
- fastreport怎样设计表格固定格式,格式不随数据条数变动
- 如何快速对比两个结构非常相似的access数据库里面的表内容有那些不同
- Delphi调用异类的WebSerivce时,老是提示Internal Server Error(500)
- TColorBox的Bug~~
- 各位大虾,请教一下DLL方面!
- dbgrideh加行号
- 关于多线程的问题!
- delphi的toolbar做的按钮(flat=true)和imagelist配合,感觉没有其它工具做出来的好看,怪怪的,如何解决
- 如何实现Form标题栏上的最小化功能,急!
- 调查:骂一骂大陆写Delphi书的无知作者!
- Delphi实现球体上面均匀分布点
- 我操作了一个filestream后,里面填充了几个文件,我如何把里面的指定文件删除?
API函数:BOOL ImmSimulateHotKey
(HWND hWnd,DWORD dwHotKeyID);//模拟热键
其中Hwnd为程序窗口的句柄,dwHotHKeyID
为模拟的热键,若成功则返回True
HKL GetKeyboardLayout(DWORD dwLayout);
//获得当前键盘状态
BOOL ImmIsIME(HKL hKL);
//判断当前是否处于中文输入状态,若是则返回True
自定义函数:
打开相应输入法:OpenIme(imename:string),
例OpenIme(’全拼输入法’);
关闭中文输入法:CloseIme;
使用时uses中加上imm