windows 复选框 - 更改通知

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1546270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:15:54  来源:igfitidea点击:

checkbox - change notification

windowswinapicheckbox

提问by Mike D

What notification code is sent with the wm_command message to the dialog box procedure when a check box changes state?

当复选框改变状态时,什么通知代码与 wm_command 消息一起发送到对话框过程?

And more importantly, where would I look in the msdn to find the notification codes for various controls?

更重要的是,我应该在 msdn 中的何处查找各种控件的通知代码?

采纳答案by Nick Dandoulakis

Note that Check boxes and Radio buttons are Buttons. So they send click and double click messages, BN_CLICKEDand BN_DOUBLECLICKED.

请注意,复选框和单选按钮是按钮。所以他们发送点击和双击消息,BN_CLICKED以及BN_DOUBLECLICKED.

If you use MFC, then you can examine the checkstate with CButton::GetCheckmethod. Otherwise you send the BM_GETCHECKmessage to the control: SendMessage(button_handle, BM_GETCHECK, 0, 0);

如果使用 MFC,则可以check使用CButton::GetCheck方法检查状态。否则,您将BM_GETCHECK消息发送到控件:SendMessage(button_handle, BM_GETCHECK, 0, 0);

SendMessagecan return

SendMessage可以返回

  • BST_CHECKEDButton is checked.
  • BST_INDETERMINATEButton is grayed, indicating an indeterminate state (applies only if the button has the BS_3STATEor BS_AUTO3STATEstyle).
  • BST_UNCHECKEDButton is cleared
  • If the button has a style other than those listed, the return value is zero.
  • BST_CHECKED按钮被选中。
  • BST_INDETERMINATE按钮呈灰色,表示处于不确定状态(仅当按钮具有BS_3STATEBS_AUTO3STATE样式时才适用)。
  • BST_UNCHECKED按钮被清除
  • 如果按钮的样式不是列出的样式,则返回值为零。

If you use the Visual Studio, the easiest way to get a list of events/messages a control can send is to go to Resource/Design view, right click a control and select Events.

如果您使用 Visual Studio,获取控件可以发送的事件/消息列表的最简单方法是转到 Resource/Design 视图,右键单击控件并选择Events

For a list of common controls see: Control Library
(in the page you'll see a popup menu with the controls if you hover the cursor on the Control Librarylink)

有关常用控件的列表,请参阅:控件库
(在页面中,如果将光标悬停在控件库链接上,您将看到带有控件的弹出菜单)

回答by Martin v. L?wis

It's BN_CLICKED. The bottom of the page links to the button messages.

它是BN_CLICKED。页面底部链接到按钮消息。