This is just a sample.
This function returns the screen coordinates of the
Calculator's area covered by Registry Editor.
You can enhance it by passing windows names or/and
classes names, and convert to the client coordinates.
Enjoy!Code:BOOL GetRegistryOverCalculatorRect( RECT &rcOver ) { BOOL bRet = FALSE; ::ZeroMemory( &rcOver, sizeof( RECT ) ); // Search the "Registry Editor" window HWND hWndReg = ::FindWindow( NULL, _T("Registry Editor") ); if( NULL == hWndReg ) { // Registry Editor not found return bRet; } // Now search the Calculator window // begining with the next window in the Z order, // after the Registry Editor HWND hWndCalc = ::FindWindowEx( NULL, hWndReg, NULL, _T("Calculator") ); if( NULL == hWndCalc ) { // "Calculator" not found // or it is not under "Registry Editor" return bRet; } RECT rcCalc, rcReg; ::GetWindowRect( hWndCalc, &rcCalc ); ::GetWindowRect( hWndReg, &rcReg ); bRet = ::IntersectRect( &rcOver, &rcCalc, &rcReg ); return bRet; // returns FALSE if "Registry Editor" // is not over "Calculator" }




Reply With Quote