From a5064d775fc1d7e3b3e5baf5d9118b2ab1a29980 Mon Sep 17 00:00:00 2001 From: "curt%netscape.com" Date: Fri, 28 Jun 2002 23:03:41 +0000 Subject: [PATCH] Refresh icons on upgrade (Bug #154708, r=curt, sr=deveditz) git-svn-id: svn://10.0.0.236/trunk@124313 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpinstall/wizard/windows/setup/dialogs.c | 4 ++ .../xpinstall/wizard/windows/setup/extra.c | 58 +++++++++++++++++++ .../xpinstall/wizard/windows/setup/extra.h | 1 + .../xpinstall/wizard/windows/setup/setup.h | 1 + 4 files changed, 64 insertions(+) diff --git a/mozilla/xpinstall/wizard/windows/setup/dialogs.c b/mozilla/xpinstall/wizard/windows/setup/dialogs.c index 22c62edd415..bbaab86b873 100644 --- a/mozilla/xpinstall/wizard/windows/setup/dialogs.c +++ b/mozilla/xpinstall/wizard/windows/setup/dialogs.c @@ -2864,6 +2864,10 @@ void DlgSequenceNext() /* DEPEND_REBOOT process file manipulation functions */ ProcessFileOpsForAll(T_DEPEND_REBOOT); + // Refresh system icons if necessary + if(gSystemInfo.bRefreshIcons) + RefreshIcons(); + UnsetSetupState(); // clear setup state ClearWinRegUninstallFileDeletion(); if(!gbIgnoreProgramFolderX) diff --git a/mozilla/xpinstall/wizard/windows/setup/extra.c b/mozilla/xpinstall/wizard/windows/setup/extra.c index 0485de63d22..ca21996c234 100644 --- a/mozilla/xpinstall/wizard/windows/setup/extra.c +++ b/mozilla/xpinstall/wizard/windows/setup/extra.c @@ -40,6 +40,7 @@ #define HIDWORD(l) ((DWORD) (((ULONG) (l) >> 32) & 0xFFFF)) #define LODWORD(l) ((DWORD) (l)) +#define DEFAULT_ICON_SIZE 32 #define INDEX_STR_LEN 10 #define PN_PROCESS TEXT("Process") #define PN_THREAD TEXT("Thread") @@ -2498,6 +2499,7 @@ HRESULT InitSetupGeneral() { char szBuf[MAX_BUF]; + gSystemInfo.bRefreshIcons = FALSE; sgProduct.dwMode = NORMAL; sgProduct.dwCustomType = ST_RADIO0; sgProduct.dwNumberOfComponents = 0; @@ -5513,6 +5515,58 @@ int CompareVersion(verBlock vbVersionOld, verBlock vbVersionNew) return(0); } +void RefreshIcons() +{ + char subKey[MAX_BUF]; + char iconConstraint[MAX_BUF]; + BYTE iconConstraintNew[MAX_BUF]; + HKEY hkResult; + DWORD dwValueType; + long iconConstraintSize; + long rv; + + // Get the size of the icon from the windows registry. + // When this registry value is changed, the OS can flush the + // icon cache and thus update the icons. + iconConstraintSize = sizeof(iconConstraint); + strcpy(subKey, "Control Panel\\Desktop\\WindowMetrics"); + RegOpenKeyEx(HKEY_CURRENT_USER, subKey, 0, KEY_ALL_ACCESS, &hkResult); + rv = RegQueryValueEx(hkResult, "Shell Icon Size", 0, &dwValueType, iconConstraint, &iconConstraintSize); + if(rv != ERROR_SUCCESS || iconConstraintSize == 0) + { + // Key not found or value not found, so use default OS value. + int iIconSize = GetSystemMetrics(SM_CXICON); + if(iIconSize == 0) + // Getting default OS value failed, use hard coded value + iIconSize = DEFAULT_ICON_SIZE; + + sprintf(iconConstraint, "%d", iIconSize); + } + + // decrease the size of the icon by 1 + // and tell the system to refresh the icons + sprintf(iconConstraintNew, "%d", atoi(iconConstraint) - 1); + iconConstraintSize = lstrlen(iconConstraintNew); + RegSetValueEx(hkResult, "Shell Icon Size", 0, dwValueType, iconConstraintNew, iconConstraintSize); + SendMessageTimeout(HWND_BROADCAST, + WM_SETTINGCHANGE, + SPI_SETNONCLIENTMETRICS, + (LPARAM)"WindowMetrics", + SMTO_NORMAL|SMTO_ABORTIFHUNG, + 10000, NULL); + + // reset the original size of the icon + // and tell the system to refresh the icons + iconConstraintSize = lstrlen(iconConstraint); + RegSetValueEx(hkResult, "Shell Icon Size", 0, dwValueType, iconConstraint, iconConstraintSize); + SendMessageTimeout(HWND_BROADCAST, + WM_SETTINGCHANGE, + SPI_SETNONCLIENTMETRICS, + (LPARAM)"WindowMetrics", + SMTO_NORMAL|SMTO_ABORTIFHUNG, + 10000, NULL); +} + int CRCCheckArchivesStartup(char *szCorruptedArchiveList, DWORD dwCorruptedArchiveListSize, BOOL bIncludeTempPath) { DWORD dwIndex0; @@ -5829,6 +5883,10 @@ HRESULT ParseConfigIni(LPSTR lpszCmdLine) GetPrivateProfileString("General", "Program Folder Name", "", szBuf, sizeof(szBuf), szFileIniConfig); DecryptString(sgProduct.szProgramFolderName, szBuf); + GetPrivateProfileString("General", "Refresh Icons", "", szBuf, sizeof(szBuf), szFileIniConfig); + if(lstrcmpi(szBuf, "TRUE") == 0) + gSystemInfo.bRefreshIcons = TRUE; + /* Welcome dialog */ GetPrivateProfileString("Dialog Welcome", "Show Dialog", "", szShowDialog, sizeof(szShowDialog), szFileIniConfig); GetPrivateProfileString("Dialog Welcome", "Title", "", diWelcome.szTitle, MAX_BUF, szFileIniConfig); diff --git a/mozilla/xpinstall/wizard/windows/setup/extra.h b/mozilla/xpinstall/wizard/windows/setup/extra.h index d79ff4e713a..7bdd3c02299 100644 --- a/mozilla/xpinstall/wizard/windows/setup/extra.h +++ b/mozilla/xpinstall/wizard/windows/setup/extra.h @@ -213,6 +213,7 @@ BOOL DeleteWGetLog(void); DWORD ParseOSType(char *szOSType); BOOL ShowAdditionalOptionsDialog(void); DWORD GetPreviousUnfinishedState(void); +void RefreshIcons(); #endif /* _EXTRA_H_ */ diff --git a/mozilla/xpinstall/wizard/windows/setup/setup.h b/mozilla/xpinstall/wizard/windows/setup/setup.h index 87e934a7092..f20d5bd5a8d 100644 --- a/mozilla/xpinstall/wizard/windows/setup/setup.h +++ b/mozilla/xpinstall/wizard/windows/setup/setup.h @@ -546,6 +546,7 @@ struct sSysInfo DWORD dwScreenX; DWORD dwScreenY; BOOL bScreenReader; + BOOL bRefreshIcons; }; typedef struct diskSpaceNode dsN;