 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Tom Guest
|
Posted: Thu Apr 06, 2006 5:03 pm Post subject: which app is curently having focus |
|
|
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
|
Posted: Thu Apr 06, 2006 5:03 pm Post subject: Re: which app is curently having focus |
|
|
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
|
Posted: Fri Apr 07, 2006 12:03 pm Post subject: Re: which app is curently having focus |
|
|
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 |
|
 |
|
|
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
|
|