在 WndProc 中处理 AeroSnap 消息

编程入门 行业动态 更新时间:2024-10-22 23:36:50
本文介绍了在 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_MAXIMIZE 和 WM_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 消息

本文发布于:2023-10-13 00:05:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486253.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   WndProc   AeroSnap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!