谢谢~
解决方案 »
- 怎样实现MFC对话框自定义按钮的透明化
- activex 安装程序的制作 急!
- access访问数据库时最长只能取255个字符?
- 我添加了一个DataGrid,界面显示出来的姓名跟性别这两个列的宽度太长了,怎么方便用vc调整?
- 关于SHFileOperation的使用,帮帮忙
- 小妹提问简单问题,有关ADO连接SQL SERVER,谢谢了
- 局域网接入INTERNET,客户机网页打不开,但QQ可以上,怎么搞的??????
- 搜索老是出现这样的错误:数字参数不允许为空!!()
- VC++vc++深入详解第一章的例子,编译成功,但运行出不来窗口,求犀利来帮忙看看
- 这个Lua基础语法 那里错了?
- 托盘图标的问题
- 工程间通信
这个也许对楼主有帮助
------------------------------
关于 WM_NCLBUTTONUP 消息
WM_NCLBUTTONDOWN 消息的使用体会:
当窗口不是最大化时, 鼠标在标题栏上按下去时会产生 WM_NCLBUTTONDOWN 消息, 鼠标释放时却不会收到 WM_NCLBUTTONUP 消息, 感觉很奇怪, MSDN上的解释:
The WM_NCLBUTTONUP message is posted when the user releases the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted.
WM_NCLBUTTONUP
nHittest = (INT) wParam; // hit-test value
pts = MAKEPOINTS(lParam); // mouse-cursor coordinates
不过更奇怪的是当鼠标在标题栏上按下去再弹起时用 Spy++ 可以看到程序有抛出 WM_LBUTTONUP 消息 , 应用程序却没有收到这个消息. 为什么会这样?!
看MFC的源码, 没看出什么来, 到网上找资料,比较多的是用 Mouse Hook 来解决的, 而且也没有说明原因, 这儿是用 Mouse Hook 方式的解决办法:
http://www.codeguru.com/Cpp/misc/misc/windowsmessaging/article.php/c3885/
呵呵, 个人感觉比较笨拙, 后面又在 www.codeguru.com 上找到的另外一种解决办法,并且有说明了为什么会产生用 Spy++可以看见, 应用程序却没有收到消息的原因:
AlanMason : WM_NCLBUTTONUP not posted
Alex Fedotov: The problem is that to implement window movementand resizing, DefWindowProc organizes its own message loop. The WM_LBUTTONUP message is posted to the thread's message queue, but it is fetched in that internal message loop and not in the mainapplication message loop, so the application does not see the message. A possible solution is to install a thread-localmouse hook. It might look like an overkill, but should work - the hook should receive that message. Another way is to poll mouse status calling GetKeyState(VK_LBUTTON) on a timer. This methodlooks not so reliable for me, as the mouse button might be released and pressed again between timer events. Finally, you can process WM_EXITSIZEMOVE message. This message is sent to a window after it has exited the moving or sizing modal loop. This applies toboth mouse and keyboard way of doing that.原文见: http://www.codeguru.com/forum/showthread.php?t=172016
什么时候会收到这个消息, 根据网上收集的资料和个人经验, 有三种情况:
1. 当在标题栏双击时会产生
2. 当窗口最大化时, 单击标题栏等非客户区会产生
3. 在客户区按下鼠标左键, 移动鼠标到非客户区, 松开鼠标左键会产生.
---------------
各位大侠的提供的方法有时间研究下,...谢谢各位!!