1 Attachment(s)
Finding Overlapped windows areas
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]
A little bit more details
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.
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"
}
Enjoy!