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上测了一下,十分灵敏,感激不尽!分都给你了。 后会有期!
http://www.cnblogs.com/-clq/archive/2012/09/21/2696367.html
|
请发表评论