Trocar o TAB por Enter em Toda a Aplicação..Como?

Delphi

23/08/2005

Oi
Estou dando manutenção para um cliente, e ele pediu para mim trocar o tab por enter para mudar de campo de toda a aplicação.. só que tem um problema o sistema não utilizada herança de forms.. tem alguma forma de mudar em toda a aplicação, sem ter que entrar em kda form?


Daniel Martins

Daniel Martins

Curtidas 0

Respostas

Wilson Brito

Wilson Brito

23/08/2005

//Mudar com Enter e Setas Acima e Abaixo

Uses
Grids

procedure TFormPrincipal.MudarComEnter(var Msg: TMsg; var Handled: Boolean);
begin
If not ((Screen.ActiveControl is TCustomMemo) or
(Screen.ActiveControl is TCustomGrid) or
(Screen.ActiveForm.ClassName = ´TMessageForm´)) then
begin
If Msg.message = WM_KEYDOWN then
begin
Case Msg.wParam of
VK_RETURN,VK_DOWN : Screen.ActiveForm.Perform(WM_NextDlgCtl,0,0);
VK_UP : Screen.ActiveForm.Perform(WM_NextDlgCtl,1,0);
end;
end;
end;
end;

no evento OnCreate o Form Principal digite a seguinte linha

Application.OnMessage := MudarComEnter;


GOSTEI 0
Henrique Rodrigues

Henrique Rodrigues

23/08/2005

usei essa informação mas está dando o erro:

[Error] Unit_Index.pas(113): Incompatible types: ´method pointer and regular procedure´

o que fiz de errado?


GOSTEI 0
Wilson Brito

Wilson Brito

23/08/2005

[b:5aeaad7fa7]Código Completo da Unit do Formulario Principal (Delphi 7)[/b:5aeaad7fa7]

unit UntPrincipal;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids;

type
TFormPrincipal = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure MudarComEnter(var Msg: TMsg; var Handled: Boolean);
{ Public declarations }
end;

var
FormPrincipal: TFormPrincipal;

implementation

{$R *.dfm}


procedure TFormPrincipal.MudarComEnter(var Msg: TMsg; var Handled: Boolean);
begin
If not ((Screen.ActiveControl is TCustomMemo) or
(Screen.ActiveControl is TCustomGrid) or
(Screen.ActiveForm.ClassName = ´TMessageForm´)) then
begin
If Msg.message = WM_KEYDOWN then
begin
Case Msg.wParam of
VK_RETURN,VK_DOWN : Screen.ActiveForm.Perform(WM_NextDlgCtl,0,0);
VK_UP : Screen.ActiveForm.Perform(WM_NextDlgCtl,1,0);
end;
end;
end;
end;


procedure TFormPrincipal.FormCreate(Sender: TObject);
begin
Application.OnMessage := MudarComEnter;
end;

end.


GOSTEI 0
Daniel Martins

Daniel Martins

23/08/2005

eu utilizo o delphi 6 tem alguma diferença?


GOSTEI 0
POSTAR