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. bitset用法

    学习博客:https://www.cnblogs.com/magisk/p/8809922.html C++的 bitset 在 bitset 头文件中,它是一种类似数组的结构,它的每一个元素只能是0 ...

  2. setSelectionRange方法解决光标错位问题

    inputElement.setSelectionRange(value.length, value.length);

  3. List与IList的区别

    在我看一个源程序的时候看到这个例子使用了IList<T>返回类型,因为上午刚刚总结过List<T>的详细用法,突然出现了IList<T>,感觉很奇怪,于是上网搜集了 ...

  4. Web性能优化之雅虎军规

    相信互联网已经越来越成为人们生活中不可或缺的一部分.Ajax,flex等等富客户端的应用使得人们越加“幸福”地体验着许多原先只能在C/S实 现的功能. 比如Google机会已经把最基本的office应 ...

  5. JS框架设计之主流框架的引入机制DomeReady一种子模块

    DomReady其实是一种名为"DomContentLoaded"事件的名称,不过由于框架的需要,它与真正的DomContentLoaded有区别,在旧的JS书籍中m都会让我们把J ...

  6. Cookie跳转登录验证码

    对于web应用来说,大部分的系统在用户登录时都要求用户输入验证码,验证码的类型的很多,有字母数字的,有汉字的,甚至还要用户输入一条算术题的答案的, 对于系统来说使用验证码可以有效果的防止采用机器猜测方 ...

  7. 使用SubstanceDesign和Unity插件ShaderForge制作风格化火焰

    使用 SubstanceDesign 软件可以制作shader用的特殊图片,原来真有这种软件,一直好奇这种图片怎么做的 https://www.kancloud.cn/hazukiaoi/sd_sf_ ...

  8. 解决MysqlWorkbench Export Data时报错:'delayed-insert'=FALSE

  9. jenkins配置权限不对导致无法登陆或者空白页面解决办法

    找到.jenkins/config.xml文件:替换为:1.<authorizationStrategy class="hudson.security.AuthorizationStr ...

  10. shiro的授权

    1.授权的流程 2.三种授权方式 1.编程式:通过写if/else 授权代码块完成: Subject subject = SecurityUtils.getSubject(); if(subject. ...