本文整理汇总了C#中System.Windows.Thickness.ToDwmMargins方法的典型用法代码示例。如果您正苦于以下问题:C# Thickness.ToDwmMargins方法的具体用法?C# Thickness.ToDwmMargins怎么用?C# Thickness.ToDwmMargins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Thickness
的用法示例。
在下文中一共展示了Thickness.ToDwmMargins方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtendFrameIntoClientArea
/// <summary>
/// Extends the frame into client area.
/// </summary>
/// <param name="window">The window.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="exceptionOnFail">if set to <c>true</c> [exception on fail].</param>
public static void ExtendFrameIntoClientArea(Window window, Thickness thickness, bool exceptionOnFail)
{
if (window == null)
{
throw new ArgumentNullResourceException("window", Resources.General_Given_Parameter_Cannot_Be_Null);
}
bool compEnabled = IsCompositionEnabled();
if (exceptionOnFail && !compEnabled)
{
throw new DesktopWindowManagerNotEnabledException();
}
if (exceptionOnFail && !window.IsLoaded)
{
throw new WindowNotLoadedException();
}
if (!compEnabled)
{
return;
}
var margins = thickness.ToDwmMargins();
IntPtr windowPointer = new WindowInteropHelper(window).Handle;
// convert the background to nondrawing
HwndSource mainWindowHwnd = HwndSource.FromHwnd(windowPointer);
if (mainWindowHwnd != null && mainWindowHwnd.CompositionTarget != null)
{
mainWindowHwnd.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
}
try
{
NativeMethods.DwmExtendFrameIntoClientArea(windowPointer, ref margins);
} catch (DllNotFoundException)
{
window.Background = Brushes.White;
}
}