Forum > General

AllocateHwnd alternative on Linux?

(1/2) > >>

lazycat2:
I have a Delphi 11 project that extensively uses AllocateHwnd to communicate between the main thread and background threads (using SendMessage/SendMEssageTimeout/PostMessage). This is very convenient, but now I want to also make this work on Linux with Freepascal.

I was able to make it compile more or less, but AllocateHwnd and SendMessage, as it turned out, don't seem to work on Linux. If I use GTK2 it throws an error ("Widget is nil") and on GTK3 there's no error but it doesn't work. AllocateHwnd always returns zero on Linux. Did I miss something? Or maybe there's a more appropriate alternative (note TThread Synchronize/Queue I'd like to avoid)? The project does not require a GUI at all.

marcov:

--- Quote from: lazycat2 on July 02, 2022, 05:51:24 pm ---  AllocateHwnd always returns zero on Linux. Did I miss something? Or maybe there's a more appropriate alternative (note TThread Synchronize/Queue I'd like to avoid)? The project does not require a GUI at all.

--- End quote ---

Some of those windows specific calls exist for LCL internal purposes, but are by no means full emulations, nor is there the intention to do this.

So in short: use TThread Synchronize/Queue. There is no GUI relation, it is a sysutils construction. 


jamie:

--- Quote from: lazycat2 on July 02, 2022, 05:51:24 pm ---I have a Delphi 11 project that extensively uses AllocateHwnd to communicate between the main thread and background threads (using SendMessage/SendMEssageTimeout/PostMessage). This is very convenient, but now I want to also make this work on Linux with Freepascal.

I was able to make it compile more or less, but AllocateHwnd and SendMessage, as it turned out, don't seem to work on Linux. If I use GTK2 it throws an error ("Widget is nil") and on GTK3 there's no error but it doesn't work. AllocateHwnd always returns zero on Linux. Did I miss something? Or maybe there's a more appropriate alternative (note TThread Synchronize/Queue I'd like to avoid)? The project does not require a GUI at all.

--- End quote ---

How about inserting the use of the TSimpleIPCClient and TSimpleIPCServer between all these apps that need to talk ?

PascalDragon:

--- Quote from: lazycat2 on July 02, 2022, 05:51:24 pm ---I have a Delphi 11 project that extensively uses AllocateHwnd to communicate between the main thread and background threads (using SendMessage/SendMEssageTimeout/PostMessage). This is very convenient, but now I want to also make this work on Linux with Freepascal.
--- End quote ---

The functionality of AllocateHwnd is very Windows specific. And FPC does not yet even provide this for non-Win32, because it requires some assembly level code to work correctly. So better look for other solutions to deal with this that are independant of the used widgetset.


--- Quote from: jamie on July 02, 2022, 10:14:36 pm ---How about inserting the use of the TSimpleIPCClient and TSimpleIPCServer between all these apps that need to talk ?

--- End quote ---

lazycat2 mentioned main and background threads, not processes. While TSimpleIPC* can be used for that, it's simply overkill and simpler mechanisms can be used there.

lazycat2:

--- Quote from: marcov on July 02, 2022, 06:06:24 pm ---Some of those windows specific calls exist for LCL internal purposes, but are by no means full emulations, nor is there the intention to do this.

--- End quote ---
My first impression (based on successful compilation on Linux) was that those features were somehow rewritten to become cross-platform, that would have made porting a lot easier in my case :) Sad that it's not the case.
By the way, shouldn't it throw an error or something (runtime or compile-time) to make it obvious that it won't work? On GTK3 it silently fails.


--- Quote from: jamie on July 02, 2022, 10:14:36 pm ---How about inserting the use of the TSimpleIPCClient and TSimpleIPCServer between all these apps that need to talk ?

--- End quote ---
I'm interested in in-process communication - between background and main thread mostly, I'm not sure those classes are the right fit for the task.

Navigation

[0] Message Index

[#] Next page

Go to full version