Solved

Detect owner window.

Posted on 1998-06-01
7
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

724 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