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回调函数实现的。
hwnd是当前窗口的句柄。
uMsg是系统发过来的消息。
wParam是消息参数。
lParam是消息参数。
如果系统调用windowproc函数未处理,就直接 调用系统默认的 defWIndowproc,关于这个函数的详细解释,有个博客写的不错,推荐看下:
 
 URL:https://www.cnblogs.com/kingln/archive/2008/09/09/1287563.html

3、WM_NCACTIVATE message:
 

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);

4、WM_SIZING message
 

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.

 
  当用户改变了窗口的大小,发送给窗口,通过这个消息,一个应用程序可以监控它的大小和拖动矩形的位置,如果需要,修改他的大小和位置。
 
 
5、WM_NCHITTEST message
 

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:

Copy
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的处理的更多相关文章

  1. 仿win7窗体自动顶部最大化左侧右侧半屏效果(改写nativeEvent,使用AdjustWindowRectEx)

    #include "HMainWindow.h" #include <QApplication> #ifdef Q_OS_WIN #include <qt_win ...

  2. isHiden和isVisible的区别(可是有nativeEvent进行设置)

    之前一直对isHiden和isVisible的区别比较模糊,都是乱用的.今天因需要仔细看了一下. 1.isHiden只是返回部件的隐藏属性,并不能表示部件当前的真实状态.比如A部件有个子部件B,而A处 ...

  3. 如何在Qt中处理(接收/发送)MFC或Windows消息(直接覆盖MainDialog::nativeEvent,或者QApplication::installNativeEventFilter安装过滤器,或者直接改写QApplication::nativeEventFilter)

    关于接收: Receive WM_COPYDATA messages in a Qt app. 还有个中文网站: 提问: 如何在Qt中模拟MFC的消息机制 关于发送: 用Qt在Windows下编程,如 ...

  4. qt动态库实现无边框窗体的消息处理 nativeEvent的使用

    需求: 在动态库中创建一个窗口句柄,可以给外部调用,库的调用者,通过这个句柄发送消息到底层库,库里面可以实现对消息的处理 m_FHandle=AllocateHWnd(WndProcDllMsg); ...

  5. qt 拖拽 修改大小(使用了nativeEvent和winEvent)

    http://www.cnblogs.com/swarmbees/p/5621543.html http://blog.sina.com.cn/s/blog_9e59cf590102w3r6.html

  6. React Native 之 Text的使用

    前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...

  7. ReactNative入门 —— 动画篇(上)

    在不使用任何RN动画相关API的时候,我们会想到一种非常粗暴的方式来实现我们希望的动画效果——通过修改state来不断得改变视图上的样式. 我们来个简单的示例: var AwesomeProject ...

  8. React Native:使用 JavaScript 构建原生应用

    [转载] 本篇为联合翻译,译者:寸志,范洪春,kmokidd,姜天意 数月前,Facebook 对外宣布了正在开发的 React Native 框架,这个框架允许你使用 JavaScript 开发原生 ...

  9. React Native之 ScrollView介绍和使用

    前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...

随机推荐

  1. Java获取永久图文素材中的网页端Url

    package com.epalmpay.test; import com.alibaba.fastjson.JSON;import com.epalmpay.util.HttpClientUtil; ...

  2. 爬虫--requeste

    1.requeste模块,是我们Python对我们爬虫有好的一面,,其主要作用是用来模拟浏览器发起请求.功能强大,用法简洁高效.在爬虫领域中占据着半壁江山的地位.没有的话直接pip3 install  ...

  3. Oracle 事务操作

    在看本文之前,请确保你已经了解了Oracle事务和锁的概念即其作用,不过不了解,请参考数据库事务的一致性和原子性浅析和Oracle TM锁和TX锁 1.提交事务 当执行使用commit语句可以提交事务 ...

  4. Bugfree安装与使用

    第一步:下载XAMPP和bugfree http://www.bugfree.org.cn/ http://www.apachefriends.org/zh_cn/xampp.html 第二步:安装 ...

  5. c#各个版本的特性

    现在unity2018.2已经支持c#7.2了 版本特性: https://www.cnblogs.com/zq20/p/6323205.html

  6. 1.8 js基础(常用方法小结)

    1.获取随机数 var rdm=function(n,m){ return parseInt(n+Math.random()*(m-n)); } 2.位数不够补0 function toDou(inu ...

  7. idea maven install 卡住,无报错排查。

    今天使用idea打包,执行install,看控制台日志,卡主了(意思是日志不继续在控制台输打印了,卡主了,也看不到错误),也没有报错,然后进行排查. 进入dos命令,进入到项目的根目录,使用 运行 m ...

  8. fabu dao fenleizhong

    IsAggregated IsAggregatedIsAggregated IsAggregatedIsAggregated IsAggregatedIsAggregated IsAggregated ...

  9. MySQL 8.0 压缩包版安装方法

    转自:https://blog.csdn.net/yangs_2012/article/details/80412016 注意: 操作系统:Windows 10 专业版(64位) MySQL版本:my ...

  10. div按照屏幕尺寸(设备大小)进行缩放

    原理:利用css3 transform 属性 代码: body{ width: 810px; height: 340px; margin: 0px; padding: 0px; background- ...