![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Окно на поверхности
demon © (2009-01-11 04:14:00)Как узнать не прикрыто ли моё окно сверху другими окноми?
demon (2009-01-11 17:42:00) [1]Rouse_, спасибо!
palva (2009-01-11 12:57:00) [2]Если в окне что-то есть (главное меню, кнопка...) то оно всегда прикрыто другими окнами - окнами, которые отрисовывают эту кнопку и т. д.
Rouse_ (2009-01-11 10:23:00) [3]Как-то так:
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm6 = class(TForm)
Memo1: TMemo;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
end;
var
Form6: TForm6;
implementation
{$R *.dfm}
procedure TForm6.Timer1Timer(Sender: TObject);
var
CurrentRect, OtherRect, IntersectedRect: TRect;
WndHandle, ForegrowndHandle: THandle;
OtherWindoCaption: String;
CaptionLength: Integer;
begin
if not Visible then
Exit
else
GetWindowRect(Handle, CurrentRect);
ForegrowndHandle := GetForegroundWindow;
if ForegrowndHandle <> Handle then
begin
WndHandle := GetNextWindow(Handle, GW_HWNDPREV);
repeat
if not IsWindowVisible(WndHandle) then
begin
WndHandle := GetNextWindow(WndHandle, GW_HWNDPREV);
Continue;
end;
GetWindowRect(WndHandle, OtherRect);
if IntersectRect(IntersectedRect, CurrentRect, OtherRect) then
begin
Memo1.Lines.Add('Найдено окно, расположенное поверх контрольного:');
Memo1.Lines.Add('Хэндл окна: ' + IntToStr(WndHandle));
CaptionLength := SendMessage(WndHandle, WM_GETTEXTLENGTH, 0, 0);
if CaptionLength > 0 then
begin
Inc(CaptionLength);
SetLength(OtherWindoCaption, CaptionLength);
SendMessage(WndHandle, WM_GETTEXT, CaptionLength, Integer(@OtherWindoCaption[1]));
Memo1.Lines.Add('Заголовок окна: ' + OtherWindoCaption);
end;
end;
WndHandle := GetNextWindow(WndHandle, GW_HWNDPREV);
until WndHandle = 0;
end;
end;
end.