Undo

//CString sleFilePath;

//sleFilePath.Format(_T("All Files (*.*)|*.txt|"));

 

//分解

RETURN_INFO CmfcDlg::SplitString(const CString strSource, const int nNumber, const TCHAR* SplitSym, vector<CString> &strSubStr)
{
 RETURN_INFO ri = NP_OK;

 result strRlt;

 CString Source = strSource;
 int first = 0;
 int last = COMMON_FIND_NOTFIND;

 for (int i = 0; i < nNumber - 1; ++ i)
 {
  // 定位last位置
  last = strSource.Find(SplitSym[i], first);
  if (COMMON_FIND_NOTFIND == last)
  {
   ri = NP_FAILED;
   break;
  }

  strSubStr.push_back(strSource.Mid(first, last - first));

  first = last + 1;
  last = COMMON_FIND_NOTFIND;
 }

 if (NP_OK != ri)
 {
  return ri;
 }

 strSubStr.push_back(strSource.Mid(first, strSource.GetLength() - first));

 return ri;
} //初始化ListBox表頭 listCtrl = (CListCtrl*)GetDlgItem(IDC_LIST); listCtrl->SetExtendedStyle(WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_EX_GRIDLINES); listCtrl->InsertColumn(0,_T("時間"), LVCFMT_LEFT, 150); listCtrl->InsertColumn(1,_T("地點"), LVCFMT_LEFT, 150); listCtrl->InsertColumn(2,_T("人物"), LVCFMT_LEFT, 150); //插入數據 listCtrl->InsertItem(0,_T("2010年12月6日")); listCtrl->InsertItem(1,_T("fgdh")); listCtrl->InsertItem(2,_T("dfh"));

 

 

 

 

 

void CExcelDlg::PutOut(const CString s1,const CString s2)
{
//

excelCtrl->InsertItem(0,s1);
excelCtrl->SetItemText(0,1,s2);
}

 

 

 

 

 

 

 

 

//選擇目錄按鈕
void CDcPackerDlg::OnBnClickedDecgen()
{
char szPath[MAX_PATH]; //存放選擇的目錄路徑
CString str;

ZeroMemory(szPath, sizeof(szPath));

BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = szPath;
bi.lpszTitle = "請選擇需要打包的目錄:";
bi.ulFlags = 0;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
//彈出選擇目錄對話框
LPITEMIDLIST lp = SHBrowseForFolder(&bi);

if(lp && SHGetPathFromIDList(lp, szPath))
{
str.Format("選擇的目錄爲 %s", szPath);
AfxMessageBox(str);


}
else
AfxMessageBox("無效的目錄,請重新選擇");
}


選擇文件對話框

CString CDcPackerDlg::BootOpenDialog() //返回選擇的文件名稱
{
CString strFile = _T("");

CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("Describe Files (*.cfg)|*.cfg|All Files (*.*)|*.*||"), NULL);

if (dlgFile.DoModal())
{
strFile = dlgFile.GetPathName();
}

return strFile;
}

//加載文件按鈕
void CDcPackerDlg::OnBnClickedSelectdec()
{
// TODO: Add your control notification handler code here
m_strDescPath = ""; //類的成員變量

//"打開文件"對話框,選擇文件,返回其路徑
m_strDescPath = BootOpenDialog();


}

 

 

 

 

 

sSql = L"INSERT INTO demo (Name,Age) VALUES ('" + s1 + L"','" + s2 + L"')";

 

 

 

 

 

 

 

 

void Cmfc_tDlg::OnBnClickedButtonChoose()
{
// TODO: 在此添加控件通知處理程序代碼
CFileDialog fileDlg(TRUE,_T("*.txt"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,L"All Txt File (*.txt)|*.txt||",this);
//CFileDialog FDlg(TRUE , ".doc" , NULL , OFN_HIDEREADONLY , "word文件(*.doc)|*.doc|所有文件(*.*) |*.*||" );

CString file[20];
int i=0;
CString msg;
CFileFind finder;

if (IDOK==fileDlg.DoModal())
{
CString filePath=fileDlg.GetPathName();

int nPos = filePath.ReverseFind('//');
CString f_Name = filePath.Left(nPos);
//MessageBox(f_Name);

f_Name +="//*.txt";
BOOL bWorking = finder.FindFile(f_Name);

while (bWorking)
{
bWorking = finder.FindNextFile();
file[i] = finder.GetFileName();
i++;
}

for (int j=0;j<i;j++)
{
msg = msg + file[j]; //顯示點擊的文件所在文件夾下所有.txt的文件
}
MessageBox(msg);

SetDlgItemText(IDC_EDIT,filePath);

selFilePath=fileDlg.GetFileName();
}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章