🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1801

Re: EnumWindows etc.

#1801
From: Ed Mulroy
Date: Sun, 10 Jun 2007 00:22
59 lines
3182 bytes
I do not know why you need the process id or class name for the window.

I think you are on the right track in using EnumWindows to find the windows 
and writing the captions to the listbox for the user to see.  You would then 
also need to keep an internal list of HWND and window caption.  You can save 
those two items into a structure that you define and use one of a vector 
(best) or a TList (not best) for the list.

When the user double clicks on a caption in the list box you can then go 
through your internal list and find the associated window handle, the HWND. 
You can then test its state with IsIconic and IsZoomed and decide what to do 
with it.

.  Ed

> Matthew wrote in message
> news:466aefff$1@newsgroups.borland.com...
>
>>The call to GetWindowThreadProcessIId with a valid window handle
>>will always return the process ID so need not be tested for NULL.
>
> Ed, if all I wanted were a list of windows (and not procs)
> what would I use/do instead?
>
> I know VERY LITTLE about windows API... I am attempting
> to a create a list of (only) running apps, and then have
> the ability to select any one of those apps, and maximize,
> or minimize it. I don't want to see the procs in my list,
> but this code is the only (the one you refer to) example
> to go on... So should I use something other than enumproc?
>
>
>>  ------------------------
>>  bool __stdcall EnumProc(HWND hWnd, long)
>>  {
>>      unsigned long process_id;
>>      char buffer[128];
>>      const AnsiString tab_str = '\t';
>>      AnsiString total_str;
>>
>>      GetClassName(hWnd, buffer, 95);
>>      total_str = buffer;
>>
>>      GetWindowThreadProcessId(hWnd, &process_id);
>>      ultoa(process_id, buffer, 10);
>>      total_str = total_str + tab_str + buffer;
>>
>>      if (GetWindowText(hWnd, buffer, 110)) {
>>          total_str = total_str + tab_str + buffer;
>>      }
>>
>>      FormMain->ListBox1->Items->Add(total_str);
>>      return true;
>>  }
>>  ------------------------ 
>
> Excellent - I will test this out as soon as I can.
>
> Thank you for the information and point of view.
Technical Details
Message-ID: <466b4b25$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4668d902$1@newsgroups.borland.com> <l2ri63pmm23tsci1u4subhitr6cchmm147@4ax.com> <4669fbaf$1@newsgroups.borland.com> <466aacf2$1@newsgroups.borland.com> <466aefff$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,859e738ad5fa0eae
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ed Mulroy" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4668d902$1@newsgroups.borland.com> <l2ri63pmm23tsci1u4subhitr6cchmm147@4ax.com> <4669fbaf$1@newsgroups.borland.com> <466aacf2$1@newsgroups.borland.com> <466aefff$1@newsgroups.borland.com>
Subject: Re: EnumWindows etc.
Date: Sat, 9 Jun 2007 20:22:07 -0400
Lines: 61
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 69.141.82.147
Message-ID: <466b4b25$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1181436709 69.141.82.147 (9 Jun 2007 17:51:49 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail