Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Sending message to a window

Sending message to a window

Scheduled Pinned Locked Moved C#
questioncsharphelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DavidR_r
    wrote on last edited by
    #1

    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

    A H 2 Replies Last reply
    0
    • D DavidR_r

      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

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • D DavidR_r

        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

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        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 the SendMessage API. You'll need the HWND 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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups