🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: which app is curently having focus

#3955
From: Tom
Date: Fri, 07 Apr 2006 11:06
33 lines
1986 bytes
thanks, it works.


"Ed Mulroy" <dont_email_me@bitbuc.ket> wrote in message
news:44353c9a$1@newsgroups.borland.com...
> The window with which the user is currently working can be found with the
> Windows API function GetForegroundWindow.  You might then use the returned
> HWND in a call to GetWindowProcessId.
>
> .  Ed
>
> > Tom wrote in message
> > news:443537a4$1@newsgroups.borland.com...
> >I use the following code to determine the processes that are running, but
> >how can I find out which application has the focus (in which application
> >user is currently working)
> >
> >  ListBox1->Items->Clear();
> >  HANDLE snapshot;
> >  PROCESSENTRY32 processinfo;
> >  processinfo.dwSize = sizeof(processinfo);
> >  snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
> >  if (snapshot == NULL)
> >   return;
> >  bool status = Process32First(snapshot, &processinfo);
> >  while(status)
> >   {
> >   ListBox1->Items->Add(processinfo.szExeFile);
> >   status = Process32Next(snapshot, &processinfo);
> >   }
> >  Form1->Caption = IntToStr(ListBox1->Items->Count);
>
>
Technical Details
Message-ID: <443647c1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!newsfeeder.wxs.nl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <443537a4$1@newsgroups.borland.com> <44353c9a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,17a2084ef11c8c02
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Tom" <tom@net.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <443537a4$1@newsgroups.borland.com> <44353c9a$1@newsgroups.borland.com>
Subject: Re: which app is curently having focus
Date: Fri, 7 Apr 2006 13:06:36 +0200
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
NNTP-Posting-Host: 213.202.126.18
Message-ID: <443647c1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1144408001 213.202.126.18 (7 Apr 2006 04:06:41 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!newsfeeder.wxs.nl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail