Teclado - controlando tab |
Top Previous Next |
|
Com este código é possível controlar o pressionamento de TAB:
private procedure ControlaTAB(var Msg: TMsg; var Handled: Boolean);
OnCreate Application.OnMessage := ControlaTAB;
OnDestroy Application.OnMessage := nil;
procedure TTabEdit.ControlaTAB(var Msg: TMsg; var Handled: Boolean); begin if Msg.message = WM_KEYDOWN then if Msg.wParam = VK_TAB then begin // if not TCustomForm(Owner).Active then Exit; // Se quiser que funcione só nesta form tire o coment Msg.wParam := 0; // "Zera" esta mensagem if (GetKeyState(VK_SHIFT) and $1000000) <> 0 then // SHIFT PRESSIONADA? TCustomForm(Owner).Perform(WM_NextDlgCtl,1,0) else TCustomForm(Owner).Perform(WM_NextDlgCtl,0,0); end; end;
-------------------------------------------------
{ This can easily be done by overriding the forms CMDialogKey procedure. To see how this works drop a Edit on the form and enter in the following code: }
procedure CMDialogKey(Var Msg: TWMKey); message CM_DIALOGKEY; ... procedure TForma.CMDialogKey(Var Msg: TWMKEY); begin if (ActiveControl is TEdit) and (Msg.Charcode = VK_TAB) then begin ShowMessage('TAB key pressed?'); end; inherited; end; |