Shift + Tab
perform(WM_NEXTDLGCTL,0,0);这是向下移动,请问如何向上移动??????
perform(WM_NEXTDLGCTL,1,0);即可向上移动
为什么不看MSDN,不看HELP你当然不知道了。
perform(WM_NEXTDLGCTL,0,1)
控制焦点移动,还可以利用TWinControl.SelectNext()方法来做!
*********************
Form.KeyPreview := true; 在Form的KeyDown中
if Key = VK_RETURN then
begin
if ActiveControl is TDBGrid or ... then
PostMessage(ActiveControl.Handle, WM_KEYDOWN, VK_TAB, 0);
else
PostMessage(Handle, WM_KEYDOWN, VK_TAB, 0);
Key := 0;
end
---------------
procedure EnterToTab(aForm: TForm; var Key: Char);
begin
if Key = #13 then
begin
key := #0;
aForm.Perform(CM_DialogKey, VK_TAB, 0);
end;
end;
***************
或者拦截Application.OnMessage即可,添加代码:
if Msg.Message = WM_KEYDOWN then
begin
if Msg.wParam = VK_RETURN then
Keybd_event(VK_TAB, 0, 0, 0);
end; //if