当鼠标左键处于按下状态时,不会收到WM_NCMOUSELEAVE [英] WM_NCMOUSELEAVE is not received when mouse left button is in pressed state

查看:291
本文介绍了当鼠标左键处于按下状态时,不会收到WM_NCMOUSELEAVE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


大家好,

Hi all,


我正在开发一个自定义表单。

I'm developing a custom form.


为此,我从System.Windows.Forms.Form类派生了类,并重写了WndProc(ref Message m)方法。

For that I have derived the class from System.Windows.Forms.Form class and overridden the WndProc(ref Message m) method.


我已经处理了WM_NCMOUSEMOVE,WM_NCMOUSELEAVE,WM_NCLBUTTONDOW N个窗口消息为标题栏按钮的正常,悬停和按下状态提供不同的外观。

I have processed the WM_NCMOUSEMOVE, WM_NCMOUSELEAVE, WM_NCLBUTTONDOWN window messages to provide different appearance for the normal, hover and pressed state of the title bar buttons.


我在处理WM_NCMOUSEMOVE时使用了以下代码,以便接收WM_NCMOUSELEAVE。

I have used the below code while processing WM_NCMOUSEMOVE in order to receive WM_NCMOUSELEAVE.

if (!isMouseTracked)
        {
            var trackMouseEvent = new TRACKMOUSEEVENT();
            trackMouseEvent.cbSize = Marshal.SizeOf(trackMouseEvent);
            trackMouseEvent.hwndTrack = this.Handle;
            trackMouseEvent.dwFlags = WindowMessages.TME_LEAVE | WindowMessages.TME_NONCLIENT;
            TrackMouseEvent(ref trackMouseEvent);
            isMouseTracked = true;
        }



这是正常的。

This works correctly.


当我点击非客户区域时,没有收到WM_NCMOUSELEAVE,并且
将光标移出窗体而不释放鼠标按钮。


请建议我如何处理这个问题。

Please suggest me how to proceed with this problem.


提前致谢。

Thanks in advance.






推荐答案

Hi Mohanram,

Hi Mohanram,

来自  MSDN 我们可以获得有关WM_NCMOUSELEAVE的以下消息:

From MSDN we can get the following message about WM_NCMOUSELEAVE:

当光标离开窗口的非客户区域时发布到窗口在事先调用TrackMouseEvent中指定。

因此,此消息不用于执行操作,即按住鼠标然后移动,因此无法触发当您单击非客户区域并将光标移出表格而不释放鼠标按钮时。

So this message is not used to do the operation that keep the mouse pressed and then move, so of cause it can not fire when you click on the non client area and move the cursor out of the form without releasing the mouse button.

我建议您检查是否有相应的Windows消息。

I suggest you can check if there is a corresponding windows message to do it.

问候,

Stanly


这篇关于当鼠标左键处于按下状态时,不会收到WM_NCMOUSELEAVE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆