分类: C/C++
2012-01-27 01:38:47
1 | m_pMainWnd->DragAcceptFiles(TRUE); |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 | void CMainFrame::OnDropFiles(HDROP hDropInfo) { SetActiveWindow(); // activate us first ! UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0); CWinApp* pApp = AfxGetApp(); ASSERT(pApp != NULL); for (UINT iFile = 0; iFile < nFiles; iFile++) { TCHAR szFileName[_MAX_PATH]; ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH); pApp->OpenDocumentFile(szFileName); } ::DragFinish(hDropInfo); } |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | void CMainFrame::OnDropFiles(HDROP hDropInfo) { SetActiveWindow(); // activate us first ! UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0); CWinApp* pApp = AfxGetApp(); ASSERT(pApp != NULL); for (UINT iFile = 0; iFile < nFiles; iFile++) { TCHAR szFileName[_MAX_PATH]; ::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH); LPTSTR pszExtension = PathFindExtension(szFileName); if (pszExtension != NULL && *pszExtension == _T('.')) { _tcslwr_s(pszExtension, _tcslen(pszExtension) + 1); if (0 == _tcscmp(pszExtension, _T(".exe")) || 0 == _tcscmp(pszExtension, _T(".chm"))) { AfxMessageBox(_T("不支持的文件类型!")); } else pApp->OpenDocumentFile(szFileName); } } ::DragFinish(hDropInfo); } |