ListerPlugin: how subclassing and message loop?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
smesserschmidt
Junior Member
Junior Member
Posts: 3
Joined: 2017-07-20, 06:45 UTC

ListerPlugin: how subclassing and message loop?

Post by *smesserschmidt »

Hi,

In my lister-plugin I need to handle all keys before the hot-keys are evaluated by the subclassed window. Currently I'm registering a WS_CHILD type of window.

After crawling trough the forum I figured, that I need to save my windowProc-address I set and when my window is subclassed and thus the window's windowProc changes I need to somehow set the original windowProc again (to handle the keys myself) and then redirect to the TC-set windowProc.

My code looks like this:

WNDPROC tc_internal_func = nullptr;

LONG WINAPI
WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
//...handle keyown ..//
if ((WNDPROC)address != (WNDPROC)WindowProc)
{
tc_internal_func = (WNDPROC)address;
SetWindowLongPtr(hWnd, GWLP_WNDPROC,(LONG_PTR)WindowProc);
}
if (tc_internal_func)
{
return CallWindowProc(tc_internal_func, hWnd, uMsg, wParam, lParam);
}
else
{
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
}


Unfortunately this doesn't work, as I suspect it to simply create an infinite loop. Can anyone help me with how to re-direct the messages in a way I can handle all keys inside my lister plugin?


Cheers
Sebastian
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, you create an infinite loop because TC's subclass function calls the original function again.

Instead, just create a second subclass function and set that via SetWindowLongPtr, then call TC's function from it. TC's function will then call the original:

Windows -> Your new subclass function -> TC's function -> original function
Author of Total Commander
https://www.ghisler.com
smesserschmidt
Junior Member
Junior Member
Posts: 3
Joined: 2017-07-20, 06:45 UTC

Post by *smesserschmidt »

Thanks a lot.
In retrospective it seems obvious ;-)

Cheers
Sebastian
smesserschmidt
Junior Member
Junior Member
Posts: 3
Joined: 2017-07-20, 06:45 UTC

Post by *smesserschmidt »

The message chain now seems to work. But I still don't get WM_KEYDOWN events for "W", "L" etc. Are those filtered by anyone else but the lister window?

How do I get all keystrokes, before they are filtered away?

Cheers
Sebastian
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Hmm, they could be filtered by the Delphi menu function because they are part of the menu.

This isn't present in Total Commander Ctrl+Q quick view panel. Do you get all the keys there?
Author of Total Commander
https://www.ghisler.com
Post Reply