PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0) causes a glitch

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
AkulaBig
Senior Member
Senior Member
Posts: 372
Joined: 2021-09-09, 17:28 UTC

PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0) causes a glitch

Post by *AkulaBig »

PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0);
SetForegroundWindow(hListerHandle);
SetFocus(hListerHandle);
This design hangs TC when exiting Quick View.
Without focus transfer when only one command is used PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0); everything works perfectly. But the focus remains in the view pane.
Is it possible to somehow use the command PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0); and move focus to the panel where the plugin was called from, so that TC does not freeze.
The problem itself arose due to the fact that I have to handle exiting an external program using Esc in the TC Quick View. There is no way to disable Esc in an external program.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0) causes a glitch

Post by *ghisler(Author) »

307 is cm_SrcHideQuickView. Do you call this from within a lister plugin? This would close quick view and the plugin, but only when Total Commander gets active again (the message loop handles the posted message). Your SetForegroundWindow and SetFocus calls are therefore handled before cm_SrcHideQuickView.
Author of Total Commander
https://www.ghisler.com
AkulaBig
Senior Member
Senior Member
Posts: 372
Joined: 2021-09-09, 17:28 UTC

Re: PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0) causes a glitch

Post by *AkulaBig »

Thank you for the clarification.
AkulaBig
Senior Member
Senior Member
Posts: 372
Joined: 2021-09-09, 17:28 UTC

Re: PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0) causes a glitch

Post by *AkulaBig »

ghisler(Author) wrote: 2024-03-25, 08:32 UTC Your SetForegroundWindow and SetFocus calls are therefore handled before cm_SrcHideQuickView.
And this is how it happened:
SetForegroundWindow(hListerHandle);
SetFocus(hListerHandle);
PostMessageW(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0);
SendMessageW(hAppHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0) causes a glitch

Post by *ghisler(Author) »

Your SendMessageW is also handled before the PostMessageW call, because it directly calls the message handler and waits for the response, while PostMessageW puts the message at the end of the message queue. It is only handled when Total Commander handles messages in the message loop (GetMessage or PeekMessage).
Author of Total Commander
https://www.ghisler.com
AkulaBig
Senior Member
Senior Member
Posts: 372
Joined: 2021-09-09, 17:28 UTC

Re: PostMessage(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0) causes a glitch

Post by *AkulaBig »

ghisler(Author) wrote: 2024-03-29, 13:49 UTC Your SendMessageW is also handled before the PostMessageW call
Yes, sure. To make the code more correct, I fixed it:
SetForegroundWindow(hListerHandle);
SetFocus(hListerHandle);
SendMessageW(hAppHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
PostMessageW(FindWindowW(L"TTOTAL_CMD", 0), 1075, 307, 0);
Post Reply