MagSetWindowSource function

Sets the source rectangle for the magnification window.

Syntax


BOOL WINAPI MagSetWindowSource(
  _In_  HWND hwnd,
  _In_  RECT rect
);

Parameters

hwnd [in]

Type: HWND

The magnification window.

rect [in]

Type: RECT

The rectangle to be magnified, in desktop coordinates.

Return value

Type: BOOL

Returns TRUE if successful, or FALSE otherwise.

Examples

The following example function calculates the position and dimensions of the source rectangle (based on the mouse position and the dimensions of the magnifier window divided by the magnification factor) and sets the source rectangle accordingly. This function would be called at intervals to update the magnification window.


// Description:
//   Sets the source rectangle for a magnifier control to a rectangle centered
//   at the mouse cursor. 
// Parameters:
//   hwndMag - Handle of the magnifier control.
// Constants:
//   LENS_WIDTH - Width of the magnifier window.
//   LENS_HEIGHT - Height of the magnifier window.
//   MAGFACTOR - The magnification factor.
//
BOOL SetMagnifierSourceRect(HWND hwndMag)
{
    // Get the mouse coordinates.
    POINT mousePoint;
    GetCursorPos(&mousePoint);

    // Calculate a source rectangle that is centered at the mouse coordinates. 
    // Size the rectangle so that it fits into the magnifier window (the lens).
    RECT sourceRect;
    sourceRect.left = (mousePoint.x - (int)((LENS_WIDTH / 2) / MAGFACTOR));
    sourceRect.top = (mousePoint.y - (int)((LENS_HEIGHT / 2) / MAGFACTOR));
    sourceRect.right = LENS_WIDTH;
    sourceRect.bottom = LENS_HEIGHT;

    // Pass the source rectangle to the magnifier control.
    BOOL ret = MagSetWindowSource(hwndMag, sourceRect);

    // Force the magnifier control to redraw itself.
    InvalidateRect(hwndMag, NULL, TRUE);

    return ret;
}


Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Magnification.h

Library

Magnification.lib

DLL

Magnification.dll

See also

MagGetWindowSource

 

 

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.