Найти формы, которые частично перекрывают окно вашего приложения

{codecitation class=»brush: pascal; gutter: false;» width=»600px»}

Оформил: DeeCo

Автор: http://www.swissdelphicenter.ch

{

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:

}

procedure TForm1.Button1Click(Sender: TObject);

var

wnd: HWND;

function IsTopMost(wnd: HWND): Boolean;

begin

Result := (GetWindowLong(wnd, GWL_EXSTYLE) and WS_EX_TOPMOST) 0;

end;

procedure logWindowInfo(wnd: HWND);

const

visString: array[Boolean] of string = (‘not ‘, »);

var

buffer: array[0..256] of Char;

r: TRect;

begin

if wnd = 0 then Exit;

GetClassName(wnd, buffer, SizeOf(buffer));

with Memo1.Lines do

begin

Add(Format(‘ Window of class %s ‘, [buffer]));

GetWindowRect(wnd, r);

Add(Format(‘ at (%d,%d):(%d,%d)’, [r.Left, r.Top, r.Right, r.Bottom]));

Add(Format(‘ Window is %svisible’, [visString[IsWindowVisible(wnd)]]));

Add(Format(‘ Window is %stopmost’, [visString[IsTopmost(wnd)]]));

end;

end;

begin

Memo1.Clear;

wnd := Handle;

repeat

wnd := GetNextWindow(wnd, GW_HWNDPREV);

LogWindowInfo(wnd);

until wnd = 0;

Memo1.Lines.Add(‘End log.’);

end;

{/codecitation}

Добавить комментарий