Sending message to a window
-
Hi, I've got an application which responds to WM_COMMAND Message with some defined Wparams Now I am writing a service in .NET which should control that application by sending him messages. The question is: how do I send a message to a window? I already created the message using the Message class, obtained the handler of the window of the desired application, but still the sending part is missed. can u help me? DavidR
-
Hi, I've got an application which responds to WM_COMMAND Message with some defined Wparams Now I am writing a service in .NET which should control that application by sending him messages. The question is: how do I send a message to a window? I already created the message using the Message class, obtained the handler of the window of the desired application, but still the sending part is missed. can u help me? DavidR
I'm not sure on what type of application you are creating, but if I were you, I would try to simply make a function to the child that can be called from the parent's instance to send the message. In other words ChildInstance.sendData(params) Wouldn't that work?
-
Hi, I've got an application which responds to WM_COMMAND Message with some defined Wparams Now I am writing a service in .NET which should control that application by sending him messages. The question is: how do I send a message to a window? I already created the message using the Message class, obtained the handler of the window of the desired application, but still the sending part is missed. can u help me? DavidR
You simply P/Invoke
SendMessage
. See http://pinvoke.net/default.aspx/user32.SendMessage[^] for the syntax. This is how you would do it (well, one way) in a native C/C++ application (or even in VB6 and below by declaring theSendMessage
API. You'll need theHWND
to the destination window, but it sounds like you already have it. You'll also most likely need to register your service either as a specific user with local login rights, or as the Local System with the "Allow service to interact with desktop" checked (search this message board using "Search comments" above for a previous reply about how to do this I wrote a day or two ago).Microsoft MVP, Visual C# My Articles