?
Solved

Help with EnumChildWindows please...

Posted on 2003-03-31
1
Medium Priority
?
187 Views
Last Modified: 2010-04-06
I have a pretty basic win API question...

How do I use EnumChildWindows to find all the windows of a specific type. For example lets say I am trying to find all the IM windows on AOL. All IM windows have 1 thing in common on the title bar they all say ">IM: " how can I filter all these windows? And then now I want to send a message to a specific person say to ">IM: ScreeName" I know this sounds kinda confusing because I dont word things very well
Pretty much I need to...

Enumerate child windows and find all the windows with ">IM: " as their first 4 characters, then with the windows I enumerated I need to send a message to a specific one, like to ">IM: ScreenName" can someone please help me with this? I have a working function but I use FindWindow and GetWindow but this just doesnt seem to work very well. I feel that I will have better results using EnumChildWindows.

Thanks for your help.

Best Regards,
Steve
0
Comment
Question by:PoeticAudio
1 Comment
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 8243568
an older sample, a bit adjusted to your needs

unit enumw_u;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Edit1: TEdit;
    Button1: TButton;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
var WName : Array[0..99] of Char;

//Search Childs
Function TWCallBackChild(H : THandle; V : Longint) : longBool; stdcall;
var s : String;
begin
 GetwindowText(H,@WName[0],100);
 s := StrPas(@WName[0]);
 if (copy(s,1,length(Form1.Edit1.Text)) = Form1.Edit1.Text) or //collect specific or
    (Form1.Edit1.Text = '') then                               //collect all
   form1.ListBox1.Items.AddObject(s,ptr(H));
 Result := True;
end;

//search Parents
Function TWCallBack(H : THandle; V : Longint) : longBool; stdcall;
var s : String;
begin
 GetwindowText(H,@WName[0],100);
 s := StrPas(@WName[0]);
 if (copy(s,1,length(Form1.Edit1.Text)) = Form1.Edit1.Text) or //collect specific or
    (Form1.Edit1.Text = '') then                               //collect all
   form1.ListBox1.Items.AddObject(s,ptr(H));
 EnumChildWindows(H,@TWCallBackChild,V);
 Result := True;
end;


procedure TForm1.Button1Click(Sender: TObject);
var Dummy : Longint;
begin
 EnumWindows(@TWCallBack,Dummy);  //Search through the windows
end;

//output the handle
procedure TForm1.ListBox1Click(Sender: TObject);
begin
  edit2.Text := IntToStr(integer(ListBox1.Items.Objects[ListBox1.ItemIndex]));
  //show the windows, just as sample, may not allways applied to child-objects
  ShowWindow(integer(ListBox1.Items.Objects[ListBox1.ItemIndex]),SW_SHOW);
end;

end.

meikl ;-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question