首先,在主窗体中声明以下private过程:
procedure TMainForm.DoEnterAsTab(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.Message = WM_KEYDOWN then
begin
if Msg.wParam = VK_RETURN then
Keybd_event(VK_TAB, 0, 0, 0);
end; //if
end;
在主窗体的OnCreate事件中加入:
Application.OnMessage := DoEnterAsTab;
procedure TMainForm.DoEnterAsTab(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.Message = WM_KEYDOWN then
begin
if Msg.wParam = VK_RETURN then
Keybd_event(VK_TAB, 0, 0, 0);
end; //if
end;
在主窗体的OnCreate事件中加入:
Application.OnMessage := DoEnterAsTab;
本文介绍了一种在主窗体中通过按键事件将回车键的功能替换为Tab键的方法。具体实现是在主窗体中声明了一个Private过程DoEnterAsTab,并在OnCreate事件中注册了该过程作为消息处理函数。
757

被折叠的 条评论
为什么被折叠?



