我想写一个过程,用于改变窗体上EDIT的颜色,当该某个EDIT获得焦点时就改变其颜色,当焦点离开时则恢复以前的颜色?望高手不吝赐教!

解决方案 »

  1.   

    onenter,onexit里面写
    button.canvas.brush.color := ...;
      

  2.   

    错了
    是edit.color := ;
      

  3.   

    procedure TForm1.Edit1Enter(Sender: TObject);
    begin
      TEdit(Sender).Color := clRed;
    end;procedure TForm1.Edit1Exit(Sender: TObject);
    begin
      TEdit(Sender).Color := clWindow;
    end;
      

  4.   

    procedure TForm1.Edit1Enter(Sender: TObject);
    begin
      (Sender as TEdit).Color := clRed;
    end;procedure TForm1.Edit1Exit(Sender: TObject);
    begin
      (Sender as TEdit).Color := clWindow;
    end;
      

  5.   

    Protected
        Procedure WndProc(Var Message : TMessage); Override;Procedure TForm1.WndProc(Var Message : TMessage);
    Begin
     If Message.LParam = Longint(Edit1) Then
      Begin
        If (Message.Msg = CM_MOUSELEAVE) Then
          Edit1.Color := clRed
        Else If (Message.Msg = CM_MOUSEENTER) Then
          Edit1.Color := clWindow;
      End;
      Inherited WndProc(Message);
    End;
      

  6.   

    从EDIT继承一个是较合理的做法。
      

  7.   

    可能是我没有说清楚,我想写一个公用过程,让窗体的onenter或onexit过程调用.