MFC CButton点击能在OFF/ON之间切换
2013-08-28 15:06
155 查看
CButton控件点击后自动切换文本信息:
1. 继承一个CButton的类,增加函数
2. 函数代码为:
3. 添加消息处理:
4. 使用:在*Dlg.cpp中
1. 继承一个CButton的类,增加函数
protected: afx_msg BOOL OnClicked1(); |
BOOL CButton_Change::OnClicked1() { int lenght; lenght = GetWindowTextLengthW(); if(lenght==3){ this->SetWindowTextW(_T("ON")); }else{ this->SetWindowTextW(_T("OFF")); } return TRUE; } |
ON_CONTROL_REFLECT_EX(BN_CLICKED, &CButton_Change::OnClicked1) 最后为: BEGIN_MESSAGE_MAP(CButton_Change, CButton) ON_CONTROL_REFLECT_EX(BN_CLICKED, &CButton_Change::OnClicked1) END_MESSAGE_MAP() |
button = new CButton_Change; button->Create(_T("OFF"), 0, CRect(200, 200, 250, 250), this, IDC_BUTTON2); button->ShowWindow(TRUE); |
相关文章推荐
- MFC编程中,应用程序界面最小化与显示之间切换时,GDI对象增加
- MFC 设置按钮背景,点击后切换背景(不是按下时和松开时切换)
- Swift 点击按钮两张图片之间来回切换
- android中Imagebutton实现两张图片之间的点击来回切换
- Android Fragment之间的点击切换
- ViewPager+Fragment中fragment之间的切换的时候怎么设置调用onresume()
- mfc的项目里,想要实现点击tabcontrol的每个tab,切换到不同窗口显示不同摄像头的实时画
- jQuery实现两个CSS样式之间的点击切换
- Fragment之间切换时onResume效果的使用
- UITableView 之 点击cell 实现两个自定义cell之间的切换
- mfc 多窗口之间互相切换
- MFC学习笔记之OnPaint和OnDraw之间的关系
- Viewpager的竖直切换及其子fragment之间的点击跳转
- jquery 点击按钮切换样式on方法使用
- 使用ViewPager+LinearLayout来实现页面之间的切换和点击
- 点击CheckBox让Gridview控件在编辑与正常状态之间切换
- 〖Linux〗使用命令行切换触摸板的状态on/off/toggle
- 点击一个按钮实现在不同对话框之间的切换,帮忙看下这代码能不能这样写,为什么不对呀
- Flex 如何实现按钮之间的切换,按钮点击事件
- toggle的用法(点击更换不同的function)当指定元素被点击时,在两个或多个函数之间轮流切换。