WM_SYSCOMMAND奇数 [英] WM_SYSCOMMAND oddities

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

问题描述

应用程序收到 WM_SYSCOMMAND 消息当用户在系统菜单上选择菜单项命令时,wParam可以是SC_CLOSE,SC_CONTEXTHELP,SC_MAXIMIZE,SC_MINIMIZE,SC_RESTORE等.这是合乎逻辑的. (当然,您也可以通过单击最小化",最大化",关闭"按钮等来发送这些消息.)

An application recieves the WM_SYSCOMMAND message when the user selects a menu item command on the system menu, and so wParam can be SC_CLOSE, SC_CONTEXTHELP, SC_MAXIMIZE, SC_MINIMIZE, SC_RESTORE etc. That's logical. (Of course you can also send these messages by clicking on the minimize, maximize, close buttons etc.)

但是也可以发送WM_SYSCOMMAND消息以将命令发送到Windows Shell.例如,可以显示开始菜单(SC_TASKLIST),激活屏幕保护程序(SC_SCREENSAVE),然后关闭监视器(SC_MONITORPOWER).这没有道理,对吗?这与应用程序的系统菜单有什么关系?这更多是系统命令",即更多是消息名称"WM_SYSCOMMAND"的完全其他解释.就像该消息用于向系统发送命令请求一样.

But one can also send the WM_SYSCOMMAND message to send commands to the Windows Shell. For instance, one can display the start menu (SC_TASKLIST), activate the screen saver (SC_SCREENSAVE), and turn off the monitor (SC_MONITORPOWER). This does not make sense, does it? What does this have to do with the application's system menu? This is more of a "system command", i.e. more of a completely other interpretation of the name "WM_SYSCOMMAND" of the message. It's like the message is used to send command requests to the system.

为什么此消息用于两个看似完全不同的事物,而"SYSCOMMAND"名称是指什么事物(系统菜单上的命令或操作系统的命令)?

Why is this message used for two seemingly entirely different things, and what thing does the name "SYSCOMMAND" refer to (command on the system menu, or command of the operating system)?

推荐答案

当用户从窗口"菜单(以前称为系统或控制菜单)中选择命令时,或者当用户选择最大化"按钮,最小化"按钮,还原"按钮或关闭"按钮时,窗口就会收到此消息.

A window receives this message when the user chooses a command from the Window menu (formerly known as the system or control menu) or when the user chooses the maximize button, minimize button, restore button, or close button.

当用户使用系统菜单或标题按钮时,这些WM_SYSCOMMAND(最大化,最小化,还原,关闭以及系统菜单中的WM_SYSCOMMAND)可能会发送到您的窗口.我相信(我的Win32非常生锈)通常由DefWindowProc处理,该工作完成所有肮脏的工作,然后将通知发送到您的窗口(WM_SIZE/WM_SIZING,WM_CLOSE等).

These WM_SYSCOMMANDs (maximize, minimize, restore, close, and the ones in the system menu) may be sent to your window when the user uses the system menu or the caption buttons. I believe (my Win32 is very rusty) these are normally handled by DefWindowProc which does all the dirty work and then sends a notification to your window (WM_SIZE/WM_SIZING, WM_CLOSE, etc.).

现在,进一步往下移动(隐藏在底部的方框中):

Now, further down (hidden in the blurb at the bottom):

通过将WM_SYSCOMMAND消息传递给DefWindowProc,应用程序可以随时执行任何系统命令.该应用程序未处理的所有WM_SYSCOMMAND消息都必须传递给DefWindowProc.

An application can carry out any system command at any time by passing a WM_SYSCOMMAND message to DefWindowProc. Any WM_SYSCOMMAND messages not handled by the application must be passed to DefWindowProc.

您还可以通过将其发送到DefWindowProc来执行特定的WM_SYSCOMMAND.这些包括上面提到的内容,但也包括其他内容,例如SC_SCREENSAVE和SC_TASKLIST.我不知道通过DefWindowProc之类的路径(如SC_SCREENSAVE)最终会触发屏幕保护程序,但是就是这样.

You can also execute a particular WM_SYSCOMMAND by sending it to the DefWindowProc. These include the ones mentioned above, but they also include additional ones such as SC_SCREENSAVE and SC_TASKLIST. I have no idea what kind of path through DefWindowProc something like SC_SCREENSAVE would take to eventually end up triggering the screensaver, but that's how it is.

所以我看到的是WM_SYSCOMMAND的整个类都是系统命令.只是其中一些(可从窗口标题访问的)被发送到窗口,而另一些则由窗口自行决定.

So the way I see it is the entire class of WM_SYSCOMMANDs are system commands. It's just that some of them (the ones accessible from a window's caption) are sent to the window and others are sent by the window at your discretion.

这篇关于WM_SYSCOMMAND奇数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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