次の方法で共有


MagSetFullscreenTransform 関数 (拡大.h)

全画面表示拡大鏡の倍率設定を変更します。

構文

BOOL MagSetFullscreenTransform(
  [in] float magLevel,
  [in] int   xOffset,
  [in] int   yOffset
);

パラメーター

[in] magLevel

型: float

全画面表示拡大鏡の新しい倍率。 このパラメーターの最小値は 1.0 で、最大値は 4096.0 です。 この値が 1.0 の場合、画面の内容は拡大されず、オフセットは適用されません。

[in] xOffset

型: int

拡大表示の左上隅の新しい x 座標オフセット (ピクセル単位)。 オフセットは、プライマリ モニターの左上隅を基準にして、未イメージの座標で表されます。 パラメーターの最小値は -262144 で、最大値は262144。

[in] yOffset

型: int

拡大表示の左上隅の新しい y 座標オフセット (ピクセル単位)。 オフセットは、プライマリ モニターの左上隅を基準にして、未イメージの座標で表されます。 パラメーターの最小値は -262144 で、最大値は262144。

戻り値

種類: BOOL

成功した場合は TRUE を返します。 それ以外の場合は FALSE。

解説

オフセットは、現在のドット/インチ (dpi) の設定の影響を受けません。

拡大率は、[簡単操作] コントロール パネルのマウス関連の設定の影響を受けるカーソル ビジュアルを含め、現在のマウス カーソル ビジュアルに適用されます。

マルチ モニター環境では、拡大ビューの左上隅をプライマリ モニターの左側に配置するには、仮想画面の左上隅と適用される倍率によってオフセットを調整する必要があります。 (仮想画面は、すべてのディスプレイ モニターの外接する四角形です)。拡大表示の左上隅をプライマリ モニターの左側に配置する方法を示す例については、「 」を参照してください。

Windows 10 Creators Update (バージョン 1703) 以降では、拡大された要素にルーティングする入力に MagSetInputTransform 関数を使用する必要があります。

次の使用例は、全画面表示拡大鏡の倍率を設定し、拡大画面のコンテンツの中心を画面の中央に配置します。

BOOL SetZoom(float magnificationFactor)
{
    // A magnification factor less than 1.0 is not valid.
    if (magnificationFactor < 1.0)
    {
        return FALSE;
    }

    // Calculate offsets such that the center of the magnified screen content 
    // is at the center of the screen. The offsets are relative to the 
    // unmagnified screen content.
    int xDlg = (int)((float)GetSystemMetrics(
            SM_CXSCREEN) * (1.0 - (1.0 / magnificationFactor)) / 2.0);
    int yDlg = (int)((float)GetSystemMetrics(
            SM_CYSCREEN) * (1.0 - (1.0 / magnificationFactor)) / 2.0);

    return MagSetFullscreenTransform(magnificationFactor, xDlg, yDlg);
}

次の使用例は、拡大表示の左上隅に特定のウィンドウの左上隅が表示されるように画面を拡大します。 パラメーターが fPositionRelativeToVirtualScreen FALSE の場合、ウィンドウはプライマリ モニターの左上隅に配置されます。 が TRUE で、システムに複数のモニターがある場合 fPositionRelativeToVirtualScreen 、この例では、仮想画面を基準にしてウィンドウを配置するようにオフセットを調整します。つまり、ウィンドウは左端のモニターの左上隅に配置されます。

// Note: This example does not check whether the offset is large enough to 
// ensure that the magnified content fills the entire screen. Depending on the 
// location of the target window, some unmagnified content might be visible to 
// the right of the magnified content.

// Description:
//   Magnifies the screen such that the upper-left corner of a particular window 
//   appears at the upper-left corner of the magnified view.
//
// Parameters:
//   fPositionRelativeToVirtualDesktop - TRUE to set the magnified view relative
//   to the upper-left corner of the virtual screen, or FALSE to set the 
//   magnified view relative to the upper-left corner of the primary monitor.
//
BOOL SetFullscreenMagnification(BOOL fPositionRelativeToVirtualScreen)
{
    BOOL fResult = FALSE;

    // Get the window whose upper-left corner is to appear at the upper-left 
    // corner of the magnified view.
    HWND hWndTarget = FindWindow(L"TargetAppClass", NULL);
    if (hWndTarget != NULL)
    {
        RECT rcTarget;
        GetWindowRect(hWndTarget, &rcTarget);

        // Set the magnification to be 200%.
        float magVal = 2.0;

        // Position the point of interest to appear at the upper-left corner 
        // of the primary monitor.
        int xOffset = rcTarget.left;
        int yOffset = rcTarget.top;

        if (fPositionRelativeToVirtualScreen)
        {
            // Adjust the point of interest to appear at the upper-left corner of 
            // the virtual screen; that is, the left-most monitor.

            RECT rcVirtualScreen;
    
            rcVirtualScreen.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
            rcVirtualScreen.top  = GetSystemMetrics(SM_YVIRTUALSCREEN);

            xOffset -= (int)(rcVirtualScreen.left / magVal);
            yOffset -= (int)(rcVirtualScreen.top  / magVal);
        }

        fResult = MagSetFullscreenTransform(magVal, xOffset, yOffset);
    }

    return fResult;
}

要件

要件
サポートされている最小のクライアント Windows 8 [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows Server 2012 [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー magnification.h
Library Magnification.lib
[DLL] Magnification.dll

こちらもご覧ください

MagGetFullscreenTransform