herculanojs Posted October 13, 2016 Share Posted October 13, 2016 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; Quote Link to comment Share on other sites More sharing options...
Alysson_pp Posted January 4, 2018 Share Posted January 4, 2018 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?? Quote Link to comment Share on other sites More sharing options...
herculanojs Posted January 5, 2018 Author Share Posted January 5, 2018 Você poderia compartilhar o código que esta no teu formulário principal e o código que esta no frame? Apenas as partes que esta referenciando o código no onkeydow Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 5, 2018 Share Posted January 5, 2018 Hi, Can you make a simple testcase for this... ?! Best regards, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.