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:
authorAleksoid <aleksoid@users.sourceforge.net>2008-10-02 09:52:50 +0400
committerAleksoid <aleksoid@users.sourceforge.net>2008-10-02 09:52:50 +0400
commita134935b5f8ddb5c7e8bb84ead882a6e2814d9fe (patch)
tree0c064b0218cca0c25c039d914882b859840a3022 /src/apps/mplayerc/PPageFormats.cpp
parentb272f2a944ec9aec76c6704808ca31d4a9b6f723 (diff)
ADD : Rebuild Icons cache after Formats associate;
ADD : Support for mpciconlib.dll - dll with icons for different type of files(mpciconlib project add later) git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@815 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps/mplayerc/PPageFormats.cpp')
-rw-r--r--src/apps/mplayerc/PPageFormats.cpp125
1 files changed, 121 insertions, 4 deletions
diff --git a/src/apps/mplayerc/PPageFormats.cpp b/src/apps/mplayerc/PPageFormats.cpp
index 5fb95158a..88583d36c 100644
--- a/src/apps/mplayerc/PPageFormats.cpp
+++ b/src/apps/mplayerc/PPageFormats.cpp
@@ -25,6 +25,7 @@
#include "mplayerc.h"
#include "PPageFormats.h"
#include <psapi.h>
+#include <string>
// CPPageFormats dialog
@@ -39,7 +40,6 @@ CString g_strRegisteredKey = _T("Software\\Clients\\Media\\Media Player Cla
int f_setContextFiles = 0;
int f_getContextFiles = 0;
-
IMPLEMENT_DYNAMIC(CPPageFormats, CPPageBase)
CPPageFormats::CPPageFormats()
: CPPageBase(CPPageFormats::IDD, CPPageFormats::IDD)
@@ -195,7 +195,26 @@ bool CPPageFormats::IsRegistered(CString ext, CString strProgID)
return !!bIsDefault;
}
-bool CPPageFormats::RegisterExt(CString ext, CString strProgID, CString strLabel, bool fRegister)
+CString GetProgramDir()
+{
+ CString RtnVal;
+ TCHAR FileName[MAX_PATH];
+ ::GetModuleFileName(AfxGetInstanceHandle(), FileName, MAX_PATH);
+ RtnVal = FileName;
+ RtnVal = RtnVal.Left(RtnVal.ReverseFind('\\'));
+ return RtnVal;
+}
+
+int FileExists(const TCHAR *fileName)
+{
+ DWORD fileAttr;
+ fileAttr = ::GetFileAttributes(fileName);
+ if (0xFFFFFFFF == fileAttr)
+ return false;
+ return true;
+}
+
+bool CPPageFormats::RegisterExt(CString ext, CString strProgID, CString strLabel, bool fRegister, int iconIndex)
{
CRegKey key;
bool bSetValue;
@@ -250,7 +269,20 @@ bool CPPageFormats::RegisterExt(CString ext, CString strProgID, CString strLabel
CString AppIcon = _T("");
TCHAR buff[MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH))
+ CString mpciconlib = GetProgramDir() + _T("\\mpciconlib.dll");
+ CString m_typeicon;
+ if(FileExists(mpciconlib)) m_typeicon = mpciconlib;
+
+ if(!m_typeicon.IsEmpty())
+ {
+ if(ExtractIcon(AfxGetApp()->m_hInstance,(LPCWSTR)m_typeicon, iconIndex))
+ {
+ m_typeicon = "\""+mpciconlib+"\"";
+ AppIcon.Format(_T("%s,%d"), m_typeicon, iconIndex);
+ }
+ }
+
+ if((AppIcon.IsEmpty()) && (::GetModuleFileName(AfxGetInstanceHandle(), buff, MAX_PATH)))
{
AppIcon = buff;
AppIcon = "\""+AppIcon+"\"";
@@ -265,6 +297,89 @@ bool CPPageFormats::RegisterExt(CString ext, CString strProgID, CString strLabel
return(true);
}
+void CPPageFormats::RebuildIconsCache() // source get from TSVN Windows client ...
+{
+ const int BUFFER_SIZE = 1024;
+ TCHAR *buf = NULL;
+ HKEY hRegKey = 0;
+ DWORD dwRegValue;
+ DWORD dwRegValueTemp;
+ DWORD dwSize;
+ DWORD_PTR dwResult;
+ LONG lRegResult;
+ std::wstring sRegValueName;
+ std::wstring sDefaultIconSize;
+ int iDefaultIconSize;
+ bool bResult = false;
+
+ lRegResult = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop\\WindowMetrics"),
+ 0, KEY_READ | KEY_WRITE, &hRegKey);
+ if (lRegResult != ERROR_SUCCESS)
+ goto Cleanup;
+
+ buf = new TCHAR[BUFFER_SIZE];
+ if(buf == NULL)
+ goto Cleanup;
+
+ // we're going to change the Shell Icon Size value
+ sRegValueName = _T("Shell Icon Size");
+
+ // Read registry value
+ dwSize = BUFFER_SIZE;
+ lRegResult = RegQueryValueEx(hRegKey, sRegValueName.c_str(), NULL, NULL,
+ (LPBYTE) buf, &dwSize);
+ if (lRegResult != ERROR_FILE_NOT_FOUND)
+ {
+ // If registry key doesn't exist create it using system current setting
+ iDefaultIconSize = ::GetSystemMetrics(SM_CXICON);
+ if (0 == iDefaultIconSize)
+ iDefaultIconSize = 32;
+ _sntprintf_s(buf, BUFFER_SIZE, BUFFER_SIZE, _T("%d"), iDefaultIconSize);
+ }
+ else if (lRegResult != ERROR_SUCCESS)
+ goto Cleanup;
+
+ // Change registry value
+ dwRegValue = _ttoi(buf);
+ dwRegValueTemp = dwRegValue-1;
+
+ dwSize = _sntprintf_s(buf, BUFFER_SIZE, BUFFER_SIZE, _T("%d"), dwRegValueTemp) + sizeof(TCHAR);
+ lRegResult = RegSetValueEx(hRegKey, sRegValueName.c_str(), 0, REG_SZ,
+ (LPBYTE) buf, dwSize);
+ if (lRegResult != ERROR_SUCCESS)
+ goto Cleanup;
+
+
+ // Update all windows
+ SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS,
+ 0, SMTO_ABORTIFHUNG, 5000, &dwResult);
+
+ // Reset registry value
+ dwSize = _sntprintf_s(buf, BUFFER_SIZE, BUFFER_SIZE, _T("%d"), dwRegValue) + sizeof(TCHAR);
+ lRegResult = RegSetValueEx(hRegKey, sRegValueName.c_str(), 0, REG_SZ,
+ (LPBYTE) buf, dwSize);
+ if(lRegResult != ERROR_SUCCESS)
+ goto Cleanup;
+
+ // Update all windows
+ SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS,
+ 0, SMTO_ABORTIFHUNG, 5000, &dwResult);
+
+ bResult = true;
+
+Cleanup:
+ if (hRegKey != 0)
+ {
+ RegCloseKey(hRegKey);
+ }
+ if (buf != NULL)
+ {
+ delete buf;
+ }
+
+ //return bResult;
+}
+
static struct {LPCSTR verb, cmd; UINT action;} handlers[] =
{
{"VideoFiles", " %1", IDS_AUTOPLAY_PLAYVIDEO},
@@ -690,7 +805,7 @@ BOOL CPPageFormats::OnApply()
POSITION pos = exts.GetHeadPosition();
while(pos)
- RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetProgId(), mf[(int)m_list.GetItemData(i)].GetLabel(), !!iChecked);
+ RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetProgId(), mf[(int)m_list.GetItemData(i)].GetLabel(), !!iChecked, mf[(int)m_list.GetItemData(i)].GetIconIndex());
}
CRegKey key;
@@ -731,6 +846,8 @@ BOOL CPPageFormats::OnApply()
AppSettings& s = AfxGetAppSettings();
s.Formats.SetRtspHandler(m_iRtspHandler==0?RealMedia:m_iRtspHandler==1?QuickTime:DirectShow, !!m_fRtspFileExtFirst);
+ RebuildIconsCache();
+
return __super::OnApply();
}