mIRC Homepage
Posted By: ARandomFurry Using DLL's Function in Remote Event - 17/07/14 06:23 AM
So, within an ON TEXT or similar remote event, when I use /dll or $dll the HWND that's supposed to be the active window is always the status window, not the window that recieved the event. How can I fix, or work around this?
Posted By: Iire Re: Using DLL's Function in Remote Event - 17/07/14 07:17 PM
Correct - that is the reason you can't use /say and /me in such events.

How, exactly, you handle this will depend on the event. For the on TEXT and ACTION (and to some extent, NOTICE) events, you can use:
Code:
$gettok($chan(#).hwnd $query($nick).hwnd $window(Message Window).hwnd,1,32)
within the event to return the handle of either the channel, query window, or dedicated message window, depending.
Posted By: Loki12583 Re: Using DLL's Function in Remote Event - 17/07/14 07:23 PM
Quote:
Extended SendMessage() to enable executing a command in the context of a remote event. During a remote event, a $eventid identifier is set to a unique value to identify the event. This can be passed to a DLL which can then pass it back to mIRC using: SendMessage(mHwnd, WM_MCOMMAND, MAKEWPARAM(cMethod, cEventId), cIndex)

This will cause the command/evaluation to execute in the context of the remote event identified by cEventId. If cEventId is 0, this indicates a non-remote event.


This change added in 7.33 may also be useful
Posted By: Wims Re: Using DLL's Function in Remote Event - 18/07/14 01:24 PM
Read this thread, which tell us it's normal to get the hwnd of the status window for almost all events (has nothing to do with the fact you can't use /me inside an event, mIRC is aware if you do /me from an on text event which listen on a channel and could totally make /me working here by sending an action to that channel).
There is no local identifier returning the HWND of the window associated with the event, you can't possibly pass/use such a value, you can't possibly be annoyed by this side effect of running events with the status window, UNLESS you are using $window(@ $+ $wid).hwnd inside the definition of the event which is unlikely (in the thread, a workaround for that seems to grab the $wid value inside an alias call from that event..
Can this returned handle be use as an HWND in a C/C++ DLL (is it an integer that can be converted to a HWND or HWND*)?

Edit: It is a shame that the active window isn't the calling window, but the server's status window.
Posted By: Wims Re: Using DLL's Function in Remote Event - 22/07/14 12:37 AM
Yes, those handles are not fake handles lol.
But I found what you need, when you make a call to a dll, the prototype of the function include an "aWnd" parameter, which is the handle of the window in which the command is being issued, this should be your correct target window.
I currently use that parameter, it isn't correct. It is set to the status window of the connection when used in remote events. When used in an alias or the remote event on INPUT it is correctly set.
Posted By: Wims Re: Using DLL's Function in Remote Event - 23/07/14 05:51 AM
Then you have to pass the parameter yourself, using $chan().hwnd for example
Okay. I will do this, and then cast it to a HWND in the DLL.
© mIRC Discussion Forums