那就用上一级组件的CM_MouseEnter配合

解决方案 »

  1.   

    cm_mouseleave的确不太好用,应该用wm_mouseleave这个消息结合trackmouseevent这个api使用!绝对好用,呵呵,只不过比cm_mouseleave麻烦一点点了!
      

  2.   

    wm_mouseleave是windows的消息,我测试过处理mouseleave绝对很不错,虽然必须结合trackmouseevent函数使用,不是很方便,但是效果嘛,最好!
      

  3.   

    好象不行,trackmouseevent是NT的函数。
    我在98下试了试,没有反应。
      

  4.   

    不会呀,trackmouseevent虽然我没在98下测试,但是msdn上说了支持98,不要告诉我ms在骗我:)呵呵  Windows NT/2000: Requires Windows NT 4.0 or later.
      Windows 95/98: Requires Windows 98 or later.
      Header: Declared in Winuser.h; include Windows.h.
      Library: Use User32.lib.
      

  5.   

    但我手边的DELPHI 5的WIN REFERENCE手册中trackmouseevent的QUICKINFO明确指出不支持。
    浪人,能让我看看你的代码吗?我的代码如下:procedure TForm1.Button1Click(Sender: TObject);
    var
      e: TagTRACKMOUSEeVENT;
    begin
      E.cbSize:= SIZEof(TagTRACKMOUSEeVENT);
      E.dwFlags:= TME_LEAVE;
      E.dwHoverTime:= 10;
      E.hwndTrack:= handle;
      trackmouseevent(e);
    end;procedure TForm1.WMMouseLeave(var M: TMessage);
    begin
      color:=  clRed;
    end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      color:=  clBlue;
    end;不行。
      

  6.   

    wm_mouseleave是windows的消息吗?瞎搞嘛!你说的是win64还是win32啊
      

  7.   

    先谢了。
    另外说一句,我刚试了用SetCapture的方法,但效果不好。
      

  8.   

    to ss(雅龙):
    至于我是不是瞎搞,你把你的msdn换正版把,难道你的msdn和我的不一样,奇怪!WM_MOUSELEAVE到底是不是windows消息,我给你看看,我现在还用不上win64,不好意思:
    下面是msdn拷贝,自己看看吧:
      
    Platform SDK: Windows User Interface 
    WM_MOUSELEAVE
    The WM_MOUSELEAVE message is posted to a window when the cursor leaves the client area of the window specified in a prior call to TrackMouseEvent. A window receives this message through its WindowProc function. LRESULT CALLBACK WindowProc(
      HWND hwnd,       // handle to window
      UINT uMsg,       // WM_MOUSELEAVE
      WPARAM wParam,   // not used
      LPARAM lParam    // not used
    );
    Parameters
    This message has no parameters.Return Values
    If an application processes this message, it should return zero. Res
    All tracking requested by TrackMouseEvent is canceled when this message is generated. The application must call TrackMouseEvent when the mouse reenters its window if it requires further tracking of mouse hover behavior.Requirements 
      Windows NT/2000: Requires Windows NT 4.0 or later.
      Windows 95/98: Requires Windows 98 or later.
      Header: Declared in Winuser.h; include Windows.h.See Also
    Mouse Input Overview, Mouse Input Messages, GetCapture, SetCapture, TrackMouseEvent, TRACKMOUSEEVENT, WM_NCMOUSELEAVEBuilt on Thursday, October 12, 2000Requirements 
      Windows NT/2000: Requires Windows NT 4.0 or later.
      Windows 95/98: Requires Windows 98 or later.
      Header: Declared in Winuser.h; include Windows.h.
    See Also
    Mouse Input Overview, Mouse Input Messages, GetCapture, SetCapture, TrackMouseEvent, TRACKMOUSEEVENT, WM_NCMOUSELEAVE
      

  9.   

    to oldhawk(老鹰):上面贴一大堆东西,不好意思,因为我对他有点生气而已,呵呵
    给你的代码,很简单,值得注意的就一点,TrackMouseEvent的调用在窗体的mousemove里面,good lucky!!!:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
      private
        { Private declarations }    procedure MouseLeave(var Msg: TMessage); message WM_MOUSELEAVE;  public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    var
      xh: TTrackMouseEvent;
    begin
      xh.cbSize := sizeof(xh);
      xh.dwFlags := TME_LEAVE;
      xh.hwndTrack := Handle;
      xh.dwHoverTime := 0;
      TrackMouseEvent(xh);
    end;procedure TForm1.MouseLeave(var Msg: TMessage);
    begin
      Caption := Caption + '#';
      Msg.Result := 0;
    end;end.
      

  10.   

    浪人:
    在我的WINDOWS98S上测了一下,十分灵敏,感激不尽!分都给你了。
    后会有期!