在 WndProc 中处理 AeroSnap 消息 [英] Handling AeroSnap message in WndProc

查看:23
本文介绍了在 WndProc 中处理 AeroSnap 消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 C# .NET 4 应用程序中,我使用 WndProc 来处理一些主要处理应用程序大小调整为全屏的消息.

In my C# .NET 4 application, I use WndProc to process some messages mostly dealing with resizing the application to and from full screen.

现在我只是在处理 SC_MAXIMIZEWM_NCLBUTTONDBLCLK 以确定窗口的大小是否调整为最大化状态或从最大化状态(我知道我不需要 WndProc处理 SC_MAXIMIZE,但是当我双击应用程序的标题栏时,Form_Resize 似乎没有触发 WM_NCLBUTTONDBLCLK 消息.

Right now I am just handling SC_MAXIMIZE and WM_NCLBUTTONDBLCLK to determine if the window is being resized to or from a maximized state (I know I don't need WndProc to handle SC_MAXIMIZE, but Form_Resize didn't seem to fire for a WM_NCLBUTTONDBLCLK message when I double-click on the application's title bar.

现在我注意到,如果我 Aero Snap 窗口到屏幕顶部以最大化它,则上述消息都不会发布,因此当通过 Aero Snap 最大化窗口时不会应用某些逻辑.如果窗口被捕捉到屏幕顶部而不是向右或向左,或者如果窗口从最大化位置取消捕捉,我只想处理消息.

Now I noticed that if I Aero Snap the window to the top of the screen to maximize it, neither of the above messages are posted so certain logic is not applied when the window is maximized via Aero Snap. I only want to handle the message if the window is snapped to the top of the screen rather than the right or left, or if a window is unsnappped from maximized position.

我找不到任何与 Aero Snap 相关的窗口消息.有谁知道这些消息的任何参考资料?

I couldn't find any of the window messages related to Aero Snap. Does anyone know of any references for those messages?

推荐答案

我猜这里没有任何特殊信息;Aero 可能只是使用普通的 Win32 API - ShowWindow(SW_MAXIMIZE) 和类似的.

I'm guessing there aren't any special messages here; Aero is likely just using the plain Win32 APIs - ShowWindow(SW_MAXIMIZE) and similar.

要理解 SC_ 消息的是,这些是来自菜单的请求,要求窗口自行调整大小/恢复/等,但这并不是更改窗口大小的唯一机制.可能发生的情况是,当窗口获得 SC_MAXIMIZE 时,DefWndProc 通过调用 ShowWindow(SW_MAXIMIZE) 来实现这一点.

The thing to uderstand with the SC_ messages are that those are requests from a menu asking the window to resize/restore/etc itself, but that is not the only mechanism for changing the windows's size. What's probably happening is that when a window gets SC_MAXIMIZE, the DefWndProc implements this by calling ShowWindow(SW_MAXIMIZE).

最好的方法是听 WM_SIZE 消息,窗口接收到的消息,无论是什么触发了大小更改:系统菜单、API 或其他方式.特别是,lParam 会让您知道窗口是最大化 (SIZE_MAXIMIZED) 还是恢复 (SIZE_RESTORED).

Your best best is to listen to the WM_SIZE message, which the window receives, regardless of what triggered the size change: system menu, API, or other means. In particular, the lParam will let you know if the window was maximized (SIZE_MAXIMIZED) or restored (SIZE_RESTORED).

这篇关于在 WndProc 中处理 AeroSnap 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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