Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 2 Monaten
Letzter Beitrag:
vor 1 Jahr, 2 Monaten
Beteiligte Autoren:
André Labuschagné, Fabrice Harari, Paulo Oliveira, Arie

Send Message To A Program

Startbeitrag von André Labuschagné am 16.03.2017 17:48

Hi All

I have received a reply from PCSoft about getting App A to get App B to be active. The answer is cryptic and I have no idea where to start"

"You may try to send a Windows message to the program"

That makes sense but.....

1. How do I get the handle of the window of App B if App A and App B are the exact same app but different instances?

2. What is the message that I am going to send to the app to get it to be active?

Getting there but very slowly.



I think I have solved 2 - will use WM_ACTIVATEAPP. But how do I get the handle of the window of App B :-(

von André Labuschagné - am 16.03.2017 18:10
Did you try if can get the handle with SysWinHandle?

von Paulo Oliveira - am 16.03.2017 18:24

when starting the first instance, this instance easily can get it's own handle using Instance() the Handle() function (not sure which one you need) . If you save it to an inifile or in your db, then when starting the second instance you can read that handle and use it.

von Arie - am 16.03.2017 18:36
Paulo - I looked at that but the title of the window is the same in the two apps. But what has just occurred to me now is that the docs say that it assumes a non windev app - so it may by default ignore the same window in the calling app. Will give it a bash.

Arie - that will be a cunning plan. Will look at instance as well.


von André Labuschagné - am 16.03.2017 18:55
Arie - anyway of storing this in RAM instead? An area that both apps can address?


von André Labuschagné - am 16.03.2017 19:19
Hi André,

when starting the second app, you should:
- detect that the fist app is there (in the project init code)
- if it's there, find the handle of it's window (as you have NOT open any window yet, only the original program window is there to detect)
- do a sendmessage with a specific message number to that window
- in that window, have an event on that specific message number and make your window visible when you receive it

that's all

von Fabrice Harari - am 16.03.2017 20:13
Hi Fabrice

I was wondering about that - as the window is not open yet I will only find one and will therefore have its handle. Cool. Will try that.


von André Labuschagné - am 16.03.2017 21:07
Hi Fabrice

I have no ways of finding the handle of the other app's window. SysWinHandle uses the title and that is variable. I cannot see any other way of doing it.


von André Labuschagné - am 16.03.2017 21:19
Problem solved - use exerunning, syswinhandle and sendmessage. Thanks all - especially Fabrice's fourth point.


von André Labuschagné - am 17.03.2017 00:07
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.