mfc radio button怎么实现单选

 我来答
huanglenzhi
2016-12-28 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
采纳数:117539 获赞数:517163
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。

向TA提问 私信TA
展开全部

  1新建一个基于对话框的应用程序,工程名为RadioButton。

  2

  如下图为对话框添加三个Radio Button。

  3

  为CRadioButtonDlg类添加颜色变量,记录当前背景颜色。

  4

  添加三个Radio Button的响应函数。

  void CRadioButtonDlg::OnRadio1()

  {

  // TODO: Add your control notification handler code here

  m_BKColor = RGB(255,0,0);

  Invalidate();

  }

  void CRadioButtonDlg::OnRadio2()

  {

  // TODO: Add your control notification handler code here

  m_BKColor = RGB(0,255,0);

  Invalidate();

  }

  void CRadioButtonDlg::OnRadio3()

  {

  // TODO: Add your control notification handler code here

  m_BKColor = RGB(0,0,255);

  Invalidate();

  }

  5

  改写CRadioButtonDlg类的OnPaint()函数

  void CRadioButtonDlg::OnPaint()

  {

  CRect rect;

  CPaintDC dc(this);

  GetClientRect(rect);

  dc.FillSolidRect(rect,m_BKColor);

  }

  

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式