Solved

Detect owner window.

Posted on 1998-06-01
7
336 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
Comment Utility
If you have your control's handle, you could use:
  GetWindow(MyControl.Handle, GW_OWNER);

Cheers,
JB
0
 

Author Comment

by:mshaw
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:mshaw
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Slash,
well done. It worked a treat.
Mark.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now