コード例 #1
0
        /// <summary>
        /// Returns the coordinates of the edges of a specific window in terms of
        /// X from the left and Y from the top of the window.
        /// </summary>
        /// <param name="windowHandle">Handle to the window of which the client area rectangle should be obtained.</param>
        /// <returns></returns>
        public static Structures.WinapiRectangle GetClientAreaSize(IntPtr windowHandle)
        {
            // Obtains the size of the client area.
            WindowFunctions.GetClientRect(windowHandle, out Structures.WinapiRectangle clientAreaRectangle);

            // Return
            return(clientAreaRectangle);
        }
コード例 #2
0
        /// <summary>
        /// Returns the coordinates of the edges of the client area of a specific window
        /// relative to the desktop the window is presented on.
        /// </summary>
        /// <param name="windowHandle">Handle to the window of which the client area rectangle should be obtained.</param>
        /// <returns></returns>
        public static Structures.WinapiRectangle GetClientRectangle(IntPtr windowHandle)
        {
            // Obtains the coordinates of the edges of the window.
            WindowFunctions.GetClientRect(windowHandle, out Structures.WinapiRectangle clientAreaRectangle);

            // Get the coordinates of the top left point on the screen in client's area.
            Structures.WinapiPoint topLeftClientCoordinate = new Structures.WinapiPoint();
            WindowFunctions.ClientToScreen(windowHandle, ref topLeftClientCoordinate);

            // Calculate each edge.
            Structures.WinapiRectangle clientArea = new Structures.WinapiRectangle();
            clientArea.LeftBorder = topLeftClientCoordinate.x;
            clientArea.TopBorder  = topLeftClientCoordinate.y;

            clientArea.RightBorder  = topLeftClientCoordinate.x + clientAreaRectangle.RightBorder;
            clientArea.BottomBorder = topLeftClientCoordinate.y + clientAreaRectangle.BottomBorder;

            // Return
            return(clientArea);
        }