Getting the Window-Handle of the Automation-Application (HWND)

Add-in Express™ Support Service
That's what is more important than anything else

Getting the Window-Handle of the Automation-Application (HWND)
 
Raed Qumsieh




Posts: 4
Joined: 2015-10-19
Hallo,

I Need a way to access the Handle (HWND) of the ActiveWindow of the automated application (e.g. Excel) using Delphi ??

I added a custom Form (Form1) and i want to pass the "HWND" as a Parameter for the Methode TForm1.CreateParented(ParentHandle).

Thx.
Posted 03 Nov, 2015 13:09:20 Top
Raed Qumsieh




Posts: 4
Joined: 2015-10-19
I meen without creating a new Ole variable and using CreateOleObject
Posted 03 Nov, 2015 13:13:20 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Hello Raed,

In Excel 2013 they introduced Application.Hwnd and Windows.Hwnd, see https://msdn.microsoft.com/en-us/library/office/ff840629%28v=office.15%29.aspx and https://msdn.microsoft.com/en-us/library/office/dn292510%28v=office.15%29.aspx.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Nov, 2015 06:47:21 Top
Raed Qumsieh




Posts: 4
Joined: 2015-10-19
Hello Andrei,

those Solutions are in VBA. I'am using only your Add-In module (DLL) in Delphi, without any XLA or XLAM files. The global variable ExcelApp (from class TExcelApplication) do not provide any property (such as .Hwnd or .Handle) which allows me to get the window handle of the active Excel application.
Posted 04 Nov, 2015 07:05:02 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Raed Qumsieh writes:
those Solutions are in VBA.


You are wrong. You can import the corresponding type library and use those properties in your code. An example is given in Using Outlook2010 instead of Outlook2000.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Nov, 2015 07:13:17 Top
Raed Qumsieh




Posts: 4
Joined: 2015-10-19
Oh Yes of Course!! Thank you Andrei.

I found the property ".HostApp" in the class TadxCOMAddInModule, it returns the Excel-Application as OleVariant. this was my best solution as far.

Thanks again for your quick Response.
Posted 04 Nov, 2015 07:51:34 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
You are welcome!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Nov, 2015 09:22:15 Top