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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find window handle of another application

Status
Not open for further replies.

gtirmizi

Programmer
Oct 9, 2002
6
US
Hi,

I am using MS VC++ 6.0 and win32 APIs. I have created a process to some other application using Win32 API "CreateProcess" and was able to launch that applicaton. I was able to obatain the handle of the that process window with EnumWindows API. The first window is a logon dialog box and once the OK button is pressed another window is displayed. Since I have the handle to the first window, everything works fine. But now I need to get a window handle of the second window so I could perfom minimize, maximize etc fuctions on it.

Could some one please tell me how I can obtain the handle to the second window. Following is the code I use for my CALLBACK function for EnumWindows:

BOOL CALLBACK AppManager::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
AppManager * pAppMgr = (AppManager*) lParam;

// Get the process id of this newly found window
DWORD pid=0;
GetWindowThreadProcessId(hwnd, &pid);

if (pid == pAppMgr->_instanceData.pi.dwProcessId) { // if this id and our id match save the handle

pAppMgr->_instanceData.hwndRootWindow = hwnd;
pAppMgr->_instanceData.launched = true;
return false; // false to stop enumeration since we've found our window
}
return true;
}

I really apprciate the help.

Thanks
GT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top