ctrl+c bug in lister

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: sheep, Hacker, Stefan2, white

deondreboylextc
Junior Member
Junior Member
Posts: 7
Joined: 2016-10-13, 13:26 UTC

ctrl+c bug in lister

Post by *deondreboylextc »

1) open any file in lister (A)
2) search for anything that is not in the opened file
3) do not click on the OK button in "Not found:" dialog
4) go back to the main TC window and open another file in another lister (B)
5) select any text in lister (B) and press ctrl+c
6) paste the "copied" text somewhere, eg. the notepad
7) you just ended up with text:

Code: Select all

---------------------------
Reading directories: %3i  (Esc to abort)
---------------------------
adsa
---------------------------
OK   
---------------------------

instead of the text selected in the step 5)

The text "Reading directories: %3i (Esc to abort)" seems to be randomly selected if you repeat this process.


It looks like the "Not found:" dialog is stealing the ctrl+c events.

I put a screenshot of all steps at http://imgur.com/CjJGdmB.
User avatar
petermad
Power Member
Power Member
Posts: 9848
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Post by *petermad »

Confirmed for TC9rc3 32bit and 64bit

It also applies to TC8.52a - I think something similar has been reported before, and that the behaviour couldn't be avoided, but I can't find it now.
License #524 (1994)
Danish Total Commander Translator
TC 9.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (2004) 64bit, 'Everything' 1.4.1.988 (x64)
TC 3.10 on Android 6.0
Get:
Extended TC Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
MaxX
Power Member
Power Member
Posts: 700
Joined: 2012-03-23, 18:15 UTC
Location: Earth

Post by *MaxX »

Confirm for both TC 8.52a abd TC 9.0 RC3.
browny
Senior Member
Senior Member
Posts: 216
Joined: 2007-09-10, 13:19 UTC

Post by *browny »

Lister is a thread in TC.
Standard messagebox dialog handles Ctrl+C for copying its texts into the clipboard.
The dialog is modal, therefore shortcut would be intercepted by the latest messagebox and would not go to other threads or TC main window.
To copy the current selection text try to use Ctrl+Ins.
deondreboylextc
Junior Member
Junior Member
Posts: 7
Joined: 2016-10-13, 13:26 UTC

Post by *deondreboylextc »

Hi browny, thanks for the workaround (the other way I know of is to use the popup menu and select copy as text).

But this hardly solves the problem.

The problem is that TC is doing something (copies the error text) while the user expects something else (he want to copy the text) and there is no explanation as to where the error text came from.

Also the argument that the messagebox handles Ctrl+C does not always hold.

I found out that if you repeat steps 5) and 6) many times, sometimes you do get the selected text instead of error text.

It is also worth to mention that there is another bug.

The title text in the copied text does not match the title text of the messagebox.

In my example there was "Reading directories: %3i (Esc to abort)" instead of "Not found:".

And there is also this bug:

1) open any file in lister (A)
2) search for anything that is not in the opened file
3) do not click on the OK button in "Not found:" dialog
4) go back to the main TC window and open another file in another lister (B)
5) search for anything that is not in the opened file
6) now go back to lister (A) and click OK in the "Not found:" dialog
7) observe that lister (A) now does not accept any user input and there is this "wait" mouse cursor
8) go to lister (B)
9) click OK in the "Not found:" dialog
10) go to lister (A) and observe that now it does process user input

What I hoped to demonstrate is that there is something fishy with the way how messageboxes and multiple windows are handled in TC.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 39974
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, this has been discussed before - it is NOT solvable. If it bothers you, then don't use internal lister. Instead, define an external viewer for F3 like this:
c:\totalcmd\totalcmd.exe /S=L "%1"
Author of Total Commander
http://www.ghisler.com
deondreboylextc
Junior Member
Junior Member
Posts: 7
Joined: 2016-10-13, 13:26 UTC

Post by *deondreboylextc »

Hi, ghisler, here is my proposed solution:

Add line like this at the end of the error message:
This text was copied to the clipboard because you pressed ctrl+c in total commander while there was a messagebox shown (but not necessary in the foreground). If you wanted to copy something else, find the messagebox and close it before cointinuing or use ctrl+ins instead of ctrl+c.
This way you can tell the perplexed user what is going on and what to do.

Thanks!
User avatar
MVV
Power Member
Power Member
Posts: 8546
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Ctrl+C is handled by Windows MessageBox function, not TC, and why should he add such an odd strange extra piece of text to every copied message?
browny
Senior Member
Senior Member
Posts: 216
Joined: 2007-09-10, 13:19 UTC

Post by *browny »

MVV wrote:Ctrl+C is handled by Windows MessageBox function, not TC
Correction: MessageBox hadler is still in TC context. Otherwise any other application would copy the same MessageBox' contents instead of selection.
User avatar
MVV
Power Member
Power Member
Posts: 8546
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Correction (it is rather an assumption) is wrong. MessageBox Ctrl+C handler is in Windows system library, it is a system-wide function that works in every message box, not in TC only.
When you call MessageBox API function, it does all itself: shows window, handles events, copies text on Ctrl+C etc.
Other applications either don't allow copying text while modal dialog is shown (perhaps mostly) or use separate threads for windows (but Delphi uses the same thread for all windows so we have this problem).
browny
Senior Member
Senior Member
Posts: 216
Joined: 2007-09-10, 13:19 UTC

Post by *browny »

MVV wrote:Correction (it is rather an assumption) is wrong. MessageBox Ctrl+C handler is in Windows system library, it is a system-wide function that works in every message box, not in TC only.
You failed to spot the word context, did you not?
User avatar
MVV
Power Member
Power Member
Posts: 8546
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Yes, it is TC context, but it is a system library memory area. So you suggest to hack undocumented system function call in a system library while MessageBox function does its work or install a hook for subclassing dialog box just in order to provide own realization of Ctrl+C handler when existing one is pretty good but doesn't print the extra footer, am I correct? I don't think that the goal worths the effort.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 39974
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Add line like this at the end of the error message
I can't - Ctrl+C isn't even going to TC, it's intercepted by the message handler of the MessageBox function.
Author of Total Commander
http://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

It should be technically possible to change the default behavior:

- a thread-only message hook should be installed (this shouldn't be any problem for antivirus software, in opposite to system-wide message hooks),

- if Ctrl+C has been pressed and the window, given by the message record, is a dialog window (class name tells this), hook function should change the handle value in the message record, from a handle of message box to the handle of its parent.
User avatar
MVV
Power Member
Power Member
Posts: 8546
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It is possible, and I've mentioned a hook, but it is too much effort for such thing.
Post Reply