Jump to content

OnKeydown Frame


herculanojs

Recommended Posts

Was there any way to know the keys pressed on onkeydown in a frame?

 

I need to know if the user precionar certain key example F4.
In maimform I'm monitoring the onkeydown and through reference to the frame. It happens that when there dbgrid and the focus is the same, the event is run in duplicate even being precionado only once. The onkeydown in FormMain runs 2 times.
 
procedure TMainForm.UniFormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
type TmyKeyDow = procedure (var Key: Word; Shift: TShiftState) of object;
var
    MyKeyDow:TMyKeyDow;
    Routine: TMethod;
begin
     if FrameSelecionado <> nil then
     begin
          try
             classe := FrameSelecionado.ClassName;
             Routine.Data := Pointer(FrameSelecionado);
             Routine.Code := FrameSelecionado.MethodAddress('KeyDown');
             if Routine.Code <> nil then
             begin
                  MyKeyDow:=TMyKeyDow(Routine);
                  MyKeyDow(key,Shift);
             end;
          except
 
          end;
     end;
end;

 

------------------

frame:

 

Public

published

 

procedure KeyDown(var Key: Word; Shift: TShiftState);

 

procedure TfrVenda_Mercadoria.KeyDown(var Key: Word; Shift: TShiftState);
begin
     if key = vk_f4 then
        edtQtde.SetFocus else
end;

 

Link to comment
Share on other sites

  • 1 year later...

Ola Herculado, você conseguiu realizar as teclas de atalho (keydown no formulário Frame?) eu tentei utilizar o seu código acima mais esta faltando algumas coisas consegui ate simular, consigo chamar pela função onKeydown do Fomulario Menu chama a Proceduro do frame, so que quando executo exemplo: BotaoExemplo.click da erro, se você consegue poderia compartilhar esse código??

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...