?
Solved

Detect owner window.

Posted on 1998-06-01
7
Medium Priority
?
343 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
Technology Partners: 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 400 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 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