Вниз
Скачать: CL | DM;

Как получить список всех окон Windows (включая все дочерние)   Найти похожие ветки 

 
Igor5   (2004-03-06 14:48) [0]

Wnd := GetWindow(Handle, gw_HWndFirst);
WHILE Wnd <> 0 DO BEGIN
GetClassName(Wnd,Buff,100);
Memo1.Lines.Add(StrPas(buff));
Wnd := GetWindow(Wnd, gw_hWndNext);
end;
показывает не все.
Спасибо за ответ.


 
Игорь Шевченко ©   (2004-03-06 19:27) [1]

function EnumChildWindowsProc (WindowHandle : HWND; Data : Pointer) : BOOL; stdcall;
var
 WinText : array[0..MAX_PATH] of char;
 WinClassName : array[0..MAX_PATH] of char;
 Node : TTreeNode;
 AImageIndex : Integer;
 AIconHandle : THandle;
 AIcon : TIcon;
begin
 GetWindowText(WindowHandle, WinText, SizeOf(WinText));
 GetClassName(WindowHandle, WinClassName, SizeOf(WinClassName));
 Node := PWindowTreeNode(Data)^.TreeView.Items.AddChildObject(PWindowTreeNode(Data)^.Node,
          Format("%s - %s", [WinClassName, WinText]), Pointer(WindowHandle));
 AIconHandle := HSGetWindowIcon(WindowHandle);
 if AIconHandle <> 0 then begin
   AIcon := TIcon.Create();
   AIcon.Handle := CopyIcon(AIconHandle);
   AImageIndex := fMain.WindowIconsImageList.AddIcon (AIcon);
   if AImageIndex <> -1 then begin
     Node.ImageIndex := AImageIndex;
     Node.SelectedIndex := AImageIndex;
   end;
 end else begin
   Node.ImageIndex := -1;
   Node.SelectedIndex := -1;
 end;
 Result := true;
end;

function EnumWindowsProc (WindowHandle : HWND; Data : Pointer) : BOOL; stdcall;
var
 WinText : array[0..MAX_PATH] of char;
 WinClassName : array[0..MAX_PATH] of char;
 WindowNode : TWindowTreeNode;
 AImageIndex : Integer;
 AIconHandle : THandle;
 AIcon : TIcon;
begin
 GetWindowText(WindowHandle, WinText, SizeOf(WinText));
 GetClassName(WindowHandle, WinClassName, SizeOf(WinClassName));
 WindowNode.TreeView := TTreeView(Data);
 WindowNode.Node := TTreeView(Data).Items.AddObject(nil,
          Format("%s - %s", [WinClassName, WinText]), Pointer(WindowHandle));
 AIconHandle := HSGetWindowIcon(WindowHandle);
 if AIconHandle <> 0 then begin
   AIcon := TIcon.Create();
   AIcon.Handle := CopyIcon(AIconHandle);
   AImageIndex := fMain.WindowIconsImageList.AddIcon (AIcon);
   if AImageIndex <> -1 then begin
     WindowNode.Node.ImageIndex := AImageIndex;
     WindowNode.Node.SelectedIndex := AImageIndex;
   end;
 end else begin
   WindowNode.Node.ImageIndex := -1;
   WindowNode.Node.SelectedIndex := -1;
 end;
 EnumChildWindows(WindowHandle, @EnumChildWindowsProc, LPARAM(@WindowNode));
 Result := true;
end;

procedure TfMain.RefreshWindowsView();
begin
 WindowsTreeView.Items.Clear();
 EnumWindows(@EnumWindowsProc, LPARAM(WindowsTreeView));
end;




Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.021 c
14-1081417892
Карелин Артем
2004-04-08 13:51
2004.05.02
Как отмазаться от армейки. Совет от MS Word.


1-1082205529
Максим
2004-04-17 16:38
2004.05.02
Как сделать Zoom=100% в PrintPriview?


1-1081499286
fatal
2004-04-09 12:28
2004.05.02
Полупрозрачные окна


3-1080925781
Orvat
2004-04-02 21:09
2004.05.02
Понимаю, что не на тот сайт защел, но...


1-1082086926
cvg
2004-04-16 07:42
2004.05.02
Какие есть цвета?




   Наверх