Native tree descriptions previously omitted state-image bits. As a result, foobar2000 Advanced Preferences read setting names without their boolean values, and changing a checkbox without moving focus could go unnoticed. Include TVIS_STATEIMAGEMASK in the native item key so polling observes state changes even when Wine omits WinEvents. Report checked and not-checked states for standard checkbox-tree images while preserving selected and expanded/collapsed states. All queries remain read-only and retain the existing target-architecture buffer layouts and bounded query behavior. Foobar2000 also uses image indexes 3 and 4 for radio choices in its Advanced settings tree. Expose those entries as radio buttons with the corresponding check state. Restrict this application-defined mapping to foobar2000.exe and its Preferences category/settings control identities. Leave unrelated state images uninterpreted rather than inventing mixed checkbox states. Extend the controls fixture with checkbox changes that emit no WinEvent, custom images, and foobar-style radio transitions. Add a foobar-controls runner mode using the application's basename. Exercise identical control IDs and images under an unrelated basename to guard against applying the compatibility mapping to other programs. Account for Wine initializing checkbox images when the fixture first appears. Document support and the manual Preferences acceptance procedure. Validation: - Controls and foobar-controls fixtures passed in both 64-bit and 32-bit. - All six CTests passed: foreground focus, MSAA states, text limits, 64/32-bit review capture, and hook safety. - Existing menu and editor integrations passed, including Unicode, selection/deletion feedback, password exclusion and read-only controls. - A private copy of foobar2000 2.26.1 exposed Advanced setting labels, numeric values, checkbox Space toggles and radio states, plus Components row names and version/module descriptions through the recording reader. - Installed the verified helper alongside the Cthulhu session-bus fix; the user subsequently confirmed that the live changes look good. Recorded events alone do not establish physical Braille acceptance. No foobar2000 settings were changed in the user's live installation.
187 lines
8.6 KiB
C
187 lines
8.6 KiB
C
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
#define UNICODE
|
|
#define _UNICODE
|
|
#include <windows.h>
|
|
#include <commctrl.h>
|
|
|
|
static HWND tabs, atlTabs, tree, combo, edit, button, list, statusTree, settingsTree;
|
|
static HTREEITEM root;
|
|
static int step;
|
|
|
|
static void focus_control(HWND window) {
|
|
SetFocus(window);
|
|
NotifyWinEvent(EVENT_OBJECT_FOCUS, window, OBJID_CLIENT, CHILDID_SELF);
|
|
}
|
|
|
|
static LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wp, LPARAM lp) {
|
|
if (message == WM_TIMER) {
|
|
switch (++step) {
|
|
case 1: SendMessageW(tabs, WM_KEYDOWN, VK_RIGHT, 1); break;
|
|
case 2: focus_control(button); break;
|
|
case 3: focus_control(atlTabs); break;
|
|
case 4: SendMessageW(atlTabs, WM_KEYDOWN, VK_RIGHT, 1); break;
|
|
case 5: focus_control(tree); break;
|
|
case 6: SendMessageW(tree, TVM_EXPAND, TVE_EXPAND, (LPARAM)root); break;
|
|
case 7: SendMessageW(tree, WM_KEYDOWN, VK_DOWN, 1); break;
|
|
case 8: focus_control(button); break;
|
|
case 9: focus_control(tree); break;
|
|
case 10: focus_control(combo); break;
|
|
case 11:
|
|
SendMessageW(combo, CB_SETCURSEL, 1, 0);
|
|
// Common file dialogs can change the selection without a WinEvent.
|
|
break;
|
|
case 12: focus_control(edit); break;
|
|
case 13: focus_control(atlTabs); break;
|
|
case 14: SendMessageW(atlTabs, TCM_DELETEALLITEMS, 0, 0); break;
|
|
case 15: focus_control(tree); break;
|
|
case 16: SendMessageW(tree, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT); break;
|
|
case 17: focus_control(list); break;
|
|
case 18:
|
|
SetWindowLongPtrW(tree, GWL_STYLE, GetWindowLongPtrW(tree, GWL_STYLE) | TVS_CHECKBOXES);
|
|
SendMessageW(tree, TVM_INSERTITEMW, 0, (LPARAM)&(TVINSERTSTRUCTW){
|
|
.hParent = TVI_ROOT, .hInsertAfter = TVI_LAST,
|
|
.item = {.mask = TVIF_TEXT | TVIF_STATE, .pszText = L"Enable playback β",
|
|
.stateMask = TVIS_STATEIMAGEMASK, .state = INDEXTOSTATEIMAGEMASK(1)}});
|
|
SendMessageW(tree, TVM_SELECTITEM, TVGN_CARET,
|
|
SendMessageW(tree, TVM_GETNEXTITEM, TVGN_ROOT, 0));
|
|
focus_control(tree);
|
|
break;
|
|
case 19: {
|
|
TVITEMW item = {0};
|
|
item.mask = TVIF_STATE;
|
|
item.hItem = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_CARET, 0);
|
|
item.stateMask = TVIS_STATEIMAGEMASK;
|
|
item.state = INDEXTOSTATEIMAGEMASK(2);
|
|
// Do not send a WinEvent: the focus poll must notice the new state.
|
|
SendMessageW(tree, TVM_SETITEMW, 0, (LPARAM)&item);
|
|
break;
|
|
}
|
|
case 20: {
|
|
TVITEMW item = {0};
|
|
item.mask = TVIF_STATE | TVIF_TEXT;
|
|
item.pszText = L"Custom checkbox icon";
|
|
item.hItem = (HTREEITEM)SendMessageW(tree, TVM_GETNEXTITEM, TVGN_CARET, 0);
|
|
item.stateMask = TVIS_STATEIMAGEMASK;
|
|
item.state = INDEXTOSTATEIMAGEMASK(3);
|
|
SendMessageW(tree, TVM_SETITEMW, 0, (LPARAM)&item);
|
|
break;
|
|
}
|
|
case 21: focus_control(statusTree); break;
|
|
case 22: {
|
|
TVITEMW item = {0};
|
|
item.mask = TVIF_STATE;
|
|
item.hItem = (HTREEITEM)SendMessageW(settingsTree, TVM_GETNEXTITEM, TVGN_CARET, 0);
|
|
item.stateMask = TVIS_STATEIMAGEMASK;
|
|
item.state = INDEXTOSTATEIMAGEMASK(3);
|
|
// Wine initializes checkbox images when the window is first shown.
|
|
// Install the application's custom image after that initialization.
|
|
SendMessageW(settingsTree, TVM_SETITEMW, 0, (LPARAM)&item);
|
|
focus_control(settingsTree);
|
|
break;
|
|
}
|
|
case 23: {
|
|
TVITEMW item = {0};
|
|
item.mask = TVIF_STATE;
|
|
item.hItem = (HTREEITEM)SendMessageW(settingsTree, TVM_GETNEXTITEM, TVGN_CARET, 0);
|
|
item.stateMask = TVIS_STATEIMAGEMASK;
|
|
item.state = INDEXTOSTATEIMAGEMASK(4);
|
|
SendMessageW(settingsTree, TVM_SETITEMW, 0, (LPARAM)&item);
|
|
break;
|
|
}
|
|
default: DestroyWindow(window); break;
|
|
}
|
|
return 0;
|
|
}
|
|
if (message == WM_DESTROY) { PostQuitMessage(0); return 0; }
|
|
return DefWindowProcW(window, message, wp, lp);
|
|
}
|
|
|
|
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show) {
|
|
(void)previous; (void)args; (void)show;
|
|
INITCOMMONCONTROLSEX controls = {sizeof(controls), ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES};
|
|
InitCommonControlsEx(&controls);
|
|
WNDCLASSW cls = {0};
|
|
cls.hInstance = instance;
|
|
cls.lpszClassName = L"WineAccessControlsFixture";
|
|
cls.lpfnWndProc = window_proc;
|
|
RegisterClassW(&cls);
|
|
HWND window = CreateWindowW(cls.lpszClassName, L"Wine & controls fixture", WS_OVERLAPPEDWINDOW,
|
|
120, 120, 700, 440, NULL, NULL, instance, NULL);
|
|
WNDCLASSEXW tabClass = {0};
|
|
tabClass.cbSize = sizeof(tabClass);
|
|
if (!GetClassInfoExW(NULL, WC_TABCONTROLW, &tabClass)) return 1;
|
|
tabClass.hInstance = instance;
|
|
tabClass.lpszClassName = L"ATL:SysTabControl32";
|
|
if (!RegisterClassExW(&tabClass)) return 2;
|
|
tabs = CreateWindowW(WC_TABCONTROLW, L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
|
10, 10, 300, 80, window, NULL, instance, NULL);
|
|
atlTabs = CreateWindowW(tabClass.lpszClassName, L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
|
330, 10, 300, 80, window, NULL, instance, NULL);
|
|
TCITEMW tab = {0};
|
|
tab.mask = TCIF_TEXT;
|
|
tab.pszText = L"Albums & artists β";
|
|
SendMessageW(tabs, TCM_INSERTITEMW, 0, (LPARAM)&tab);
|
|
tab.pszText = L"Details";
|
|
SendMessageW(tabs, TCM_INSERTITEMW, 1, (LPARAM)&tab);
|
|
tab.pszText = L"Default Playlist";
|
|
SendMessageW(atlTabs, TCM_INSERTITEMW, 0, (LPARAM)&tab);
|
|
tab.pszText = L"Second Playlist";
|
|
SendMessageW(atlTabs, TCM_INSERTITEMW, 1, (LPARAM)&tab);
|
|
tree = CreateWindowW(WC_TREEVIEWW, L"Tree1", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
|
10, 110, 300, 170, window, (HMENU)1068, instance, NULL);
|
|
TVINSERTSTRUCTW node = {0};
|
|
node.hParent = TVI_ROOT;
|
|
node.hInsertAfter = TVI_LAST;
|
|
node.item.mask = TVIF_TEXT;
|
|
node.item.pszText = L"All music";
|
|
root = (HTREEITEM)SendMessageW(tree, TVM_INSERTITEMW, 0, (LPARAM)&node);
|
|
node.hParent = root;
|
|
node.item.pszText = L"Artist & album β";
|
|
SendMessageW(tree, TVM_INSERTITEMW, 0, (LPARAM)&node);
|
|
SendMessageW(tree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)root);
|
|
button = CreateWindowW(L"Button", L"&Named && native button", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
|
10, 310, 250, 30, window, NULL, instance, NULL);
|
|
combo = CreateWindowW(L"ComboBox", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST,
|
|
390, 110, 200, 150, window, NULL, instance, NULL);
|
|
SendMessageW(combo, CB_ADDSTRING, 0, (LPARAM)L"artist & album");
|
|
SendMessageW(combo, CB_ADDSTRING, 0, (LPARAM)L"year && date");
|
|
SendMessageW(combo, CB_SETCURSEL, 0, 0);
|
|
edit = CreateWindowW(L"Edit", L"search & find", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
|
390, 170, 200, 25, window, NULL, instance, NULL);
|
|
// Labels are deliberately created after their fields, like foobar2000.
|
|
CreateWindowW(L"Static", L"&View && sort:", WS_CHILD | WS_VISIBLE,
|
|
330, 110, 50, 25, window, NULL, instance, NULL);
|
|
CreateWindowW(L"Static", L"Filter & query:", WS_CHILD | WS_VISIBLE | SS_NOPREFIX,
|
|
330, 170, 50, 25, window, NULL, instance, NULL);
|
|
list = CreateWindowW(L"ListBox", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
|
390, 220, 200, 80, window, NULL, instance, NULL);
|
|
SendMessageW(list, LB_ADDSTRING, 0, (LPARAM)L"Rock & roll && blues");
|
|
SendMessageW(list, LB_SETCURSEL, 0, 0);
|
|
statusTree = CreateWindowW(WC_TREEVIEWW, L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
|
|
500, 310, 170, 60, window, NULL, instance, NULL);
|
|
node.hParent = TVI_ROOT;
|
|
node.item.mask = TVIF_TEXT | TVIF_STATE;
|
|
node.item.pszText = L"Status image";
|
|
node.item.stateMask = TVIS_STATEIMAGEMASK;
|
|
node.item.state = INDEXTOSTATEIMAGEMASK(2);
|
|
HTREEITEM status = (HTREEITEM)SendMessageW(statusTree, TVM_INSERTITEMW, 0, (LPARAM)&node);
|
|
SendMessageW(statusTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)status);
|
|
// Reproduce foobar's native control identities and application-defined
|
|
// radio images. The runner tests this under matching and unrelated names.
|
|
settingsTree = CreateWindowW(WC_TREEVIEWW, L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP | TVS_CHECKBOXES,
|
|
500, 370, 170, 40, window, (HMENU)1181, instance, NULL);
|
|
node.item.pszText = L"Radio option";
|
|
node.item.state = INDEXTOSTATEIMAGEMASK(3);
|
|
HTREEITEM radio = (HTREEITEM)SendMessageW(settingsTree, TVM_INSERTITEMW, 0, (LPARAM)&node);
|
|
SendMessageW(settingsTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)radio);
|
|
ShowWindow(window, SW_SHOW);
|
|
SetForegroundWindow(window);
|
|
focus_control(tabs);
|
|
SetTimer(window, 1, 400, NULL);
|
|
MSG message;
|
|
while (GetMessageW(&message, NULL, 0, 0) > 0) {
|
|
TranslateMessage(&message); DispatchMessageW(&message);
|
|
}
|
|
return 0;
|
|
}
|