关于class produre

很好理解

type

    TMessageHandler = class     //使得回车消息转换成Tab消息

      class procedure AppMessage(var Msg:TMsg;var Handled:Boolean);

end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

class procedure TMessageHandler.AppMessage(var Msg: TMsg; var Handled: Boolean);

begin

  if Msg.message=WM_KEYDOWN then

    if (Msg.wParam=VK_RETURN ) and

      (

        (Screen.ActiveForm.ActiveControl is TEdit) or               

        (Screen.ActiveForm.ActiveControl is TComboBox) or

        (Screen.ActiveForm.ActiveControl is TCheckBox) or

        (Screen.ActiveForm.ActiveControl is TRadioButton)

              //可以添加需要的控件

      )

    then

    begin

      Msg.wParam:=VK_TAB;

    end

    else if (Msg.wParam=VK_RETURN) and

      (

       (Screen.ActiveForm.ActiveControl is TDBGrid)

      )

    then

    begin

{      with Screen.ActiveForm.ActiveControl do

      begin

        if Selectedindex<(FieldCount-1) then

          Selectedindex:=Selectedindex+1// 移动到下一字段

        else

          Selectedindex:=0;

      end;}

    end;

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

  Application.OnMessage:=TMessageHandler.AppMessage;

end;
View Code

你可能感兴趣的:(Class)