操作步骤:
1,拖一个ListContorl控件
2,修改ID名称
3,设置Report样式
3,加入初始化代码
void CDuplicatefilesclearDlg::InitlizationListView()
{CListCtrl *lstVew= (CListCtrl*)GetDlgItem(IDC_LIST_Main);lstVew->SetExtendedStyle(/*LVS_EX_GRIDLINES |*/ LVS_EX_FLATSB | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES|LVS_EX_CHECKBOXES); while (lstVew->DeleteColumn (0));//删除所有列lstVew->DeleteAllItems() ; // 删除所有行//--------------lstVew->InsertColumn(0,_T("序号"),LVCFMT_CENTER,40,0);//设置列 lstVew->InsertColumn(1,_T("路径"),LVCFMT_LEFT,150,1); lstVew->InsertColumn(2,_T("文件名"),LVCFMT_LEFT,100,1); lstVew->InsertColumn(3,_T("大小"),LVCFMT_LEFT,80,1); lstVew->InsertColumn(4,_T("MD5值"),LVCFMT_LEFT,100,1); lstVew->InsertColumn(5,_T("是否重复"),LVCFMT_LEFT,60,1); lstVew->InsertColumn(6,_T("是否移动"),LVCFMT_LEFT,60,1); lstVew->InsertColumn(7,_T("重复数量"),LVCFMT_LEFT,60,1); lstVew->InsertColumn(8,_T("创建时间"),LVCFMT_LEFT,80,1); lstVew->InsertColumn(9,_T("修改时间"),LVCFMT_LEFT,80,1);
}
4,在::OnInitDialog()加入初始化调用,及增加记录
BOOL CDuplicatefilesclearDlg::OnInitDialog()
{CDialog::OnInitDialog();// Add "About..." menu item to system menu.// IDM_ABOUTBOX must be in the system command range.ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);CMenu* pSysMenu = GetSystemMenu(FALSE);if (pSysMenu != NULL){CString strAboutMenu;strAboutMenu.LoadString(IDS_ABOUTBOX);if (!strAboutMenu.IsEmpty()){pSysMenu->AppendMenu(MF_SEPARATOR);pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);}}// Set the icon for this dialog. The framework does this automatically// when the application's main window is not a dialogSetIcon(m_hIcon, TRUE); // Set big iconSetIcon(m_hIcon, FALSE); // Set small icon// TODO: Add extra initialization hereInitlizationListView();CString strNo;CListCtrl *lstVew= (CListCtrl*)GetDlgItem(IDC_LIST_Main);for(int i=0;i<10;i++){strNo.Format("%d",i);lstVew->InsertItem(i,strNo);lstVew->SetItemText(i,1,_T("C:\\Users\\stw\\duplicatefilesclear\\"));lstVew->SetItemText(i,2,_T("duplicatefilesclear.exe"));lstVew->SetItemText(i,3,_T("123"));lstVew->SetItemText(i,4,_T("3FE42EA23200000"));lstVew->SetItemText(i,5,_T("0"));lstVew->SetItemText(i,6,_T("1"));lstVew->SetItemText(i,7,_T("2"));lstVew->SetItemText(i,8,_T("2024年5月13日16:15:48"));lstVew->SetItemText(i,9,_T("2024年5月13日16:15:48"));}return TRUE; // return TRUE unless you set the focus to a control
}
5,运行效果
6,完整代码上传到资源