zoukankan      html  css  js  c++  java
  • MFC创建ListCtrl(待补充。。。。)

    背景条件:在对话框里面添加ListCtrl资源。

    1.在对话框添加一个ListCtrl资源,ListCtrl属性View设置为Report,竖形显示。

    2.然后给该ListCtrl资源添加类:打开类向导,添加类CMyListCtrl,继承自基类CListCtrl。

    3.ListCtrl资源绑定类变量,选择自己刚刚建过的类CMyListCtrl,成员变量m_ListCtrl。

    4.准备工作做好后,就开始在对话框的OnInitDlag函数里面添加初始化代码了。

    	// TODO:  在此添加额外的初始化代码
    	DWORD dwOldStyle = m_ListCtrl.GetExtendedStyle();//获取原风格,可以在添加有复选框样式的表格
    	m_ListCtrl.SetExtendedStyle(dwOldStyle | LVS_EX_FULLROWSELECT 
    		| LVS_EX_GRIDLINES);//若设置复选框样式,在此添加LVS_CHECK宏
    	//获取表格的宽度
    	CRect rc;
    	m_ListCtrl.GetClientRect(rc);
    	int nWidth = rc.Width();
    	//为List插入列信息
    	m_ListCtrl.InsertColumn(0, _T("进程名称"), 0, nWidth / 4);
    	m_ListCtrl.InsertColumn(1, _T("PID"), 0, nWidth / 4);
    	m_ListCtrl.InsertColumn(2, _T("线程数"), 0, nWidth / 4);
    	m_ListCtrl.InsertColumn(3, _T("优先级"), 0, nWidth / 4);

    插入行:

      //插入10行   
      for(int i=0;i<10;i++)
      {
         m_ListCtrl.InsertItem(i, stcPe32.szExeFile);//插入第i行/i行0列
            //sPid.Format(_T("%d"), stcPe32.th32ProcessID);
    	//sNum.Format(_T("%d"), stcPe32.cntThreads);
    	//sPri.Format(_T("%d"), stcPe32.pcPriClassBase);
    	m_ListCtrl.SetItemText(i, 1, sPid);i行1列
    	m_ListCtrl.SetItemText(i, 2, sNum);i行2列
    	m_ListCtrl.SetItemText(i, 3, sPri);i行3列
      }
    

      

  • 相关阅读:
    day25:接口类和抽象类
    vue1
    How the weather influences your mood?
    机器学习实验方法与原理
    How human activities damage the environment
    Slow food
    Brief Introduction to Esports
    Massive open online course (MOOC)
    Online learning in higher education
    Tensorflow Dataset API
  • 原文地址:https://www.cnblogs.com/wingss/p/5122883.html
Copyright © 2011-2022 走看看