Commit 9d8250e5 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

uxtheme: Parse app/class name in OpenThemeData().

Themed Delphi applications use "explorer::listview" and "explorer::treeview": https://gitlab.com/freepascal.org/lazarus/lazarus/-/blob/main/lcl/interfaces/win32/win32themes.pasSigned-off-by: 's avatarDmitry Timoshkov <dmitry@baikal.ru>
parent e4ede41c
......@@ -1022,6 +1022,23 @@ static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics)
}
}
static void parse_app_class_name(LPCWSTR name, LPWSTR app_name, LPWSTR class_name)
{
LPCWSTR p;
app_name[0] = class_name[0] = 0;
p = wcsstr(name, L"::");
if (p)
{
lstrcpynW(app_name, name, min(p - name + 1, MAX_THEME_APP_NAME));
p += 2;
lstrcpynW(class_name, p, min(wcslen(p) + 1, MAX_THEME_CLASS_NAME));
}
else
lstrcpynW(class_name, name, MAX_THEME_CLASS_NAME);
}
/***********************************************************************
* MSSTYLES_OpenThemeClass
*
......@@ -1036,6 +1053,8 @@ static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics)
PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList, UINT dpi)
{
PTHEME_CLASS cls = NULL;
WCHAR buf[MAX_THEME_APP_NAME + MAX_THEME_CLASS_NAME];
WCHAR szAppName[MAX_THEME_APP_NAME];
WCHAR szClassName[MAX_THEME_CLASS_NAME];
LPCWSTR start;
LPCWSTR end;
......@@ -1052,14 +1071,22 @@ PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList, U
start = pszClassList;
while((end = wcschr(start, ';'))) {
len = end-start;
lstrcpynW(szClassName, start, min(len+1, ARRAY_SIZE(szClassName)));
lstrcpynW(buf, start, min(len+1, ARRAY_SIZE(buf)));
start = end+1;
cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName);
parse_app_class_name(buf, szAppName, szClassName);
if (szAppName[0])
cls = MSSTYLES_FindClass(tfActiveTheme, szAppName, szClassName);
else
cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName);
if(cls) break;
}
if(!cls && *start) {
lstrcpynW(szClassName, start, ARRAY_SIZE(szClassName));
cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName);
parse_app_class_name(start, szAppName, szClassName);
if (szAppName[0])
cls = MSSTYLES_FindClass(tfActiveTheme, szAppName, szClassName);
else
cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName);
}
if(cls) {
TRACE("Opened app %s, class %s from list %s\n", debugstr_w(cls->szAppName), debugstr_w(cls->szClassName), debugstr_w(pszClassList));
......
......@@ -560,14 +560,14 @@ static void test_OpenThemeData(void)
SetLastError(0xdeadbeef);
hTheme = OpenThemeData(hWnd, L"dead::beef;explorer::treeview");
todo_wine
ok(!hTheme, "OpenThemeData() should fail\n");
todo_wine
ok(GetLastError() == E_PROP_ID_UNSUPPORTED, "Got unexpected %#lx.\n", GetLastError());
SetLastError(0xdeadbeef);
hTheme = OpenThemeData(hWnd, L"explorer::treeview");
todo_wine
ok(hTheme != NULL, "OpenThemeData() failed\n");
todo_wine
ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got 0x%08lx\n", GetLastError());
CloseThemeData(hTheme);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment