Solved

Detect owner window.

Posted on 1998-06-01
7
337 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now