Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to know which application is currently active from a different App 1

Status
Not open for further replies.

onlyadghosh

Technical User
Joined
Jun 30, 2003
Messages
2
Location
IN
Hi,
I have an event based 2 tier application. Now when my application is running, if I activate a different application( for ex. win explorer)and starts working in it, my application becomes active after receiving an event from backend. But I do not want my application to be active after receiving an event. It should process the event but should not come up.

Pls help me in this regard, I urgently need to prevent this.

Thanxs in Advance.

 
Hello onlyadghosh,

Well it seems as though the title of your post is different from its content, but I will answer both questions.

>> How to know which application is currently active from a different App

[tt]HWND hwndForeground = GetForegroundWindow();
DWORD dwActivePID;
GetWindowThreadProcessID(hwndForeground,&dwActivePID);[/tt]

>> application becomes active after receiving an event from backend

It is not the default behavior for a window to bring itself to the foreground upon receiving an "event" (still not sure exactly what you mean by "event"). Therefore, if that behavior occurs in your code, it is because you put it in there.

If you are borrowing code from somewhere else, I would double-check all calls to SetForegroundWindow, ShowWindow and SetWindowPos.

I REALLY hope that helps.
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top