Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to check if a control is partially covered by another window Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
04-Oct-02
Category
VCL-General
Language
Delphi 2.x
Views
101
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius 

Is there a way that I can know if there is a 'Stay On Top' form owned by another 
application partially covering my control?

Answer:

You would have to iterate over all windows above yours in Z-order and check for 
each window you find if it has the WS_EX_TOPMOST exstyle set and is visible. If it 
has, you have to get its window rectangle (GetWindowRect) and test if that overlaps 
your window. Example:
1   
2   procedure TForm1.Button1Click(Sender: TObject);
3   
4     function IsTopmost(wnd: HWND): Boolean;
5     begin
6       Result := (GetWindowLong(wnd, GWL_EXSTYLE) and WS_EX_TOPMOST) <> 0;
7     end;
8   
9     procedure logWindowInfo(wnd: HWND);
10    const
11      visString: array[Boolean] of string = ('not ', '');
12    var
13      buffer: array[0..256] of Char;
14      r: TRect;
15    begin
16      if wnd = 0 then
17        exit;
18      GetClassname(wnd, buffer, sizeof(buffer));
19      memo1.lines.add(format(' Window of class %s ', [buffer]));
20      Windows.getWindowrect(wnd, r);
21      memo1.lines.add(format(' at (%d,%d):(%d,%d)', [r.left, r.top, r.right,
22        r.bottom]));
23      memo1.lines.add(format(' Window is %svisible',
24        [visString[IsWindowVisible(wnd)]]));
25      memo1.lines.add(format(' Window is %stopmost', [visString[IsTopmost(wnd)]]));
26    end;
27  
28  var
29    wnd: HWND;
30  begin
31    memo1.clear;
32    wnd := handle;
33    repeat
34      wnd := GetNextWindow(wnd, GW_HWNDPREV);
35      LogWindowInfo(wnd);
36    until
37      wnd = 0;
38    memo1.lines.add('End log');
39  end;


An easier approach would be to make your own window topmost while it is active.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC