Article View: borland.public.cppbuilder.nativeapi
Article #1934Re: EnumWindows etc.
From: Bob Gonder
Date: Fri, 08 Jun 2007 15:10
Date: Fri, 08 Jun 2007 15:10
47 lines
2334 bytes
2334 bytes
Matthew wrote:
>have used Enum to get a list of available windows (and procs).
>I just want the apps running in the list, but I don't know how
>to differentiate.
How to differentiate what?
You will only get windows.
Are you asking how to know the name of the app that the windows
belongs to?
>The example that came with BCB6:
>if(hWnd==NULL)
> return false;
>
> hg = GlobalAlloc(GMEM_SHARE,sizeof(unsigned long));
> pPid = (unsigned long *)GlobalLock(hg);
>
> result = GetWindowThreadProcessId(hWnd,pPid);
More straight-forward way:
DWORD Pid;
GetWindowThreadProcessId(hWnd, &Pid);
But I don't think I would bother with that, and go for
char title[1024];
GetWindowText( hWnd, title, 1023 );
Add the hWnd and text to a list (pointer to list passed in lparam)
After the Enum, display and select from the list, use the associated
hWnd to SetForegroundWindow( );
>Once I have the list, I need to be able to select an app, and
>bring it to focus... so if it is minimized to the task bar, how
>do I select (code) within my program to maximize it?
if( IsIconic( hWnd ) )
{ ShowWindow( hWnd, SW_RESTORE );
}else{
SetForegroundWindow( hWnd );
};
>Thanks for any help. And if you can tell me how to weed out the
>processes and just display the programs on the task bar, that
>would also be a great help.
There should be no naked processes if you are using EnumWindows
Technical Details
Message-ID:
<l2ri63pmm23tsci1u4subhitr6cchmm147@4ax.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-mailReferences:
<4668d902$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: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: EnumWindows etc. Date: Fri, 08 Jun 2007 08:10:41 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <l2ri63pmm23tsci1u4subhitr6cchmm147@4ax.com> References: <4668d902$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.69.84.157 X-Trace: newsgroups.borland.com 1181315440 69.69.84.157 (8 Jun 2007 08:10:40 -0700) Lines: 49 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