Chinaunix首页 | 论坛 | 博客
  • 博客访问: 21625
  • 博文数量: 11
  • 博客积分: 91
  • 博客等级: 民兵
  • 技术积分: 120
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-02 16:14
文章分类
文章存档

2016年(11)

我的朋友
最近访客

分类: C/C++

2016-07-05 16:26:29

/*

功能:操作复选框

环境:VS2013 VC++

时间:2016-06-28

作者:linkun

*/



void CMFCApplication3Dlg::OnBnClickedButton1()

{

       //comobox操作

       CString s;

       CString s1,s2,s3;

       LPCTSTR it1, it2,it3;


       s1 = "aa";

       s2 = "bb";

       s3 = "cc";


       it1 = (LPCTSTR)s1;

       it2 = (LPCTSTR)s2;

       it3 = (LPCTSTR)s3;


       //清除所有项

       ((CComboBox*)GetDlgItem(IDC_COMBO1))->ResetContent();


       //添加细项

       ((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString(it1);

       ((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString(it2);

       ((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString(it3);


       ((CComboBox*)GetDlgItem(IDC_COMBO1))->SetCurSel(1);//设置第1行内容为显示的内容。


       //读取值

       GetDlgItem(IDC_COMBO1)->GetWindowTextW(s);

       SetDlgItemText(IDC_EDIT1, s);

}


void CMFCApplication3Dlg::OnBnClickedButton5()

{

       CString s,str;

       int iPos = ((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel();//当前选中的行。

       int iCount = ((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCount();


       /*

         int 转CString

         ANSI下 CString a;  int b = 0;       a.format("%d", b);

         UINCODE下要改成 

       */

       s.Format(_T("%d"), iCount);

       str.Format(_T("%d"), iPos);

       SetDlgItemText(IDC_EDIT1, s+"条/当前第"+str+"条");



}

 

阅读(819) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~