BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

which app is curently having focus

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Tom
Guest





PostPosted: Thu Apr 06, 2006 5:03 pm    Post subject: which app is curently having focus Reply with quote



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);

thanks in advance
tom
Back to top
Ed Mulroy
Guest





PostPosted: Thu Apr 06, 2006 5:03 pm    Post subject: Re: which app is curently having focus Reply with quote



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

Quote:
Tom wrote in message
news:443537a4$1 (AT) newsgroups (DOT) 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);
Back to top
Tom
Guest





PostPosted: Fri Apr 07, 2006 12:03 pm    Post subject: Re: which app is curently having focus Reply with quote



thanks, it works.


"Ed Mulroy" <dont_email_me (AT) bitbuc (DOT) ket> wrote in message
news:44353c9a$1 (AT) newsgroups (DOT) borland.com...
Quote:
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 (AT) newsgroups (DOT) 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);

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.