📄 system.c
字号:
if(MSSTYLES_LookupProperty(pszPropertyName, NULL, &iDocId)) {
for(i=0; i<sizeof(wDocToRes)/sizeof(wDocToRes[0]); i+=2) {
if(wDocToRes[i] == iDocId) {
if(LoadStringW(pt->hTheme, wDocToRes[i+1], pszValueBuff, cchMaxValChars)) {
hr = S_OK;
break;
}
}
}
}
/* If loading from string resource failed, try getting it from the theme.ini */
if(FAILED(hr)) {
PUXINI_FILE uf = MSSTYLES_GetThemeIni(pt);
if(UXINI_FindSection(uf, szIniDocumentation)) {
LPCWSTR lpValue;
DWORD dwLen;
if(UXINI_FindValue(uf, pszPropertyName, &lpValue, &dwLen)) {
lstrcpynW(pszValueBuff, lpValue, min(dwLen+1,cchMaxValChars));
hr = S_OK;
}
}
UXINI_CloseINI(uf);
}
MSSTYLES_CloseThemeFile(pt);
return hr;
}
/**********************************************************************
* Undocumented functions
*/
/**********************************************************************
* QueryThemeServices (UXTHEME.1)
*
* RETURNS
* some kind of status flag
*/
DWORD WINAPI QueryThemeServices()
{
FIXME("stub\n");
return 3; /* This is what is returned under XP in most cases */
}
/**********************************************************************
* OpenThemeFile (UXTHEME.2)
*
* Opens a theme file, which can be used to change the current theme, etc
*
* PARAMS
* pszThemeFileName Path to a msstyles theme file
* pszColorName Color defined in the theme, eg. NormalColor
* pszSizeName Size defined in the theme, eg. NormalSize
* hThemeFile Handle to theme file
*
* RETURNS
* Success: S_OK
* Failure: HRESULT error-code
*/
HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName,
LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile,
DWORD unknown)
{
TRACE("(%s,%s,%s,%p,%d)\n", debugstr_w(pszThemeFileName),
debugstr_w(pszColorName), debugstr_w(pszSizeName),
hThemeFile, unknown);
return MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, (PTHEME_FILE*)hThemeFile);
}
/**********************************************************************
* CloseThemeFile (UXTHEME.3)
*
* Releases theme file handle returned by OpenThemeFile
*
* PARAMS
* hThemeFile Handle to theme file
*
* RETURNS
* Success: S_OK
* Failure: HRESULT error-code
*/
HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile)
{
TRACE("(%p)\n", hThemeFile);
MSSTYLES_CloseThemeFile(hThemeFile);
return S_OK;
}
/**********************************************************************
* ApplyTheme (UXTHEME.4)
*
* Set a theme file to be the currently active theme
*
* PARAMS
* hThemeFile Handle to theme file
* unknown See notes
* hWnd Window requesting the theme change
*
* RETURNS
* Success: S_OK
* Failure: HRESULT error-code
*
* NOTES
* I'm not sure what the second parameter is (the datatype is likely wrong), other then this:
* Under XP if I pass
* char b[] = "";
* the theme is applied with the screen redrawing really badly (flickers)
* char b[] = "\0"; where \0 can be one or more of any character, makes no difference
* the theme is applied smoothly (screen does not flicker)
* char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference
* the function fails returning invalid parameter...very strange
*/
HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd)
{
HRESULT hr;
TRACE("(%p,%s,%p)\n", hThemeFile, unknown, hWnd);
hr = UXTHEME_SetActiveTheme(hThemeFile);
UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
return hr;
}
/**********************************************************************
* GetThemeDefaults (UXTHEME.7)
*
* Get the default color & size for a theme
*
* PARAMS
* pszThemeFileName Path to a msstyles theme file
* pszColorName Buffer to receive the default color name
* dwColorNameLen Length, in characters, of color name buffer
* pszSizeName Buffer to receive the default size name
* dwSizeNameLen Length, in characters, of size name buffer
*
* RETURNS
* Success: S_OK
* Failure: HRESULT error-code
*/
HRESULT WINAPI GetThemeDefaults(LPCWSTR pszThemeFileName, LPWSTR pszColorName,
DWORD dwColorNameLen, LPWSTR pszSizeName,
DWORD dwSizeNameLen)
{
PTHEME_FILE pt;
HRESULT hr;
TRACE("(%s,%p,%d,%p,%d)\n", debugstr_w(pszThemeFileName),
pszColorName, dwColorNameLen,
pszSizeName, dwSizeNameLen);
hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
if(FAILED(hr)) return hr;
lstrcpynW(pszColorName, pt->pszSelectedColor, dwColorNameLen);
lstrcpynW(pszSizeName, pt->pszSelectedSize, dwSizeNameLen);
MSSTYLES_CloseThemeFile(pt);
return S_OK;
}
/**********************************************************************
* EnumThemes (UXTHEME.8)
*
* Enumerate available themes, calls specified EnumThemeProc for each
* theme found. Passes lpData through to callback function.
*
* PARAMS
* pszThemePath Path containing themes
* callback Called for each theme found in path
* lpData Passed through to callback
*
* RETURNS
* Success: S_OK
* Failure: HRESULT error-code
*/
HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, EnumThemeProc callback,
LPVOID lpData)
{
WCHAR szDir[MAX_PATH];
WCHAR szPath[MAX_PATH];
static const WCHAR szStar[] = {'*','.','*','\0'};
static const WCHAR szFormat[] = {'%','s','%','s','\\','%','s','.','m','s','s','t','y','l','e','s','\0'};
static const WCHAR szDisplayName[] = {'d','i','s','p','l','a','y','n','a','m','e','\0'};
static const WCHAR szTooltip[] = {'t','o','o','l','t','i','p','\0'};
WCHAR szName[60];
WCHAR szTip[60];
HANDLE hFind;
WIN32_FIND_DATAW wfd;
HRESULT hr;
size_t pathLen;
TRACE("(%s,%p,%p)\n", debugstr_w(pszThemePath), callback, lpData);
if(!pszThemePath || !callback)
return E_POINTER;
lstrcpyW(szDir, pszThemePath);
pathLen = lstrlenW (szDir);
if ((pathLen > 0) && (pathLen < MAX_PATH-1) && (szDir[pathLen - 1] != '\\'))
{
szDir[pathLen] = '\\';
szDir[pathLen+1] = 0;
}
lstrcpyW(szPath, szDir);
lstrcatW(szPath, szStar);
TRACE("searching %s\n", debugstr_w(szPath));
hFind = FindFirstFileW(szPath, &wfd);
if(hFind != INVALID_HANDLE_VALUE) {
do {
if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
&& !(wfd.cFileName[0] == '.' && ((wfd.cFileName[1] == '.' && wfd.cFileName[2] == 0) || wfd.cFileName[1] == 0))) {
wsprintfW(szPath, szFormat, szDir, wfd.cFileName, wfd.cFileName);
hr = GetThemeDocumentationProperty(szPath, szDisplayName, szName, sizeof(szName)/sizeof(szName[0]));
if(SUCCEEDED(hr))
hr = GetThemeDocumentationProperty(szPath, szTooltip, szTip, sizeof(szTip)/sizeof(szTip[0]));
if(SUCCEEDED(hr)) {
TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath), debugstr_w(szName), debugstr_w(szTip), lpData);
if(!callback(NULL, szPath, szName, szTip, NULL, lpData)) {
TRACE("callback ended enum\n");
break;
}
}
}
} while(FindNextFileW(hFind, &wfd));
FindClose(hFind);
}
return S_OK;
}
/**********************************************************************
* EnumThemeColors (UXTHEME.9)
*
* Enumerate theme colors available with a particular size
*
* PARAMS
* pszThemeFileName Path to a msstyles theme file
* pszSizeName Theme size to enumerate available colors
* If NULL the default theme size is used
* dwColorNum Color index to retrieve, increment from 0
* pszColorNames Output color names
*
* RETURNS
* S_OK on success
* E_PROP_ID_UNSUPPORTED when dwColorName does not refer to a color
* or when pszSizeName does not refer to a valid size
*
* NOTES
* XP fails with E_POINTER when pszColorNames points to a buffer smaller than
* sizeof(THEMENAMES).
*
* Not very efficient that I'm opening & validating the theme every call, but
* this is undocumented and almost never called..
* (and this is how windows works too)
*/
HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName,
DWORD dwColorNum, PTHEMENAMES pszColorNames)
{
PTHEME_FILE pt;
HRESULT hr;
LPWSTR tmp;
UINT resourceId = dwColorNum + 1000;
TRACE("(%s,%s,%d)\n", debugstr_w(pszThemeFileName),
debugstr_w(pszSizeName), dwColorNum);
hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, pszSizeName, &pt);
if(FAILED(hr)) return hr;
tmp = pt->pszAvailColors;
while(dwColorNum && *tmp) {
dwColorNum--;
tmp += lstrlenW(tmp)+1;
}
if(!dwColorNum && *tmp) {
TRACE("%s\n", debugstr_w(tmp));
lstrcpyW(pszColorNames->szName, tmp);
LoadStringW (pt->hTheme, resourceId,
pszColorNames->szDisplayName,
sizeof (pszColorNames->szDisplayName) / sizeof (WCHAR));
LoadStringW (pt->hTheme, resourceId+1000,
pszColorNames->szTooltip,
sizeof (pszColorNames->szTooltip) / sizeof (WCHAR));
}
else
hr = E_PROP_ID_UNSUPPORTED;
MSSTYLES_CloseThemeFile(pt);
return hr;
}
/**********************************************************************
* EnumThemeSizes (UXTHEME.10)
*
* Enumerate theme colors available with a particular size
*
* PARAMS
* pszThemeFileName Path to a msstyles theme file
* pszColorName Theme color to enumerate available sizes
* If NULL the default theme color is used
* dwSizeNum Size index to retrieve, increment from 0
* pszSizeNames Output size names
*
* RETURNS
* S_OK on success
* E_PROP_ID_UNSUPPORTED when dwSizeName does not refer to a size
* or when pszColorName does not refer to a valid color
*
* NOTES
* XP fails with E_POINTER when pszSizeNames points to a buffer smaller than
* sizeof(THEMENAMES).
*
* Not very efficient that I'm opening & validating the theme every call, but
* this is undocumented and almost never called..
* (and this is how windows works too)
*/
HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName,
DWORD dwSizeNum, PTHEMENAMES pszSizeNames)
{
PTHEME_FILE pt;
HRESULT hr;
LPWSTR tmp;
UINT resourceId = dwSizeNum + 3000;
TRACE("(%s,%s,%d)\n", debugstr_w(pszThemeFileName),
debugstr_w(pszColorName), dwSizeNum);
hr = MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, NULL, &pt);
if(FAILED(hr)) return hr;
tmp = pt->pszAvailSizes;
while(dwSizeNum && *tmp) {
dwSizeNum--;
tmp += lstrlenW(tmp)+1;
}
if(!dwSizeNum && *tmp) {
TRACE("%s\n", debugstr_w(tmp));
lstrcpyW(pszSizeNames->szName, tmp);
LoadStringW (pt->hTheme, resourceId,
pszSizeNames->szDisplayName,
sizeof (pszSizeNames->szDisplayName) / sizeof (WCHAR));
LoadStringW (pt->hTheme, resourceId+1000,
pszSizeNames->szTooltip,
sizeof (pszSizeNames->szTooltip) / sizeof (WCHAR));
}
else
hr = E_PROP_ID_UNSUPPORTED;
MSSTYLES_CloseThemeFile(pt);
return hr;
}
/**********************************************************************
* ParseThemeIniFile (UXTHEME.11)
*
* Enumerate data in a theme INI file.
*
* PARAMS
* pszIniFileName Path to a theme ini file
* pszUnknown Cannot be NULL, L"" is valid
* callback Called for each found entry
* lpData Passed through to callback
*
* RETURNS
* S_OK on success
* 0x800706488 (Unknown property) when enumeration is canceled from callback
*
* NOTES
* When pszUnknown is NULL the callback is never called, the value does not seem to surve
* any other purpose
*/
HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
ParseThemeIniFileProc callback, LPVOID lpData)
{
FIXME("%s %s: stub\n", debugstr_w(pszIniFileName), debugstr_w(pszUnknown));
return ERROR_CALL_NOT_IMPLEMENTED;
}
/**********************************************************************
* CheckThemeSignature (UXTHEME.29)
*
* Validates the signature of a theme file
*
* PARAMS
* pszIniFileName Path to a theme file
*
* RETURNS
* Success: S_OK
* Failure: HRESULT error-code
*/
HRESULT WINAPI CheckThemeSignature(LPCWSTR pszThemeFileName)
{
PTHEME_FILE pt;
HRESULT hr;
TRACE("(%s)\n", debugstr_w(pszThemeFileName));
hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
if(FAILED(hr))
return hr;
MSSTYLES_CloseThemeFile(pt);
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -