thpatch / thcrap

Touhou Community Reliant Automatic Patcher
https://www.thpatch.net
The Unlicense
573 stars 42 forks source link

Disable smooth scrolling for sswconf listboxes #68

Closed DankRank closed 4 years ago

DankRank commented 6 years ago

"smooth scrolling" is actually quite the opposite from smooth. The more advanced ListView and TreeView controls don't do smooth scrolling, neither does the shell 🤔

WS_EX_COMPOSITED seems to do the job, but it doesn't work on classes with CS_PARENTDC.

This makes a copy of the listbox class without the stlye:

    WNDCLASSEXW cls;
    cls.cbSize = sizeof(cls);
    GetClassInfoExW(GetModuleHandleW(L"comctl32.dll"), L"ListBox", &cls);
    cls.style = CS_DBLCLKS;
    cls.hInstance = GetModuleHandleW(NULL);
    cc_listbox_wndproc = cls.lpfnWndProc;
    cls.lpfnWndProc = crap_listbox_wndproc;
    cls.lpszClassName = L"crap_listbox";
    RegisterClassExW(&cls);

crap_listbox_wndproc just calls cc_listbox_wndproc. The original hinstance/wndproc can be used instead, but CS_GLOBALCLASS has to also be specified in that case. I have no idea if htinstance/wndproc can mismatch. Original style for ListBox is CS_DBLCLKS | CS_PARENTDC | CS_GLOBALCLASS

This actually works, but doing this makes double-clicking broken for some reason. Double-clicking in WinAPI never actually worked for me, outside of common controls, so I have no idea why. Maybe something is wrong with window styles? 🤔

I also have no idea what are the implications of messing around with WS_EX_COMPOSITED and CS_PARENTDC, because winapi is underdocumented. :tannedcirno:

there's also SPI_SETLISTBOXSMOOTHSCROLLING, but that's systemwide. Maybe we should just not do this and let user disable it if they want to? 🤔 image