IApplicationDesignModeSettings2 介面 (shobjidl_core.h)

可讓開發工具應用程式動態控制系統和用戶狀態,例如原生顯示器解析度、裝置縮放比例和應用程式檢視配置,報告給 Windows 市集應用程式,以便測試以設計模式執行的各種尺寸規格的 Windows 市集應用程式,而不需要實際硬體。 也可讓您在一般使用者控制的狀態下測試變更,以在各種情況下測試 Windows 市集應用程式。

繼承

IApplicationDesignModeSettings2 介面繼承自 IApplicationDesignModeSettingsIApplicationDesignModeSettings2 也有下列類型的成員:

方法

IApplicationDesignModeSettings2 介面具有這些方法。

 
IApplicationDesignModeSettings2::GetApplicationSizeBounds

此方法會擷取應用程式所支援的大小界限。
IApplicationDesignModeSettings2::GetApplicationViewOrientation

取得應用程式設計模式視窗的方向。
IApplicationDesignModeSettings2::SetAdjacentDisplayEdges

設定應用程式視窗是否與模擬顯示邊緣相鄰。
IApplicationDesignModeSettings2::SetApplicationViewMinWidth

設定應用程式設計模式視窗所需的最小寬度。
IApplicationDesignModeSettings2::SetApplicationViewOrientation

設定用於設計模式視窗的視窗方向。
IApplicationDesignModeSettings2::SetIsOnLockScreen

這個方法會決定應用程式在設計模式中是否可以在 Windows 8 鎖定畫面上顯示資訊。
IApplicationDesignModeSettings2::SetNativeDisplayOrientation

設定設計模式視窗模擬顯示的方向。

備註

藉由共同建立CLSID_ApplicationDesignModeSettings來取得此介面。 它是原始 IApplicationDesignModeSettings 介面的延伸模組。

範例

在此範例中,Visual Studio 會以設計模式啟動應用程式,在大小為 1366x768 的顯示器上覆寫最小寬度。 接著,它會啟用滑桿控件,讓使用者動態變更應用程式寬度。 若要這樣做,它必須使用新的 SetApplicationViewMinWidthGetApplicationSizeBounds API 來計算此類型應用程式允許的最小和最大大小。

如需 IInitializeWithWindow::Initialize 的詳細資訊,請參閱 顯示相依於 CoreWindow 的 WinRT UI 物件

ComPtr<IApplicationDesignModeSettings> spDesignModeSettings;

// CoCreate the design mode settings object
HRESULT hr = CoCreateInstance(CLSID_ApplicationDesignModeSettings, nullptr, CLSCTX_INPROC, IID_PPV_ARGS(&spDesignModeSettings));
if (SUCCEEDED(hr))
{
    ComPtr<IInitializeWithWindow> spInitializeWithWindow;
    hr = pDesignModeSettings->QueryInterface(IID_PPV_ARGS(&spInitializeWithWindow);
    if (SUCCEEDED(hr))
    {
        // Before we set any design mode state, we must first initialize the
        // design mode settings object with a proxy core window. Since apps
        // running in design mode don't have an actual core window, we must
        // supply an HWND that can be used as a proxy.
        hr = spInitializeWithWindow->Initialize(hwndProxyCoreWindow);
    }

    if (SUCCEEDED(hr))
    {
        // Set the native display size to 1366x768
        SIZE sizeDisplay = {1366, 768};
        hr = spDesignModeSettings->SetNativeDisplaySize(sizeDisplay);
        if (SUCCEEDED(hr))
        {
            // Set the native display orientation to landscape
            hr = spDesignModeSettings->SetNativeDisplayOrientation(NDO_LANDSCAPE);
            if (SUCCEEDED(hr))
            {
                // Set the scale factor to 100%
                DEVICE_SCALE_FACTOR scaleFactor = SCALE_100_PERCENT;
                hr = spDesignModeSettings->SetScaleFactor(scaleFactor);
            }
        }
    }

    if (SUCCEEDED(hr))
    {

        // Override the app’s minimum width
        hr = spDesignModeSettings->SetApplicationViewMinWidth(AVMW_320);
        if (SUCCEEDED(hr))
        {
            SIZE sizeAppMin;
            SIZE sizeAppMax;
            hr = spDesignModeSettings->GetApplicationSizeBounds(&sizeAppMin, &sizeAppMax);
            if (SUCCEEDED(hr))
            {
                // Push the min and max size to the slider control,
                // to update the values that it maps to
                …

                // Start by sizing the app to its min bound, so compute the                         
                // resulting view orientation
                APPLICATION_VIEW_ORIENTATION viewOrientation;
                hr = spDesignModeSettings->GetApplicationViewOrientation(sizeAppMin, &viewOrientation);
                if (SUCCEEDED(hr))
                {
                    // Set the app view orientation
                    hr = spDesignModeSettings->SetApplicationViewOrientation(viewOrientation);
                }
            }
        }
    }

    if (SUCCEEDED(hr))
    {
        // Set the adjacent display edges so that the app is touching just the left edge of the screen
        hr = spDesignModeSettings->SetAdjacentDisplayEdges(ADE_LEFT);
    }
}

規格需求

需求
最低支援的用戶端 Windows 8.1 [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2012 R2 [僅限傳統型應用程式]
目標平台 Windows
標頭 shobjidl_core.h (包含 Shobjidl.h)

另請參閱

IApplicationDesignModeSettings