CFileDialog類對象 調用GetFolderPath()運行錯誤

	CFileDialog dlg(TRUE);
	CString mFilePath;
	mFilePath = dlg.GetFolderPath();
	if (dlg.DoModal() == IDOK)
	{
		CWnd *pWnd = GetDlgItem(IDC_STATIC_SHOW); 
		pWnd->SetWindowTextW(m_fileExt);	
	}
GetFolderPath()
此函數只有在對話框存在的情況下,也就是你沒點擊打開時可調用,如果此對話框
已經關掉,則不能調用GetFolderPath();
MSDN 提示第2條:
Remarks
The dialog box must have been created with the OFN_EXPLORER style; otherwise, the method will fail with an assertion.

You can call this method only while the dialog box is being displayed. After the dialog box has been closed, this function will no longer work, and the method will fail with an assertion.

發佈了18 篇原創文章 · 獲贊 4 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章