本文整理汇总了C#中System.Windows.Window.VerifyAccess方法的典型用法代码示例。如果您正苦于以下问题:C# Window.VerifyAccess方法的具体用法?C# Window.VerifyAccess怎么用?C# Window.VerifyAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.VerifyAccess方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtendGlassFrame
/// <summary>
/// Extends the glass frame of a window. Only works on operating systems that support composition.
/// </summary>
/// <param name="window">The window to modify.</param>
/// <param name="margin">The margins of the new frame.</param>
/// <returns>Whether the frame was successfully extended.</returns>
/// <remarks>
/// This function adds hooks to the Window to respond to changes to whether composition is enabled.
/// </remarks>
public static bool ExtendGlassFrame(Window window, Thickness margin)
{
Verify.IsNotNull(window, "window");
window.VerifyAccess();
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if (_extendedWindows.ContainsKey(hwnd))
{
// The hook into the HWND's WndProc has the original margin cached.
// Don't want to support dynamically adjusting that unless there's a need.
throw new InvalidOperationException("Multiple calls to this function for the same Window are not supported.");
}
return _ExtendGlassFrameInternal(window, margin);
}
示例2: RegisterHotKey
public static void RegisterHotKey(Window window, Key key, ModifierKeys modifiers, int keyId)
{
window.VerifyAccess();
int winMods = 0;
if ((modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
winMods = winMods | MOD_ALT;
if ((modifiers & ModifierKeys.Control) == ModifierKeys.Control)
winMods = winMods | MOD_CONTROL;
if ((modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
winMods = winMods | MOD_SHIFT;
if ((modifiers & ModifierKeys.Windows) == ModifierKeys.Windows)
winMods = winMods | MOD_WIN;
var helper = new WindowInteropHelper(window);
RegisterHotKey(helper.Handle, keyId, winMods, KeyInterop.VirtualKeyFromKey(key));
}
示例3: SetWindowThemeAttribute
public static bool SetWindowThemeAttribute(Window window, bool showCaption, bool showIcon)
{
Verify.IsNotNull(window, "window");
window.VerifyAccess();
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if (_attributedWindows.ContainsKey(hwnd))
{
// The hook into the HWND's WndProc has the original settings cached.
// Don't want to support dynamically adjusting that unless there's a need.
throw new InvalidOperationException("Multiple calls to this function for the same Window are not supported.");
}
return _SetWindowThemeAttribute(window, showCaption, showIcon);
}
示例4: UnregisterHotKey
public static void UnregisterHotKey(Window window, int keyId)
{
window.VerifyAccess();
var helper = new WindowInteropHelper(window);
UnregisterHotKey(helper.Handle, keyId);
}