Page 1 of 1

WM_COPYDATA return code when calling em_ commands

Posted: 2018-11-02, 14:32 UTC
by chandragor
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.

Re: WM_COPYDATA return code when calling em_ commands

Posted: 2018-11-05, 14:05 UTC
by ghisler(Author)
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.

Re: WM_COPYDATA return code when calling em_ commands

Posted: 2018-11-05, 15:37 UTC
by chandragor
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.

Re: WM_COPYDATA return code when calling em_ commands

Posted: 2018-11-05, 17:26 UTC
by Dalai
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

Re: WM_COPYDATA return code when calling em_ commands

Posted: 2018-11-06, 08:58 UTC
by chandragor
Yes, it should be, also because any user defined command can be defined even in a language-specific wcmd_*.ini ...

Regards
chandragor