CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2001
    Location
    Israel
    Posts
    11

    Red face 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]
    Attached Images Attached Images

  2. #2
    Join Date
    May 2002
    Location
    Somewhere over the rainbow
    Posts
    423
    try FindWindow() api
    Bengi

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Wink 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!
    Last edited by ovidiucucu; August 10th, 2007 at 01:33 PM. Reason: added [CODE] tags
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured