Показать сообщение отдельно
  #1  
Старый 08.05.2016, 16:15
nixon232 nixon232 вне форума
Активный
 
Регистрация: 26.01.2014
Сообщения: 282
Версия Delphi: delphi xe4
Репутация: выкл
По умолчанию EmumWindows В потоке?

Снова я и снова вопрос. Есть поток, который ищет окна класса Х и если их находит, то пишет Rect, hwnd, и кол-во этих окон:
Код:
 function EnumWindowsProc(h: HWND; lParam: LPARAM): Boolean; stdcall;
var
  CN: array [0..1023] of Char;
  I: Integer;
  WndRect :TRect;
begin

  Result := True;
  i:=1;

  GetClassName(h, @CN, 1024);
if CN='х' then
begin
MyRec.table[i].HWND:=h;
GetWindowRect(h, WndRect)     ;
MyRaec.table[i].HRect:= WndRect;
myrec.max:=i;
 inc (i);
end else 


Структура Myrec
Код:
      type

  Myrec= record
  HWND: HWND;
  HRect: TRect;
  end;
  type
  PMyrec= record
  table : array [1..12] of Myrec;
  max: Integer;
  end;
Поток
Код:
  type
   TWaitTable = class(TThread)
  private
  x:Integer;
  y:Integer;
  tab: MyRec;
  pab:Pmyrec;
  className:string;
  fibish:Boolean;
    { Private declarations }
  protected
    procedure Execute; override;
    procedure finished;
    procedure ishud;
  end;
Вызов:
Код:
procedure TWaitTable.Execute;
  var
  i: Integer;
  begin
  while not Terminated do
  begin
    Myrec.max:=0;
      EnumWindows (@EnumWindowsProc,0);
      if Myrec.max>0 then
      begin
      pab:=myrec;
        for i := 1 to pab.max do
          begin
          tab:=pab.table[i];
      ;     Synchronize(ishud);


          end;
      end;
  end;
  end;
procedure TWaitTable.ishud;
  var
  tobLeft: TPoint;
  aName: array [0..255] of Char;
  shud,shud2: string;
  hw: HWND;
  begin
   tobLeft.x:=Tab.HRect.left;
   tobLeft.Y:=tab.HRect.Top;
   tobLeft:=tobLeft+ ROP;
В итоге HRect не равен ректу окна. в чем напутал?
Ответить с цитированием