const int WM_SYSCOMMAND = 0x0112;const int SC_CLOSE = 0xF060;

changuncle
博客专家认证
2016-08-18 10:33:52
看见标题恐怕就已经猜到我要问什么了。
我知道这是Windows消息机制的东西,百度百科里能找到const int WM_SYSCOMMAND = 0x0112;,但是找不到const int SC_CLOSE = 0xF060;,不知道有多少个SC开头的命令,各自的作用又是什么?
还有大家请看我的这段简单代码:
protected override void WndProc(ref Message msg)
{
const int WM_SYSCOMMAND666 = 0x0112;//多了666
const int SC_CLOSE666 = 0xF060;//多了666

if (msg.Msg == WM_SYSCOMMAND666 && ((int)msg.WParam == SC_CLOSE666))
{
Application.Exit();
}
base.WndProc(ref msg);
}
也能正常运行,其实WM_SYSCOMMAND或其他以WM、SC开头的Windows命令重要的是参数值而不是参数名,当然参数名命名合理可以直接看出该参数的作用。

最后一共两个问题:
①SC开头的命令是哪来的,有多少个,各自的作用是什么?
②我对Windows消息参数的理解正确吗?
...全文
652 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
changuncle 2016-08-19
  • 打赏
  • 举报
回复
引用 8 楼 dongxinxi 的回复:
左边是变量随便你叫什么xxx,你试试右边值多个666要能跑再来问
右边的值应该不能变吧
  • 打赏
  • 举报
回复
左边是变量随便你叫什么xxx,你试试右边值多个666要能跑再来问
redshiliu 2016-08-19
  • 打赏
  • 举报
回复
详情去看MSDN,WM_SYSCOMMAND支持以下参数

<tbody><tr responsive="true"><th>Value</th><th>Meaning</th></tr>
<tr><td data-th="Value"><a id="SC_CLOSE"></a><a id="sc_close"></a><dl>
<dt><strong>SC_CLOSE</strong></dt>
<dt>0xF060</dt>
</dl>
</td><td data-th="Meaning">
<p>Closes the window.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_CONTEXTHELP"></a><a id="sc_contexthelp"></a><dl>
<dt><strong>SC_CONTEXTHELP</strong></dt>
<dt>0xF180</dt>
</dl>
</td><td data-th="Meaning">
<p>Changes the cursor to a question mark with a pointer. If the user then clicks a control in the dialog box, the control receives a <a href="https://msdn.microsoft.com/en-us/library/bb774305(v=vs.85).aspx"><strong xmlns="http://www.w3.org/1999/xhtml">WM_HELP</strong></a> message.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_DEFAULT"></a><a id="sc_default"></a><dl>
<dt><strong>SC_DEFAULT</strong></dt>
<dt>0xF160</dt>
</dl>
</td><td data-th="Meaning">
<p>Selects the default item; the user double-clicked the window menu.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_HOTKEY"></a><a id="sc_hotkey"></a><dl>
<dt><strong>SC_HOTKEY</strong></dt>
<dt>0xF150</dt>
</dl>
</td><td data-th="Meaning">
<p>Activates the window associated with the application-specified hot key. The 
						<em>lParam</em> parameter identifies the window to activate.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_HSCROLL"></a><a id="sc_hscroll"></a><dl>
<dt><strong>SC_HSCROLL</strong></dt>
<dt>0xF080</dt>
</dl>
</td><td data-th="Meaning">
<p>Scrolls horizontally.</p>
</td></tr>
<tr><td data-th="Value"><a id="SCF_ISSECURE"></a><a id="scf_issecure"></a><dl>
<dt><strong>SCF_ISSECURE</strong></dt>
<dt>0x00000001</dt>
</dl>
</td><td data-th="Meaning">
<p>Indicates whether the screen saver is secure. </p>
</td></tr>
<tr><td data-th="Value"><a id="SC_KEYMENU"></a><a id="sc_keymenu"></a><dl>
<dt><strong>SC_KEYMENU</strong></dt>
<dt>0xF100</dt>
</dl>
</td><td data-th="Meaning">
<p>Retrieves the window menu as a result of a keystroke. For more information, see the Remarks section.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_MAXIMIZE"></a><a id="sc_maximize"></a><dl>
<dt><strong>SC_MAXIMIZE</strong></dt>
<dt>0xF030</dt>
</dl>
</td><td data-th="Meaning">
<p>Maximizes the window.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_MINIMIZE"></a><a id="sc_minimize"></a><dl>
<dt><strong>SC_MINIMIZE</strong></dt>
<dt>0xF020</dt>
</dl>
</td><td data-th="Meaning">
<p>Minimizes the window.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_MONITORPOWER"></a><a id="sc_monitorpower"></a><dl>
<dt><strong>SC_MONITORPOWER</strong></dt>
<dt>0xF170</dt>
</dl>
</td><td data-th="Meaning">
<p>Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer. 
                    
						  
						  
                    </p>
<p>The <em>lParam</em> parameter can have the following values:</p>
<ul>
<li>-1 (the display is powering on)</li>
<li> 1 (the display is going to low power)</li>
<li> 2 (the display is being shut off)</li>
</ul>
</td></tr>
<tr><td data-th="Value"><a id="SC_MOUSEMENU"></a><a id="sc_mousemenu"></a><dl>
<dt><strong>SC_MOUSEMENU</strong></dt>
<dt>0xF090</dt>
</dl>
</td><td data-th="Meaning">
<p>Retrieves the window menu as a result of a mouse click.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_MOVE"></a><a id="sc_move"></a><dl>
<dt><strong>SC_MOVE</strong></dt>
<dt>0xF010</dt>
</dl>
</td><td data-th="Meaning">
<p>Moves the window.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_NEXTWINDOW"></a><a id="sc_nextwindow"></a><dl>
<dt><strong>SC_NEXTWINDOW</strong></dt>
<dt>0xF040</dt>
</dl>
</td><td data-th="Meaning">
<p>Moves to the next window.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_PREVWINDOW"></a><a id="sc_prevwindow"></a><dl>
<dt><strong>SC_PREVWINDOW</strong></dt>
<dt>0xF050</dt>
</dl>
</td><td data-th="Meaning">
<p>Moves to the previous window.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_RESTORE"></a><a id="sc_restore"></a><dl>
<dt><strong>SC_RESTORE</strong></dt>
<dt>0xF120</dt>
</dl>
</td><td data-th="Meaning">
<p>Restores the window to its normal position and size.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_SCREENSAVE"></a><a id="sc_screensave"></a><dl>
<dt><strong>SC_SCREENSAVE</strong></dt>
<dt>0xF140</dt>
</dl>
</td><td data-th="Meaning">
<p>Executes the screen saver application specified in the [boot] section of the System.ini file.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_SIZE"></a><a id="sc_size"></a><dl>
<dt><strong>SC_SIZE</strong></dt>
<dt>0xF000</dt>
</dl>
</td><td data-th="Meaning">
<p>Sizes the window.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_TASKLIST"></a><a id="sc_tasklist"></a><dl>
<dt><strong>SC_TASKLIST</strong></dt>
<dt>0xF130</dt>
</dl>
</td><td data-th="Meaning">
<p>Activates the <strong>Start</strong> menu.</p>
</td></tr>
<tr><td data-th="Value"><a id="SC_VSCROLL"></a><a id="sc_vscroll"></a><dl>
<dt><strong>SC_VSCROLL</strong></dt>
<dt>0xF070</dt>
</dl>
</td><td data-th="Meaning">
<p>Scrolls vertically.</p>
</td></tr>
</tbody>
Poopaye 2016-08-19
  • 打赏
  • 举报
回复
引用 4 楼 xiaouncle 的回复:
[quote=引用 2 楼 shingoscar 的回复:] 1、位于winuser.h中 2、不知道你理解到了什么?
winuser.h中有那些以WM开头的值, const int SC_MINIMIZE = 0xF020; const int SC_MAXMIZE = 0xF030; const int SC_CLOSE = 0xF060; 但是winuser.h中没有0xF020、0xF030、0xF060的定义, 0xF020、0xF030、0xF060是怎么来的啊?请大哥帮忙解释下......[/quote] 这些是数字啊,这你都不知道?
changuncle 2016-08-18
  • 打赏
  • 举报
回复
引用 2 楼 shingoscar 的回复:
1、位于winuser.h中 2、不知道你理解到了什么?
找到0xF020、0xF030、0xF060的定义了,别人写的不全,源码是有的
changuncle 2016-08-18
  • 打赏
  • 举报
回复
引用 2 楼 shingoscar 的回复:
1、位于winuser.h中 2、不知道你理解到了什么?
winuser.h中有那些以WM开头的值, const int SC_MINIMIZE = 0xF020; const int SC_MAXMIZE = 0xF030; const int SC_CLOSE = 0xF060; 但是winuser.h中没有0xF020、0xF030、0xF060的定义, 0xF020、0xF030、0xF060是怎么来的啊?请大哥帮忙解释下......
changuncle 2016-08-18
  • 打赏
  • 举报
回复
引用 2 楼 shingoscar 的回复:
1、位于winuser.h中 2、不知道你理解到了什么?
,WM_SYSCOMMAND等一些以WM开头的常量和SC_CLOSE等一些以SC开头的常量,他们的名字跟普通常量一样可以随便起,不一定必须是WM_SYSCOMMAND可以是WM_SYSCOMMAND666
Poopaye 2016-08-18
  • 打赏
  • 举报
回复
1、位于winuser.h中 2、不知道你理解到了什么?
Poopaye 2016-08-18
  • 打赏
  • 举报
回复
看到标题我也不知道你想问啥

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧