🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: which app is curently having focus

#3947
From: Ed Mulroy
Date: Thu, 06 Apr 2006 16:06
26 lines
1887 bytes
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: <44353c9a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <443537a4$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: "Ed Mulroy" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <443537a4$1@newsgroups.borland.com>
Subject: Re: which app is curently having focus
Date: Thu, 6 Apr 2006 12:06:51 -0400
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 66.57.117.102
Message-ID: <44353c9a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1144339610 66.57.117.102 (6 Apr 2006 09:06:50 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail