What would be the code to simulate the inverse of the tab

Asked

Viewed 84 times

-1

I have a project in which I open a form inside the other, and with this in the secondary Forms the Onkeydown event instead of going to the secondary Forms are going to the Main form, more if I press tab on the second screens it will normal, so I decided to simulate the tab.

I know the code to simulate keybd_event(VK_TAB, 0, 0, 0); more how to do to simulate the reverse?

procedure TfrmAndamento.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin

  if ((key=VK_RETURN) or (key=VK_DOWN)) and not((Sender is TMemo) or (Sender is TComboBox) or (Sender is TDBComboBox) or (Sender is TDBGrid))
  then
    selectNext(ActiveControl,True,True); // <= aqui o sistema da erro pois o ActiveControl sempre vem o objeto que não era o correspondente
end;
  • 2

    You honestly don’t understand why you’re closing the question? "... but if your question has to do with..." - a specific programming problem - OK - a software algorithm - common tools among programmers when applied in software development - practical and well-defined problems concerning software development - OK theoretical doubts about concepts and practices applied to software development - OK - It is not a duplicate question - OK .

  • 2

    It’s the Stack Overflow custom...

1 answer

6


Do you want to simulate Shift+Tab? Try it this way:

  keybd_event(VK_SHIFT, 0, 0, 0);               // pressiona o Shift
  keybd_event(VK_TAB, 0, 0, 0);                 // pressiona o Tab
  keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);   // solta o Tab
  keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0); // solta o Shift

I hope it helps

  • I’ll test it here. Thanks!

  • Old worked even. Very top!! Thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.