Click to See Complete Forum and Search --> : Finding Overlapped windows areas


gleb49450
March 17th, 2003, 02:53 PM
Hello.
Does anyone know how can i retrieve window area that closed by other window.

Ex:First window is a "Calculator" and second window is "Registry Editor" ,and "Registry Editor" is partialy on top of the calculator.
I need to retrieve the area of the calculator that is currently under the "Registry Editor".
The area that the user is not seeing because the "Registry Editor" is on top of it.
Thank you.

See attached file for better explanation.[B]

Bengi
March 18th, 2003, 02:55 AM
try FindWindow() api

ovidiucucu
March 18th, 2003, 12:51 PM
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.

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"

}

Enjoy!