本文整理汇总了C#中System.Windows.Interop.HwndSource.?.AddHook方法的典型用法代码示例。如果您正苦于以下问题:C# HwndSource.?.AddHook方法的具体用法?C# HwndSource.?.AddHook怎么用?C# HwndSource.?.AddHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Interop.HwndSource
的用法示例。
在下文中一共展示了HwndSource.?.AddHook方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSourceInitialized
protected override void OnSourceInitialized(EventArgs e)
{
_hwndSource = (HwndSource) PresentationSource.FromVisual(this);
_hwndSource?.AddHook(WndProcHook);
UpdateWindowStyle();
base.OnSourceInitialized(e);
}
示例2: OnSourceInitialized
private void OnSourceInitialized(object sender, EventArgs e)
{
_source = (HwndSource)PresentationSource.FromVisual(this);
// calculate the DPI used by WPF; this is the same as the system DPI
if (_source?.CompositionTarget != null)
{
var matrix = _source.CompositionTarget.TransformToDevice;
DpiInformation = new DpiInformation(96D * matrix.M11, 96D * matrix.M22);
}
if (!_isPerMonitorDpiAware) return;
_source?.AddHook(WndProc);
RefreshMonitorDpi();
}
示例3: AddHook
private void AddHook(Visual window)
{
if (_hwndSource != null) return;
_hwndSource = PresentationSource.FromVisual(window) as HwndSource;
_hwndSource?.AddHook(HwndSourceHook);
}
示例4: OnLoaded
private void OnLoaded(object sender, RoutedEventArgs e)
{
Loaded -= OnLoaded;
OnThemeChanged(null, null);
this.SetParentToMainWindowOf(Model.Root.Manager);
_hwndSrc = PresentationSource.FromDependencyObject(this) as HwndSource;
_hwndSrcHook = FilterMessage;
_hwndSrc?.AddHook(_hwndSrcHook);
}
示例5: OnSourceInitialized
//--------------------------------------------------------------
/// <summary>
/// Raises the <see cref="Window.SourceInitialized"/> event.
/// </summary>
/// <param name="e">An <see cref="EventArgs"/> that contains the event data.</param>
protected override void OnSourceInitialized(EventArgs e)
{
// Add hook to intercept window messages.
_hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
_hwndSource?.AddHook(WindowMessageHandler);
base.OnSourceInitialized(e);
}