WM_SYSCOMMAND SC_MOVE占用鼠标事件,并且不触发鼠标 [英] WM_SYSCOMMAND SC_MOVE eats up mouse events and mouse up is not fired

查看:293
本文介绍了WM_SYSCOMMAND SC_MOVE占用鼠标事件,并且不触发鼠标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序是无边框窗口,我想在用户拖动对话框的任何部分时移动该窗口.使用WM_SYSCOMMAND后,所有后续鼠标事件都将丢失.

My program is a chromeless window and I want to move the window when user drag any part of my dialog. Once WM_SYSCOMMAND is used, all subsequent mouse events are lost.

首先,我编写了一个程序来捕获鼠标事件,并且一切都与WTL兼容​​.

First I wrote a program to capture the mouse events and all working fine with WTL.

BEGIN_MSG_MAP(CMainDlg)
    MSG_WM_LBUTTONUP(OnMouseUp)
    MSG_WM_LBUTTONDOWN(OnMouseDown)
....
LRESULT OnMouseDown ( UINT uKeys, CPoint pt ) {
    print ("on mouse down");
    return 0;
}
LRESULT OnMouseUp ( UINT uKeys, CPoint pt ) {
    print ("on mouse up");
    return 0;
}

然后我将上面的onMouseDown更改为

Then I change onMouseDown above to,

LRESULT OnMouseDown ( UINT uKeys, CPoint pt ) {
    print ("on mouse down");
    this->SendMessageW(WM_SYSCOMMAND, SC_MOVE|0x0002);
    return 0;
}

拖动正在起作用,并且窗口随鼠标一起移动.但是,不再触发OnMouseUp事件.

The drag is working and the windows move along with the mouse. However, OnMouseUp event is no longer fired.

尝试使用WM_NCHITTEST或ProcessMessage setHandled设置为true/false的许多不同方法都没有成功.

Tried many different approach using WM_NCHITTEST, or ProcessMessage setHandled to true/false without success.

非常感谢任何人有任何建议:)

Much appreciate if anyone has any suggestions :)

推荐答案

感谢您描述执行此操作的原因,因为有更好的方法:

Thanks for describing why you're doing this, because there's a much better approach: Return HTCAPTION in response to WM_NCHITTEST.

这篇关于WM_SYSCOMMAND SC_MOVE占用鼠标事件,并且不触发鼠标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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