Results 1 to 10 of 10

Thread: PostMessage() across process boundaries equivalent

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default PostMessage() across process boundaries equivalent

    Hello,
    is there anything equivalent to the windows PostMessage() across application boundaries?
    Qt Code:
    1. HWND hWnd = ::FindWindow(NULL, "MyOtherApplication");
    2. ::PostMessage(hWnd, IntegerMessageID,
    3. (WPARAM)param1,
    4. (LPARAM)param2);
    To copy to clipboard, switch view to plain text mode 

    I've got Qt GUI apps talking to a COM server that sits on a big heap of code. Parts of that code should be able to tell the GUI that it needs updating. Before I started using Qt I was using the PostMessage(). My GUI could catch it and ask the COM server for fresh info.

    any (simple) ideas?

    thanks
    K

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PostMessage() across process boundaries equivalent

    Can't you use COM techniques (activeX) for that?

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: PostMessage() across process boundaries equivalent

    Yes, you can.
    but, two things: (both my fault)
    The code I have is organised into into layers. my machine layer is close to the hardware. An automation layer looks after the interaction between machines. My COM server provides a wrapper interface to the automation layer. My GUIs are on top and should 'look like' the machines. I don't really want my 'machines' to know about anything else above them - except that the machines can change status on their own and should let the GUIs know that they need updating. The GUI can then go and ask the COM server for new info.

    I'm sure there are several ways of doing this: I could poll from the GUI with a 'stateChanged()' func (easy but ugly), or pass function pointers that the machine objects can call to order updates (ugly and ugly). I just thought that PostMessage() is fairly easy and light-weight. If there were a Qt equivalent in QProcess or something...

    Further, my COM is uni-directional: I don't (or didn't) want to bang in another interface(s) so that the server can call all the programs that access it (there's no real need).

    and, secondly:
    eventually I'd like to remove the MS dependencies. and eventually would like to get away from COM altogether, I'll need to run on other operating systems. I think that'll be a challenge - I'll need to start learning CORBA ' stuff.

    so ... am I doing things the wrong way? grateful for any ideas.

    Thanks
    K

  4. #4
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostMessage() across process boundaries equivalent

    Do you have a commercial license? If not don't bother reading the rest of my answer.

    With the QtSingleApplication solution code, you can set up your different apps to be singletons (I'm not sure if this is appropriate for you). Then, to send a message, you can just execute the app using QProcess and a commandline that describes your new message. If the app is already running, then a message is just sent directly to the running app.

    In fact, if you inspect the QtSingleApplication code carefully, you can probably change this to eliminate the singleton behaviour, but maintain the message passing behaviour.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: PostMessage() across process boundaries equivalent

    Wow, nice hack . That sounds like it's worth playing with! I'll give it a try.

    thanks
    K

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PostMessage() across process boundaries equivalent

    Or you can just use winapi to make your call and then catch it with platform events (winEvent or something like that -- never used it, so check the docs).

  7. #7
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostMessage() across process boundaries equivalent

    Doesn't work very well on other platforms though.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PostMessage() across process boundaries equivalent

    Just like COM itself.

  9. #9
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostMessage() across process boundaries equivalent

    Quote Originally Posted by wysota
    Just like COM itself.
    ...which is why he said this:

    eventually I'd like to remove the MS dependencies. and eventually would like to get away from COM altogether, I'll need to run on other operating systems. I think that'll be a challenge - I'll need to start learning CORBA ' stuff.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PostMessage() across process boundaries equivalent

    Yes, I missed that.

    Anyway, things like shared memory or named pipes are always an alternative (yes, I know Qt doesn't have direct support for them).

    BTW. Corba (and other RPCs) involve using network sockets, so with simple apps it might be simpler to just use network sockets yourself instead of higher level protocols.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.