Browse Source

Merge branch 'master' of http://gitz.zhixinhuixue.net:18880/zxhx-client-tool/pdfproject

duanjianjun 2 years ago
parent
commit
12cde80804
2 changed files with 61 additions and 0 deletions
  1. 57 0
      MFCApplication1/MFCApplication1Dlg.cpp
  2. 4 0
      MFCApplication1/MFCApplication1Dlg.h

+ 57 - 0
MFCApplication1/MFCApplication1Dlg.cpp

@@ -140,6 +140,8 @@ BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
 	ON_BN_CLICKED(IDOK, &CMFCApplication1Dlg::OnBnClickedOk)
 	ON_MESSAGE(WM_SHOWINFO, OnShowInfo)
 	ON_BN_CLICKED(IDCANCEL, &CMFCApplication1Dlg::OnBnClickedCancel)
+	ON_BN_CLICKED(IDC_BTN_TXT, &CMFCApplication1Dlg::OnBnClickedBtnTxt)
+	ON_BN_CLICKED(IDC_BTN_PDF, &CMFCApplication1Dlg::OnBnClickedBtnPdf)
 END_MESSAGE_MAP()
 
 
@@ -271,3 +273,58 @@ void CMFCApplication1Dlg::OnBnClickedCancel()
 	SAFETY_EXIT_THREAD(_threadProcess, 100);
 	CDialogEx::OnCancel();
 }
+
+void CMFCApplication1Dlg::SelectFolder(HWND hwnd, CString& lpszFolder)
+{
+	TCHAR szFolderPath[MAX_PATH];
+	szFolderPath[0] = 0;
+	BROWSEINFO	sInfo;
+	::ZeroMemory(&sInfo, sizeof(BROWSEINFO));
+	sInfo.pidlRoot = 0;
+	sInfo.lpszTitle = _T("请选择一个文件夹");
+	sInfo.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
+	sInfo.lpfn = NULL;
+	sInfo.hwndOwner = hwnd;
+	LPITEMIDLIST  lpidlBrowse = ::SHBrowseForFolder(&sInfo);
+
+	if (lpidlBrowse != NULL) {
+		if (::SHGetPathFromIDList(lpidlBrowse, szFolderPath)) {
+			lpszFolder = szFolderPath;
+			lpszFolder.Replace('\\', '/');
+		}
+		::CoTaskMemFree(lpidlBrowse);
+	}
+}
+
+void CMFCApplication1Dlg::OnBnClickedBtnTxt()
+{
+	CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_TXT);
+	if (!pEdit)
+	{
+		return;
+	}
+	CString strText;
+	SelectFolder(GetSafeHwnd(), strText);
+	if (strText.GetLength() == 0)
+	{
+		return;
+	}
+	pEdit->SetWindowText(strText);
+}
+
+
+void CMFCApplication1Dlg::OnBnClickedBtnPdf()
+{
+	CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_PDF);
+	if (!pEdit)
+	{
+		return;
+	}
+	CString strText;
+	SelectFolder(GetSafeHwnd(), strText);
+	if (strText.GetLength() == 0)
+	{
+		return;
+	}
+	pEdit->SetWindowText(strText);
+}

+ 4 - 0
MFCApplication1/MFCApplication1Dlg.h

@@ -38,4 +38,8 @@ public:
 
 	void UpdateMsg(CString strMsg);
 	afx_msg void OnBnClickedCancel();
+
+	void SelectFolder(HWND hwnd, CString& lpszFolder);
+	afx_msg void OnBnClickedBtnTxt();
+	afx_msg void OnBnClickedBtnPdf();
 };