WM_COPYDATA return code when calling em_ commands

Please report only one bug per message!

Moderators: Stefan2, white, sheep, Hacker

Post Reply
User avatar
chandragor
Junior Member
Junior Member
Posts: 82
Joined: 2005-06-01, 10:10 UTC
Location: Italy

WM_COPYDATA return code when calling em_ commands

Post by *chandragor » 2018-11-02, 14:32 UTC

I don't know if this can be considered a bug report or a suggestion (maybe both).
Feel free to move this post to the appropriate section if I posted it in the wrong one.

From MSDN:

WM_COPYDATA Return value:
If the receiving application processes this message, it should return TRUE; otherwise, it should return FALSE.

Instead, when calling em_ user defined commands, TC always returns FALSE (0).

I suggest to return TRUE (1) and to return FALSE only in case of error, i.e. if the command has not been implemented.

Or you can notify the window passing the data, if its handle was set in the wParam argument of SendMessage, just like the "GW" / "GA" usage of WM_COPYDATA which notify a "RW" / "RA" to the calling window.

This way, as an added bonus, you can avoid the error message box in TC, if the calling window handle has been passed.
Happy owner of license #12422 since 1997

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

Re: WM_COPYDATA return code when calling em_ commands

Post by *ghisler(Author) » 2018-11-05, 14:05 UTC

I'm not sure whether this is such a good idea to change it. People will assume that it returns true when the command was successful, but this isn't always possible to determine because the commands may be executed asynchronously.
Author of Total Commander
http://www.ghisler.com

User avatar
chandragor
Junior Member
Junior Member
Posts: 82
Joined: 2005-06-01, 10:10 UTC
Location: Italy

Re: WM_COPYDATA return code when calling em_ commands

Post by *chandragor » 2018-11-05, 15:37 UTC

I understand.
Yet I think it would be a good idea if there was a way to give some feedback to the calling program if the requested em_ command was not defined.
The only way, right now, is to parse the UserCmd.ini file for a section with that name.

Thanks anyway.
Happy owner of license #12422 since 1997

User avatar
Dalai
Power Member
Power Member
Posts: 6535
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: WM_COPYDATA return code when calling em_ commands

Post by *Dalai » 2018-11-05, 17:26 UTC

There's another reason why it's not generally possible to return True: em_ commands might consist of more than one cm_ command, and some of them might fail. What should be returned in such a case and who could decide what's the best approach? The truth is that It's not so simple (true/false).

However, I agree that it should be possible to determine whether or not an em_ command is defined.

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
chandragor
Junior Member
Junior Member
Posts: 82
Joined: 2005-06-01, 10:10 UTC
Location: Italy

Re: WM_COPYDATA return code when calling em_ commands

Post by *chandragor » 2018-11-06, 08:58 UTC

Yes, it should be, also because any user defined command can be defined even in a language-specific wcmd_*.ini ...

Regards
chandragor
Happy owner of license #12422 since 1997

Post Reply