How to detect a cursor position?

English support forum

Moderators: white, Hacker, petermad, Stefan2

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

How to detect a cursor position?

Post by *mia »

Hi all, for using in my home-theatre PC i need to detect, if cursor stay at file or directory. It is possible? Exist any internal command for TC, like result=sendmessage(tc.hWnd, WM_USER+something, any, any), that returns for example 1 for file and 2 for directory? Thanks for answer(s).
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No there isn't, sorry.
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 »

There is possible to detect position of cursor, when i send message LB_GETCARETINDEX or LB_GETCURSEL to listbox "TMyListBox", this message returns index of position of cursor. But there is not possible to get text or any other data from index of cursor? When i send message LB_GETITEMDATA or LB_GETTEXT, returns zero or empty string :-( Is any other way?
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

There must be, because CopyText works well with TMyListBox. This means, it behaves in this sense just like a standard listbox.
I switched to Linux, bye and thanks for all the fish!
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

it behaves in this sense just like a standard listbox.
It behaves just like a standard OWNER-DRAWN listbox!
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2VadiMGP
Because it is one ;-)
I switched to Linux, bye and thanks for all the fish!
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

2SanskritFritzOf course! In this case it means text is not stored in listbox (and therefore cannot be retrieved) but DRAWN by TC itself. ;)
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2VadiMGP
I have to disagree, the text is not drawn by TC, otherwise CopyText would have no chance.
I switched to Linux, bye and thanks for all the fish!
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

2SanskritFritz
Well, you agree listbox is is ownerdrawn but you say "text is not drawn by owner". A little contradiction, isn't? ;)

Most probably CopyText uses some undocumented features.
Did you notice warning in readme?

Code: Select all

Warnings
========

This program may sometimes fail to get text, or even crash another
application. Unfortunately, the bugs of this sort are to be expected:
CopyText demands a certain default behavior from window classes of the
other applications. In some of cases, when these demands are
not met, CopyText cannot function properly.
And it is exactly what happens to me after several attempts to copy from TC.
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2VadiMGP
Well, you agree listbox is is ownerdrawn but you say "text is not drawn by owner". A little contradiction, isn't?
Ownerdrawn does not mean, that everyting is drawn by the host application, it merely means, that in addition to the standard features, a program can hook in, adding some extra features, like colouring, etc.
Most probably CopyText uses some undocumented features.
It is not CopyText which uses undocumented features, but the controls you want to copy from. CopyText can only use known messages of some known standard controls (list box, combo box, check box, radio button etc). If a control is not a standard windows control, CopyText will fail to copy from it, or even recongnize the control.
And it is exactly what happens to me after several attempts to copy from TC.
I use CopyText for maybe 10 years now, and often copy text from TC, never had any problems. I tried just now, no problems.

Well the conclusion is: TC uses a normal list box spiced up a little, and the text is drawn by standard windows means, any application should be able to read its contents, the only problem is, i dont know what messages to send ;-)
I switched to Linux, bye and thanks for all the fish!
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

mia
Maybe, this will help: send command cm_CopyNamesToClip to TC, this will copy to the clipboard the current file's name. If this is a directory, it will end with backslash "\" like "MyFolder\", so you will be able to easily determine what you need.
Unfortunately, this will not work if some files or folders are selected: the command above will copy all the selected items' names then...
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: I think that this is right for me :-) If this will copy all selected items, then better for me. Will try... Thanks.
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

2SanskritFritz
Ownerdrawn does not mean, that everyting is drawn by the host application, it merely means, that in addition to the standard features, a program can hook in, adding some extra features, like colouring, etc.
In general - yes. But I wrote "in this case". If you want to store strings in ownerdrawn listbox you have to add LBS_HASSTRINGS style. Does TC listbox have this style?
It is not CopyText which uses undocumented features,
How you know this? Do you have sources of CopeText? Did you tried to write similar application using documented features only?
any application should be able to read its contents, the only problem is, i dont know what messages to send
Oh, only your problem is message? I'm glad to help you! :)
Microsoft wrote:LB_GETTEXT
An application sends an LB_GETTEXT message to retrieve a string from a list box.
So please, could you write small application to send CB_GETLBTEXT message to TC list box and retrieve strings?
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2VadiMGP
Ok, I tried. No success :-(
I guess LBS_HASSTRINGS is not set. So I guess you are right, CopyText does something tricky. Maybe we will find out what. Thanks for your hint!
I switched to Linux, bye and thanks for all the fish!
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

2SanskritFritz
Ok, I tried. No success
Well, experience is the best teacher but rough teacher! Now we both finished the same scool. ;)
I guess LBS_HASSTRINGS is not set.
Exactly. You even don't need to guess. You can run SpyXX and investigate window styles.
Post Reply