in the form.onkeydown()
if (ssCtrl in shift) then
begin
if (key = 84) then //ctrl+T
pcDock.Visible := not PCDock.Visible
else if (key = 67) then //ctrl+C
if pcDock.Visible = true then
pcDock.TabIndex := 1;
end;
截获不到Ctrl+T and Ctrl+C 为什么????
if (ssCtrl in shift) then
begin
if (key = 84) then //ctrl+T
pcDock.Visible := not PCDock.Visible
else if (key = 67) then //ctrl+C
if pcDock.Visible = true then
pcDock.TabIndex := 1;
end;
截获不到Ctrl+T and Ctrl+C 为什么????
if (ssCtrl in shift) and (key = 84) then
为了实现form拦截,请使用form.keypreview := true;在属性栏也可以设置。
begin
////见 delphi 帮助 keyboard events - Example (KeyPreview property Example)
Button1.Enabled:= false; //一定要啊,Form 得到焦点
KeyPreview := true; //一定要啊
//发送ctrl+C
keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), 0, 0);
keybd_event(ord('C'), MapVirtualKey(ord('C'), 0), 0, 0);
keybd_event(ord('C'), MapVirtualKey(ord('C'), 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), KEYEVENTF_KEYUP, 0);
end;
还是不响应,
用 if ((getkeystate(vk_control) and 128) = 128) and
((getkeystate(ord('T')) and 128 = 128) then
pcdock.visible := false;可是必须先按T,再按Ctrol,才响应,??????????????