Recent

Author Topic: how to query window handles of external programs? (multiplatform)  (Read 2101 times)

Martin V

  • Full Member
  • ***
  • Posts: 139
After starting an external program from my Lazarus app with tProcess, I know the external process ID but not the window handle. To have the ability of sending messages to the external program, I need to query the window handle of the main form of the external program.

In Windows, I can query reverse the process ID from the window handle. So I need to query all open windows by using GetWindow or enumWindows and compare the process ids with the id I am searching for and - bingo I have the window handle.

But these functions are not for multiplatform programming.

The goal would be a multiplatform function MainWindowHandleFromProcessID. Any ideas?

(I know that an alternative concept of inter-program communication is IPCServer. It will fit my purpose, but I am interested in this anyway.)

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: how to query window handles of external programs? (multiplatform)
« Reply #1 on: August 28, 2016, 12:02:54 pm »
The problem is that not every platform uses the concept of "window handles". So basically if you want it implemented in a truely cross-platform way you are at a loss.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

balazsszekely

  • Guest
Re: how to query window handles of external programs? (multiplatform)
« Reply #2 on: August 28, 2016, 12:14:22 pm »
There are many ways to communicate between two processes: sockets, shared memory, files, memory mapped files, named pipes, message queues, etc. So it can be done cross platform way, just not with window handles.
« Last Edit: August 28, 2016, 12:15:53 pm by GetMem »

 

TinyPortal © 2005-2018