关于NativeEvent的处理
nativeEvent(const QByteArray &eventType, void *message, long *result)
{
chASSERT(message != NULL);
MSG* winMsg = static_cast<MSG *>(message);
HWND hWnd = winMsg->hwnd;
switch (winMsg->message)
nativeEvent获取windows的事件处理,暂时用到的几个消息:
1、WM_NCCALCSIZE message
MicroSoft的Docs的解释:
Sent when the size and position of a window's client area must be calculated. By processing this message, an application can control the content of the window's client area when the size or position of the window changes.
当windows程序的客户端区域的位置和大小发生变化时,会发出这个消息。通过这个程序,当它的位置和大小发生变化时,一个应用程序可以控制windows客户端区域。
2、WM_NCPAINT message :
The WM_NCPAINT message is sent to a window when its frame must be painted.
A window receives this message through its WindowProc function.
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
); 当窗口的边框需求重新绘制的时候,会给窗口发送这个消息。
这个消息的发出,是系统通过调用窗口的windowproc
回调函数实现的。
Sent to a window when its nonclient area needs to be changed to indicate an active or inactive state.
A window receives this message through its WindowProc function.
当窗口的非客户端区域发生变化时,这个消息将被发送到窗口,来指示当前是活跃还是非活跃状态,这个消息也是通过,windowproc回调实现的。
注意:窗口激活时和反激活时会触发系统重绘非客户区以反应窗口状态更改,所以需要在将lparam 传入-1阻止系统重绘窗体边框。
解释如下:
Remarks
Processing messages related to the nonclient area of a standard window is not recommended, because the application must be able to draw all the required parts of the nonclient area for the window. If an application does process this message, it must return TRUE to direct the system to complete the change of active window. If the window is minimized when this message is received, the application should pass the message to the DefWindowProc function.
举例:
case WM_NCACTIVATE:
auto res = DefWindowProc(winMsg->hwnd, winMsg->message, winMsg->wParam, -1);
Sent to a window that the user is resizing. By processing this message, an application can monitor the size and position of the drag rectangle and, if needed, change its size or position.
A window receives this message through its WindowProc function.
Sent to a window in order to determine what part of the window corresponds to a particular screen coordinate. This can happen, for example, when the cursor moves, when a mouse button is pressed or released, or in response to a call to a function such as WindowFromPoint. If the mouse is not captured, the message is sent to the window beneath the cursor. Otherwise, the message is sent to the window that has captured the mouse.
A window receives this message through its WindowProc function.
发送到窗口,用来确定,窗口的某一个位置面对应屏幕的某一个坐标。这个发生的时候,例如,当鼠标移动,或者当鼠标的按键点击或松开。或者是对一个函数的调用,比如window frompoint。如果鼠标没有被捕获,消息就会被发送到光标下面的窗口。否则,消息被发送到捕获鼠标的窗口。
注意:不要使用LOWORD或HIWORD宏来提取光标位置的x和y坐标,因为这些宏在具有多个监视器的系统上返回不正确的结果。有多个显示器的系统可以有负x和y坐标,
Remarks
Use the following code to obtain the horizontal and vertical position:
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
As noted above, the x-coordinate is in the low-order short of the return value; the y-coordinate is in the high-order short (both represent signed values because they can take negative values on systems with multiple monitors). If the return value is assigned to a variable, you can use the MAKEPOINTS macro to obtain a POINTS structure from the return value. You can also use the GET_X_LPARAM or GET_Y_LPARAMmacro to extract the x- or y-coordinate.
[!Important]
Do not use the LOWORD or HIWORD macros to extract the x- and y- coordinates of the cursor position because these macros return incorrect results on systems with multiple monitors. Systems with multiple monitors can have negative x- and y- coordinates, and LOWORD and HIWORD treat the coordinates as unsigned quantities.
顺便说下:WindowFromPoint function
Retrieves a handle to the window that contains the specified point.
HWND WINAPI WindowFromPoint(
_In_ POINT Point
);
这个函数,获取包含指定点的窗口的句柄。
6、WM_TIMECHANGE message
时间变化
7、WM_WTSSESSION_CHANGE message
Notifies applications of changes in session state.
通知应用程序在会话状态下的变化。
关于NativeEvent的处理的更多相关文章
- 仿win7窗体自动顶部最大化左侧右侧半屏效果(改写nativeEvent,使用AdjustWindowRectEx)
#include "HMainWindow.h" #include <QApplication> #ifdef Q_OS_WIN #include <qt_win ...
- isHiden和isVisible的区别(可是有nativeEvent进行设置)
之前一直对isHiden和isVisible的区别比较模糊,都是乱用的.今天因需要仔细看了一下. 1.isHiden只是返回部件的隐藏属性,并不能表示部件当前的真实状态.比如A部件有个子部件B,而A处 ...
- 如何在Qt中处理(接收/发送)MFC或Windows消息(直接覆盖MainDialog::nativeEvent,或者QApplication::installNativeEventFilter安装过滤器,或者直接改写QApplication::nativeEventFilter)
关于接收: Receive WM_COPYDATA messages in a Qt app. 还有个中文网站: 提问: 如何在Qt中模拟MFC的消息机制 关于发送: 用Qt在Windows下编程,如 ...
- qt动态库实现无边框窗体的消息处理 nativeEvent的使用
需求: 在动态库中创建一个窗口句柄,可以给外部调用,库的调用者,通过这个句柄发送消息到底层库,库里面可以实现对消息的处理 m_FHandle=AllocateHWnd(WndProcDllMsg); ...
- qt 拖拽 修改大小(使用了nativeEvent和winEvent)
http://www.cnblogs.com/swarmbees/p/5621543.html http://blog.sina.com.cn/s/blog_9e59cf590102w3r6.html
- React Native 之 Text的使用
前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...
- ReactNative入门 —— 动画篇(上)
在不使用任何RN动画相关API的时候,我们会想到一种非常粗暴的方式来实现我们希望的动画效果——通过修改state来不断得改变视图上的样式. 我们来个简单的示例: var AwesomeProject ...
- React Native:使用 JavaScript 构建原生应用
[转载] 本篇为联合翻译,译者:寸志,范洪春,kmokidd,姜天意 数月前,Facebook 对外宣布了正在开发的 React Native 框架,这个框架允许你使用 JavaScript 开发原生 ...
- React Native之 ScrollView介绍和使用
前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...
随机推荐
- redis cluster 部署过程
一, 特点 高性能: 1.在多分片节点中,将16384个槽位,均匀分布到多个分片节点中 2.存数据时,将key做crc16(key),然后和16384进行取模,得出槽位值(0-16383之间) 3.根 ...
- oracle--等待事件
1. Buffer busy waits 从本质上讲,这个等待事件的产生仅说明了一个会话在等待一个Buffer(数据块),但是导致这个现象的原因却有很多种,常见的两种是:当一个会话试图修改一个数据块, ...
- linux磁盘分区fdisk命令详解
1.什么是分区? 分区是将一个硬盘驱动器分成若干个逻辑驱动器,分区是把硬盘连续的区块当做一个独立的磁硬使用.分区表是一个硬盘分区的索引,分区的信息都会写进分区表.2.为什么要有多个分区? 防止数 ...
- openerp学习笔记 domain 的应用
1.在Action中定义,domain用于对象默认的搜索条件: 示例: <record id="action_orders" model="ir.actions.a ...
- gcd函数两种实现(参考)
注意: %a= a%-----溢出 递归: #include<stdio.h> int gcd(m,n) { int g; ) g=m; else g=gcd(n,m%n) return ...
- Call to a member function assign() on null
Thinkphp: 在子控制器里面写了一个构造函数,如下 //构造函数 public function __construct(){ echo 1; } 结果页面报错了 ----> Call ...
- php根据IP获取所在省份-淘宝api接口
这里用的file_put_contents,你也可以用别的,直接怼代码: //拼接传递的参数$ip = '175.12.53.12' $opts = array( 'http'=>array( ...
- [转]Asp.Net Web API 2第十七课——Creating an OData Endpoint in ASP.NET Web API 2(OData终结点)
本文转自:http://www.cnblogs.com/aehyok/p/3545824.html 前言 很久没更新博客了,加上刚过年,现在准备重新开战,继续自己的学习之路.本文已同步到Web API ...
- List和Queue使用过程中的纪录
业务需求: 发送特定的请求,根据返回的信息执行特定的事件. 目前的做法:把我的请求放入一个容器内,然后待到某一条件,就从这个容器把请求发送出去,等客户返回信息时,查询容器中对应请求中特定的事件.开始的 ...
- java 类与对象基础整理
之前学习javaSE的时候,没有针对性地对对类与对象的一些基础进行整理,下面这些内容是笔记内容整理后的,希望以后自己可以通过这些博客时常复习! 一.类and对象的基础 类似于类的生命啊,类与对象的关系 ...