Any way to get filename under cursor?

English support forum

Moderators: white, Hacker, petermad, Stefan2

mia
Junior Member
Junior Member
Posts: 25
Joined: 2004-03-17, 09:53 UTC

Any way to get filename under cursor?

Post by *mia »

Please, it is possible to get filename under cursor? I want to send it to my LCD display, but - there is no way to get name through LB_GETCARETINDEX & LB_GETTEXT, why? And - if i use cm_CopyNamesToClip, then there is a "No files selected" message on top of dir. Very sad... Sure is there no way?
...to define recurse, we must to define recurse first...
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

No, currently we dont know how to get the filename. Probably Christian is able to tell us what message to use, if he is willing to. On the other hand, the utility CopyText does get the filenames, so it is a well known method... for others. AFAIK, CopyText is able to get data from Delphi controls, so the secret could be some Delphi dll call.
I switched to Linux, bye and thanks for all the fish!
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

BTW, you can use the LB_GETCURSEL message to get the position of the cursor. This way you can prevent the problem described in the cm_CopyNamesToClip method.
I switched to Linux, bye and thanks for all the fish!
mia
Junior Member
Junior Member
Posts: 25
Joined: 2004-03-17, 09:53 UTC

Post by *mia »

Thanks for reply, i'll try it :-)
...to define recurse, we must to define recurse first...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Unfortunately you can't currently get the name. Your only option is to create a starter menu entry or button bar command with parameter %P%N, and then invoke that command from outside.
Author of Total Commander
https://www.ghisler.com
mia
Junior Member
Junior Member
Posts: 25
Joined: 2004-03-17, 09:53 UTC

Post by *mia »

ghisler: will be added this feature in future release? This seems very useful :-) Thanks.
...to define recurse, we must to define recurse first...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

How could this be done? Most messages do not allow to pass pointers between applications (except for WM_COPYDATA). Any suggestions?
Author of Total Commander
https://www.ghisler.com
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

And what's wrong with WM_COPYDATA?
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
mia
Junior Member
Junior Member
Posts: 25
Joined: 2004-03-17, 09:53 UTC

Post by *mia »

Flint: how to use WM_COPYDATA, please?
...to define recurse, we must to define recurse first...
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

mia
Flint: how to use WM_COPYDATA, please?
The application sends to TC some special message (e.g. WM_USER+51 with some reserved argument which is not present in totalcmd.inc). TC handles this message and sends WM_COPYDATA back to the application with the name and/or path of the file inside it.

Or did you mean internal details? If yes, look in the MSDN, there is an example of usage.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
mia
Junior Member
Junior Member
Posts: 25
Joined: 2004-03-17, 09:53 UTC

Post by *mia »

Flint: which "special arguments" you mean? I was trying to send some commands not listed in totalcmd.inc and TC not send any WM_COPYDATA message, but show message window "function not implemented".

Edit: I was trying to send command "0" (nothing happens), "1", "2222" (Function not implemented)... I captured messages through "Spy" application, apply filter General, where is WM_COPYDATA message.
...to define recurse, we must to define recurse first...
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

mia
Flint: which "special arguments" you mean? I was trying to send some commands not listed in totalcmd.inc and TC not send any WM_COPYDATA message, but show message window "function not implemented".
I think, you misunderstood me. My reply
And what's wrong with WM_COPYDATA?
was directed to Christian, not to you! I asked him, why not to implement such a way of getting current file name (send a message to TC -> TC replies with WM_COPYDATA). Of course, it is not working now, because it needs some new functions implemented in TC that are not currently implemented! :)
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
mia
Junior Member
Junior Member
Posts: 25
Joined: 2004-03-17, 09:53 UTC

Post by *mia »

Flint: Ups... my mistake :-), sorry...

Ghisler: Maybe hidden textbox with unique name (for example Filename), where will be passed filename under cursor. Or hidden listbox (SelectedFiles), where will be passed all selected filenames (very useful for creating m3u playlists).

example:

Text_hWnd = FindWindowEx(TC_hWnd, 0, "Filename", 0)
res = SendMessage(Text_hWnd, WM_GETTEXT, length, pointer_of_Name$)

or similar for listbox.

Your current listboxes (TMyListbox) are nonstandard, right? Cursor position is handled OK but in item is nothing.
Last edited by mia on 2006-06-25, 20:33 UTC, edited 1 time in total.
...to define recurse, we must to define recurse first...
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

Any suggestions?
In any predefined or registered message it is possible to pass the handle to global allocated memory. Application can use GlobalAlloc.

Code: Select all

HGLOBAL hMem = GlobalAlloc(GMEM_FIXED, MAX_PATH);
TC can check allocated size by GlobalSize and return filename:

Code: Select all

if (GlobalSize(hMem)>=MAX_PATH)
{
    char *ptr=GlobalLock(hMem);
    strncpy(ptr,FileName,MAX_PATH);
    GlobalUnlock(hMem);
}
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

One small comment: it IS possible to get the filename at present, we just have to find out how. I hoped Christian will tell us the method, but I'm afraid he does not know this either. Maybe the author of CopyText will enlighten us. I would write an email to him, but unfortunately there is no valid email address now :-(
If someone knows some good Delphi gurus, they could tell us what Delphi specific calls are needed to get the actual text from an owner drawn listbox.
I switched to Linux, bye and thanks for all the fish!
Post Reply