所有相关控件共用一OnEnter事件处理程序,在内写代码好像也不算麻烦啊

解决方案 »

  1.   

    procedure TForm1.FormCreate(Sender: TObject);
    var
            iCount : Integer;
    begin
            for iCount := 0 to ComponentCount - 1 do
            begin
                    if Components[iCount].Tag = 1 then
                    begin
                            TEdit(Components[iCount]).OnEnter := Edit1Enter;
                    end;
            end;
    end;procedure TForm1.Edit1Enter(Sender: TObject);
    begin
            Tedit(Sender).Font.Color := clRed;
    end;
      

  2.   

    在OnEnter和OnExit事件中作文章吧:
    procedure TForm1.Edit1Enter(Sender: TObject);
    begin
      (Sender As TEdit).Color:=clRed;
      (Sender As TEdit).Font.Color := clBlue;
    endprocedure TForm1.Edit1Exit();
    begin
      (Sender As TEdit).Color:=clWhite;
      (Sender As TEdit).Font.Color := clBlack;
    end;
      

  3.   

    procedure TForm1.Edit1Enter(Sender: TObject);
    begin
      Edit1.Color := clRed;
    end;
      

  4.   

    用OnEnter吧
    懒一点就要做控件
      

  5.   

    各位谢谢你们!可是,我说过,系统已经形成,一个窗体好近百个编辑框,一个一个写?做控件?一个一个换?不现实吧?象CoolSlob() 说的一样,我总感受觉应该有个消息之类的,可是我找不到。只好做了一个笨点儿的,但不用每一个控件都写事件。有没有感受兴趣的?另外,有没有高人帮我查一查焦点转移消息?
      

  6.   

    The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus. WM_SETFOCUS  
    hwndLoseFocus = (HWND) wParam; // handle of window losing focus 
     ParametershwndLoseFocusValue of wParam. Identifies the window that has lost the keyboard focus (may be NULL).  Return ValuesAn application should return zero if it processes this message. ResTo display a caret, an application should call the appropriate caret functions when it receives the WM_SETFOCUS message.
      

  7.   

    The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus. WM_KILLFOCUS  
    hwndGetFocus = (HWND) wParam; // handle of window receiving focus 
     ParametershwndGetFocusValue of wParam. Identifies the window that receives the keyboard focus (may be NULL).  Return ValuesAn application should return zero if it processes this message. ResIf an application is displaying a caret, the caret should be destroyed at this point.
      

  8.   

    窗体中有个ActiveControl属性,它的值就是当前获得焦点的控件。
    你仔细想想,应该可以实现你所要的功能。