如何使用窗口焦点消息为Delphi屏幕键盘窗体 [英] How to use window focus messages for a Delphi on-screen keyboard form
问题描述
我不知道如何创建窗口,当您点击它是不可集中的框架,所以下面的一个是没有边界。如Andreas所说,使用TSpeedButtons。
键入
TKeypadForm = class(TForm)
SpeedButton1:TSpeedButton ;
procedure SpeedButton1Click(Sender:TObject);
private
程序CreateParams(var Params:TCreateParams);覆盖
procedure WMMouseActivate(var Message:TWMMouseActivate);消息WM_MOUSEACTIVATE;
结束
程序TKeypadForm.CreateParams(var Params:TCreateParams);
begin
继承CreateParams(Params);
Params.Style:= WS_POPUP或WS_THICKFRAME;
结束
程序TKeypadForm.WMMouseActivate(var Message:TWMMouseActivate);
begin
Message.Result:= MA_NOACTIVATE;
结束
程序TKeypadForm.SpeedButton1Click(发件人:TObject);
begin
PostMessage(GetFocus,WM_KEYDOWN,VK_NUMPAD1,MakeLong(0,MapVirtualKey(VK_NUMPAD1,0)));
结束
这里是如何显示键盘窗口
procedure TForm18.Edit1KeyDown(Sender:TObject; var Key:Word;
Shift:TShiftState);
begin
case
的关键字VK_RETURN:ShowWindow(KeypadForm.Handle,SW_SHOWNOACTIVATE);
VK_ESCAPE:ShowWindow(KeypadForm.Handle,SW_HIDE);
结束
结束
I need a built-in on screen numeric keypad in my Application. For various reasons I cannot use the TMS Software or other commercial component offerings. I'm very happy with a button-based solution shown below but I cannot yet see how to solve the focus switch issue where clicking the button activates the keypad form and I lose the focused control into which I wanted the characters. My solution works if I keep the keypad buttons within the target form but I would like a form-independent solution. Is there a way of disabling the button activation or knowing where the focus came from so that I can use something like Scree.ActiveControl :=?? to put it back?
I don't know how to create window with the frame which is unfocusable when you click it, so the following one is without border. And as Andreas mentioned, use TSpeedButtons.
type
TKeypadForm = class(TForm)
SpeedButton1: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
private
procedure CreateParams(var Params: TCreateParams); override;
procedure WMMouseActivate(var Message: TWMMouseActivate); message WM_MOUSEACTIVATE;
end;
procedure TKeypadForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.Style := WS_POPUP or WS_THICKFRAME;
end;
procedure TKeypadForm.WMMouseActivate(var Message: TWMMouseActivate);
begin
Message.Result := MA_NOACTIVATE;
end;
procedure TKeypadForm.SpeedButton1Click(Sender: TObject);
begin
PostMessage(GetFocus, WM_KEYDOWN, VK_NUMPAD1, MakeLong(0, MapVirtualKey(VK_NUMPAD1, 0)));
end;
And here's how to show the keypad window
procedure TForm18.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_RETURN: ShowWindow(KeypadForm.Handle, SW_SHOWNOACTIVATE);
VK_ESCAPE: ShowWindow(KeypadForm.Handle, SW_HIDE);
end;
end;
这篇关于如何使用窗口焦点消息为Delphi屏幕键盘窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!