CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Posts
    33

    postmessage to another instance of my app?

    I have set up my mdi app so that only one instance of my app can run at a time. Now the twist is that when the second app is executed and he sees that there is already an instance running, he needs to send to the already running instance a file path/name to open, and then exit. The part where only one instance runs at a time is working flawlessly. The problem that I am having is that I cannot seem to send a user message to the app after calling RegisterWindowMessage(). Is there a good example out there on how to do this correctly? Couple of things trouble me:
    1. examples that I have seen show views receiving user-defined messages. Mine is set up for the application to receive. Is this my problem?
    2. I do a search in CodeGuru for "RegisterWindowMessage" and get a bunch of hits, but when I do a 'Find on this page' in IE, I get no matches?!

    Thanx

  2. #2
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    As for how to send a message to the application instead of a window I don't know how to do that. For RegisterWindowMessage I hope my simple sample helps; see Using Registered Message Ids. If you need to send a string then you might need to use WM_COPYDATA instead.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  3. #3
    Join Date
    Oct 2002
    Location
    Vietnam
    Posts
    112

    Lightbulb

    You know every app has its own message queue, that means you just send mess inside your app.

    If you want to send mess to another app, may be you have to use Hook technology. With this skill, you can send any kind of messages to any apps in Microsoft Desktop app.

  4. #4
    Join Date
    May 2002
    Location
    Russia
    Posts
    1,571
    every app has its own message queue
    every thread has it's own message queue (if it's GUI-thread). Hence, in process there is a many message queues.

  5. #5
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Perhaps ::PostThreadMessage will send a message to the application but you might need to get the threadid to do that and you cannot use it to send a WM_COPYDATA message.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured