Help with EnumChildWindows please...

Posted on 2003-03-31
Medium Priority
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,
Question by:PoeticAudio
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 27

Accepted Solution

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

unit enumw_u;


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

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

  Form1: TForm1;


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

//Search Childs
Function TWCallBackChild(H : THandle; V : Longint) : longBool; stdcall;
var s : String;
 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
 Result := True;

//search Parents
Function TWCallBack(H : THandle; V : Longint) : longBool; stdcall;
var s : String;
 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
 Result := True;

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

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


meikl ;-)

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 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