CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #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