我想要完成的事情:
我正在使用此代码[KeyPreview为True]:
procedure TFMsg.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Shift = [ssCtrl]) and (Key = $0D) then
begin
Key := 0;
btnSendClick(Sender); //this moves the text and empties the TMemo box
end;
end;
Run Code Online (Sandbox Code Playgroud)
实际发生了什么:
任何帮助感激不尽.谢谢!
处理此问题的最佳方法如下:
请注意,您无需将操作附加到任何内容.仅仅存在就足以确保处理快捷方式.
对于使用修改键的复合键盘操作,使用操作快捷键总是最简单的,因此与较低级别的键盘处理代码保持一定的距离.
您的操作处理程序可能如下所示:
if ActiveControl is TMemo then
begin
Memo := TMemo(ActiveControl);
Text := Memo.Text;
Memo.Clear;
SelectNext(Memo, True, True);
if ActiveControl is TMemo then
begin
Memo := TMemo(ActiveControl);
Memo.Text := Text;
end;
end;
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我假设有多个备忘录,并且文本从一个备忘录移动到Tab键顺序中的下一个备忘录.但您的需求可能会有所不同.在这种情况下,我确信您需要为您的方案做些什么.