16,472
社区成员
发帖
与我相关
我的任务
分享
void CremarksecretDlg::ListShow(int pageNo)
{
UINT nCount=fileList.size(); //得到控件的行数 总的文件个数。
UINT i;
//int pageNo=1;
Start=pageSize*(pageNo-1);
End=pageSize*pageNo;
CString empty; //难道是这里定义错了?
CString name;
CString time;
CString fpath;
mlist.LockWindowUpdate();
mlist.DeleteAllItems(); //要想实现翻页效果这句必不可少。
for(i=Start;i<End;i++) //改成i=0;i<50也还是不行,这里不是逻辑出了问题,而是其它的问题。
{
if(i>=nCount)break;
empty.Format(_T("%d"),i+1);
int nRow=mlist.InsertItem(i,empty); //这句话什么意思?
afxDump<<nRow<<"\n"; //这句对翻页没有影响
name.Format(_T("%s\n"),fileList[i].szFileName.c_str());
mlist.SetItemText(nRow,1,name); //插入列 自注:从这里开始程序就不对了,这句还是对的
time.Format(_T("%s\n"),fileList[i].szCreateTime.c_str());
mlist.SetItemText(nRow,2,time);
fpath.Format(_T("%s\n"),fileList[i].szFilePath.c_str()); //不影响翻页
mlist.SetItemText(nRow,3,fpath);
}
mlist.UnlockWindowUpdate();
// getchar();
}
void CremarksecretDlg::OnCbnSelchangeCombo()
{
// TODO: 在此添加控件通知处理程序代码
}
CString CremarksecretDlg::GetSecurityLevel()
{
CString cmbName;
mComeboBox.GetWindowText(cmbName);//"1: 公开";
int at=cmbName.ReverseFind(' ');
return cmbName.Right(cmbName.GetLength()-at-1);
}
void CremarksecretDlg::OnBnClickedButton4()
{
// TODO: 在此添加控件通知处理程序代码
CString sl=GetSecurityLevel();
POSITION pos = mlist.GetFirstSelectedItemPosition();
int nSelectedItem = -1;
while (pos!=NULL)
{
nSelectedItem = mlist.GetNextSelectedItem(pos);
CString name = mlist.GetItemText(nSelectedItem,1);
CString path = mlist.GetItemText(nSelectedItem,3);
CString extname=name.Right(name.GetLength()-name.ReverseFind('.'));
CString pureName=name.Left(name.ReverseFind('.'));
CString newName=path;
newName += "\\";
newName += pureName;
newName += sl;// "机密";// 增加的
newName += extname;
AfxMessageBox(path + "\\"+ name + " To " + newName);
// CFile::Rename(path + "\\"+ name, newName );
}
}
这两段程序中都有CString变量,变量相同,有没有冲突啊?我这些程序这么写被证实有问题,因为没有在文件名后面添加(公开),(内部),(秘密)等密级,请问是怎么回事。
// rename
CString CShowdirDlg::GetSecurityLevel()
{
CString cmbName;
m_Cmb1.GetWindowText(cmbName);//"1: 公开";
int at=cmbName.ReverseFind(' ');
return cmbName.Right(cmbName.GetLength()-at-1);
}
//
void CShowdirDlg::OnButton4()
{
// TODO: Add your control notification handler code here
CString sl=GetSecurityLevel();
POSITION pos = m_list.GetFirstSelectedItemPosition();
int nSelectedItem = -1;
while (pos != NULL)
{
nSelectedItem = m_list.GetNextSelectedItem(pos);
CString name = m_list.GetItemText(nSelectedItem,1);
CString path = m_list.GetItemText(nSelectedItem,3);
CString extname=name.Right(name.GetLength()-name.ReverseFind('.'));
CString pureName=name.Left(name.ReverseFind('.'));
CString newName=path;
newName += "\\";
newName += pureName;
newName += sl;// "机密";// 增加的
newName += extname;
AfxMessageBox(path + "\\"+ name + " To " + newName);
// CFile::Rename(path + "\\"+ name, newName );
}
}