Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/apps/mplayerc/OpenFileDlg.cpp')
-rw-r--r--src/apps/mplayerc/OpenFileDlg.cpp170
1 files changed, 85 insertions, 85 deletions
diff --git a/src/apps/mplayerc/OpenFileDlg.cpp b/src/apps/mplayerc/OpenFileDlg.cpp
index 0ad662ad9..e9f37ad3d 100644
--- a/src/apps/mplayerc/OpenFileDlg.cpp
+++ b/src/apps/mplayerc/OpenFileDlg.cpp
@@ -36,26 +36,26 @@ WNDPROC COpenFileDlg::m_wndProc = NULL;
IMPLEMENT_DYNAMIC(COpenFileDlg, CFileDialog)
COpenFileDlg::COpenFileDlg(CAtlArray<CString>& mask, bool fAllowDirSelection, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
- DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd)
- : CFileDialog(TRUE, lpszDefExt, lpszFileName, dwFlags|OFN_NOVALIDATE, lpszFilter, pParentWnd, 0)
- , m_mask(mask)
+ DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd)
+ : CFileDialog(TRUE, lpszDefExt, lpszFileName, dwFlags|OFN_NOVALIDATE, lpszFilter, pParentWnd, 0)
+ , m_mask(mask)
{
- m_fAllowDirSelection = fAllowDirSelection;
- m_pOFN->lpstrInitialDir = lpszFileName;
+ m_fAllowDirSelection = fAllowDirSelection;
+ m_pOFN->lpstrInitialDir = lpszFileName;
- m_buff = DNew TCHAR[10000];
- m_buff[0] = 0;
- m_pOFN->lpstrFile = m_buff;
- m_pOFN->nMaxFile = 10000;
+ m_buff = DNew TCHAR[10000];
+ m_buff[0] = 0;
+ m_pOFN->lpstrFile = m_buff;
+ m_pOFN->nMaxFile = 10000;
}
COpenFileDlg::~COpenFileDlg()
{
- delete [] m_buff;
+ delete [] m_buff;
}
BEGIN_MESSAGE_MAP(COpenFileDlg, CFileDialog)
- ON_WM_DESTROY()
+ ON_WM_DESTROY()
END_MESSAGE_MAP()
@@ -63,97 +63,97 @@ END_MESSAGE_MAP()
LRESULT CALLBACK COpenFileDlg::WindowProcNew(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- if(message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK
- && m_fAllowDirSelection)
- {
- CAutoVectorPtr<TCHAR> path;
- path.Allocate(MAX_PATH+1); // MAX_PATH should be bigger for multiple selection, but we are only interested if it's zero length
- // note: allocating MAX_PATH only will cause a buffer overrun for too long strings, and will result in a silent app disappearing crash, 100% reproducable
- if(::GetDlgItemText(hwnd, cmb13, (TCHAR*)path, MAX_PATH) == 0)
- ::SendMessage(hwnd, CDM_SETCONTROLTEXT, edt1, (LPARAM)__DUMMY__);
- }
-
- return CallWindowProc(COpenFileDlg::m_wndProc, hwnd, message, wParam, lParam);
+ if(message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK
+ && m_fAllowDirSelection)
+ {
+ CAutoVectorPtr<TCHAR> path;
+ path.Allocate(MAX_PATH+1); // MAX_PATH should be bigger for multiple selection, but we are only interested if it's zero length
+ // note: allocating MAX_PATH only will cause a buffer overrun for too long strings, and will result in a silent app disappearing crash, 100% reproducable
+ if(::GetDlgItemText(hwnd, cmb13, (TCHAR*)path, MAX_PATH) == 0)
+ ::SendMessage(hwnd, CDM_SETCONTROLTEXT, edt1, (LPARAM)__DUMMY__);
+ }
+
+ return CallWindowProc(COpenFileDlg::m_wndProc, hwnd, message, wParam, lParam);
}
BOOL COpenFileDlg::OnInitDialog()
{
- CFileDialog::OnInitDialog();
+ CFileDialog::OnInitDialog();
- m_wndProc = (WNDPROC)SetWindowLongPtr(GetParent()->m_hWnd, GWLP_WNDPROC , (LONG_PTR)WindowProcNew);
+ m_wndProc = (WNDPROC)SetWindowLongPtr(GetParent()->m_hWnd, GWLP_WNDPROC , (LONG_PTR)WindowProcNew);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
}
void COpenFileDlg::OnDestroy()
{
- int i = GetPathName().Find(__DUMMY__);
- if(i >= 0) m_pOFN->lpstrFile[i] = m_pOFN->lpstrFile[i+1] = 0;
+ int i = GetPathName().Find(__DUMMY__);
+ if(i >= 0) m_pOFN->lpstrFile[i] = m_pOFN->lpstrFile[i+1] = 0;
- CFileDialog::OnDestroy();
+ CFileDialog::OnDestroy();
}
BOOL COpenFileDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
- ASSERT(pResult != NULL);
-
- OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
- // allow message map to override
- if (__super::OnNotify(wParam, lParam, pResult))
- {
- ASSERT(pNotify->hdr.code != CDN_INCLUDEITEM);
- return TRUE;
- }
-
- switch(pNotify->hdr.code)
- {
- case CDN_INCLUDEITEM:
- if(OnIncludeItem((OFNOTIFYEX*)lParam, pResult))
- return TRUE;
- break;
- }
-
- return FALSE; // not handled
+ ASSERT(pResult != NULL);
+
+ OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
+ // allow message map to override
+ if (__super::OnNotify(wParam, lParam, pResult))
+ {
+ ASSERT(pNotify->hdr.code != CDN_INCLUDEITEM);
+ return TRUE;
+ }
+
+ switch(pNotify->hdr.code)
+ {
+ case CDN_INCLUDEITEM:
+ if(OnIncludeItem((OFNOTIFYEX*)lParam, pResult))
+ return TRUE;
+ break;
+ }
+
+ return FALSE; // not handled
}
BOOL COpenFileDlg::OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult)
{
- TCHAR buff[_MAX_PATH];
- if(!SHGetPathFromIDList((LPCITEMIDLIST)pOFNEx->pidl, buff))
- {
- STRRET s;
- HRESULT hr = ((IShellFolder*)pOFNEx->psf)->GetDisplayNameOf((LPCITEMIDLIST)pOFNEx->pidl, SHGDN_NORMAL|SHGDN_FORPARSING, &s);
- if(S_OK != hr) return FALSE;
- switch(s.uType)
- {
- case STRRET_CSTR:
- _tcscpy(buff, CString(s.cStr));
- break;
- case STRRET_WSTR:
- _tcscpy(buff, CString(s.pOleStr));
- CoTaskMemFree(s.pOleStr);
- break;
- default:
- return FALSE;
- }
- }
-
- CString fn(buff);
- /*
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if(GetFileAttributesEx(fn, GetFileExInfoStandard, &fad)
- && (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
- return FALSE;
- */
- int i = fn.ReverseFind('.'), j = fn.ReverseFind('\\');
- if(i < 0 || i < j)
- return FALSE;
-
- CString mask = m_mask[pOFNEx->lpOFN->nFilterIndex-1] + _T(";");
- CString ext = fn.Mid(i).MakeLower() + _T(";");
-
- *pResult = mask.Find(ext) >= 0 || mask.Find(_T("*.*")) >= 0;
-
- return TRUE;
+ TCHAR buff[_MAX_PATH];
+ if(!SHGetPathFromIDList((LPCITEMIDLIST)pOFNEx->pidl, buff))
+ {
+ STRRET s;
+ HRESULT hr = ((IShellFolder*)pOFNEx->psf)->GetDisplayNameOf((LPCITEMIDLIST)pOFNEx->pidl, SHGDN_NORMAL|SHGDN_FORPARSING, &s);
+ if(S_OK != hr) return FALSE;
+ switch(s.uType)
+ {
+ case STRRET_CSTR:
+ _tcscpy(buff, CString(s.cStr));
+ break;
+ case STRRET_WSTR:
+ _tcscpy(buff, CString(s.pOleStr));
+ CoTaskMemFree(s.pOleStr);
+ break;
+ default:
+ return FALSE;
+ }
+ }
+
+ CString fn(buff);
+ /*
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if(GetFileAttributesEx(fn, GetFileExInfoStandard, &fad)
+ && (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
+ return FALSE;
+ */
+ int i = fn.ReverseFind('.'), j = fn.ReverseFind('\\');
+ if(i < 0 || i < j)
+ return FALSE;
+
+ CString mask = m_mask[pOFNEx->lpOFN->nFilterIndex-1] + _T(";");
+ CString ext = fn.Mid(i).MakeLower() + _T(";");
+
+ *pResult = mask.Find(ext) >= 0 || mask.Find(_T("*.*")) >= 0;
+
+ return TRUE;
}