简体   繁体   中英

How can I communicate with a Delphi window hosted in a WPF User Control?

Well, actually I know I can communicate with the window itself, the plane GUI, through it's message pump, but let's say I want to call a COM exposed function in the Delphi DLL that produced and maintains that window? I would first somehow have to determine the module that owns the window.

Communications to the Delphi side are minimal: you are now hosted, your host ID is x , can you close, you must close, etc. The rest of the time I will expose my host as a COM object the Delphi code can more easily talk to.

If you have the HWND, you can use GetWindowLong/Ptr(GWL_HINSTANCE) to retrieve the module that the window is associated with.

Another option is to have the DLL register its COM object in the ROT (Running Object Table) and then you can simply query the ROT for the COM object when needed. No HWND needed.

Since this is in process, and since you have a window available, you can send a user defined message to request the COM object. And then you are all set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM