Solved

Detect owner window.

Posted on 1998-06-01
7
340 Views
Last Modified: 2013-11-23
I need to detect the handle of the window in which my component is placed.
Using the owner's handle is fine when the component is on a form in Delphi, but that doesnt work when its on an ActiveForm in a web browser.
Currently I use the windows API call GetActiveWindow, but I cannot rely on the web browser being the active window.
0
Comment
Question by:mshaw
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1349574
If you have your control's handle, you could use:
  GetWindow(MyControl.Handle, GW_OWNER);

Cheers,
JB
0
 

Author Comment

by:mshaw
ID: 1349575
Yes, I thought that would have worked, and have already tried that. It doesnt work when my component is an activex control in a web browser.
Strangely, the IsControl function returns false, both for my component and for the active form.
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1349576
Mmm...  I presume you're using Delphi 3, so what does MyControl.ParentWindow return?

(The "IsControl" property affects property streaming at design-time.  I don't know how relevant it is to your situation???)

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:mshaw
ID: 1349577
Yes, I'm using D3. It returns 0.

The whole reason I'm trying to get the handle of the window is to change the window procedure for that window so that my component can detect when that window is being moved. It works when its a VCL and ActiveX component in a D3 form, but not when its in a web browser.
0
 
LVL 4

Accepted Solution

by:
d003303 earned 100 total points
ID: 1349578
Yo,
have you tries GetParent ? like

AHandle := Self.Handle;
while GetParent(AHandle) <> 0
 do AHandle := GetParent(AHandle)
// now AHandle is the top parent window

Slash/d003303
0
 
LVL 4

Expert Comment

by:d003303
ID: 1349579
Sorry, dependant on the object scope the code will not compile. Take this :

AHandle := Self.Handle;
while Windows.GetParent(AHandle) <> 0
 do AHandle := Windows.GetParent(AHandle)
// now AHandle is the top parent window

Slash/d003303
0
 

Author Comment

by:mshaw
ID: 1349580
Slash,
well done. It worked a treat.
Mark.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi: how to send PJL commands to printer 3 108
error 1.1 400 Bad request idhttp delphi 18 143
Multi-layered image in FireMonkey 9 48
Tvertscrollbox like a whatsapp layout 5 34
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question