如何判断指定按纽是否处于按下状态?

shazhushe 2006-11-20 10:50:31
请教如何判断指定的CBUTTON 按纽控件是否处于按下状态? 最好用代码说明. 多谢

...全文
349 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shazhushe 2007-04-06
  • 打赏
  • 举报
回复
To: dawnwinds(D版痞子)

"在这个类的WM_LBUTTONDOWN事件处理函数里发消息通知对话框按钮按下"怎样通知?
楼上高手能否说明白点?
syy64 2006-11-20
  • 打赏
  • 举报
回复 1
按钮按下时有响应函数的。

CButton::GetState
UINT GetState( ) const;

Return Value

Specifies the current state of the button control. You can use the following masks against the return value to extract information about the state:

Mask Meaning
0x0003 Specifies the check state (radio buttons and check boxes only). A 0 indicates the button is unchecked. A 1 indicates the button is checked. A radio button is checked when it contains a bullet (). A check box is checked when it contains an X. A 2 indicates the check state is indeterminate (three-state check boxes only). The state of a three-state check box is indeterminate when it contains a halftone pattern.
0x0004 Specifies the highlight state. A nonzero value indicates that the button is highlighted. A button is highlighted when the user clicks and holds the left mouse button. The highlighting is removed when the user releases the mouse button.
0x0008 Specifies the focus state. A nonzero value indicates that the button has the focus.


Remarks

Retrieves the state of a radio button or check box.

CButton Overview | Class Members | Hierarchy Chart

See Also CButton::GetCheck, CButton::SetCheck, CButton::SetState,BM_GETSTATE
dawnwinds 2006-11-20
  • 打赏
  • 举报
回复
按下按钮的时候,不会触发dialog的WM_LBUTTONDOWN事件。
可以自己写个类继承CButton,在这个类的WM_LBUTTONDOWN事件处理函数里发消息通知对话框按钮按下
syy64 2006-11-20
  • 打赏
  • 举报
回复
if(p->GetCheck()==1){
shazhushe 2006-11-20
  • 打赏
  • 举报
回复
我在CDIALOG中重载WM_LBUTTONDOWN和WM_LBUTTONUP,在ONLBUTTONDOWN()事件函数中添加如下代码:
{ CButton *P=(CButton *)GetDlgItem(IDC_BUTTON1);
if(p->GetCheck()){
AfxMessageBox("OK");
}
}

怎么执行不到IF条件中去?  求教?

15,976

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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