http://topic.csdn.net/t/20020104/09/456913.html
CM_MouseLeave訊息好象不太靈敏,當滑鼠快速移出窗體時,就收不到這個訊息,請問大家有什麼好辦法嗎?
#1樓 得分:0回覆於:2002-01-04 09:32:23
那就用上一級元件的CM_MouseEnter配合
#2樓 得分:0回覆於:2002-01-04 11:05:35
移出窗體了,不行。
#3樓 得分:0回覆於:2002-01-04 11:14:54
cm_mouseleave的確不太好用,應該用wm_mouseleave這個訊息結合trackmouseevent這個api使用!絕對好用,呵呵,只不過比cm_mouseleave麻煩一點點了!
#4樓 得分:0回覆於:2002-01-04 11:14:59
要SetCapture
#5樓 得分:0回覆於:2002-01-04 11:17:54
使用wndpro函式
#6樓 得分:0回覆於:2002-01-04 11:25:13
我正好有同樣的問題,上面幾位的意見都不一樣,能不能說的詳細一點。
#7樓 得分:0回覆於:2002-01-04 11:31:08
wm_mouseleave是windows的訊息,我測試過處理mouseleave絕對很不錯,雖然必須結合trackmouseevent函式使用,不是很方便,但是效果嘛,最好!
#8樓 得分:0回覆於:2002-01-05 21:44:56
好象不行,trackmouseevent是NT的函式。
我在98下試了試,沒有反應。
#9樓 得分:0回覆於:2002-01-06 15:12:19
不會呀,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.
#10樓 得分:0回覆於:2002-01-06 17:37:18
但我手邊的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;
不行。
#11樓 得分:0回覆於:2002-01-06 19:23:53
明天給你一個例子
#12樓 得分:0回覆於:2002-01-06 19:57:43
wm_mouseleave是windows的訊息嗎?瞎搞嘛!你說的是win64還是win32啊
#13樓 得分:0回覆於:2002-01-06 19:58:54
.net中有這個訊息啊
#14樓 得分:0回覆於:2002-01-06 21:37:09
先謝了。
另外說一句,我剛試了用SetCapture的方法,但效果不好。
#15樓 得分:0回覆於:2002-01-07 08:53:59
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.
Remarks
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_NCMOUSELEAVE
Built 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
#16樓 得分:40回覆於:2002-01-07 08:56:28
to oldhawk(老鷹):上面貼一大堆東西,不好意思,因為我對他有點生氣而已,呵呵
給你的程式碼,很簡單,值得注意的就一點,TrackMouseEvent的呼叫在窗體的mousemove裡面,good lucky!!!:
unit Unit1;
interface
uses
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.
#17樓 得分:0回覆於:2002-01-07 12:03:54
浪人:
在我的WINDOWS98S上測了一下,十分靈敏,感激不盡!分都給你了。
後會有期!