本文整理汇总了C#中System.Windows.Interop.HwndSource.AddHook方法的典型用法代码示例。如果您正苦于以下问题:C# HwndSource.AddHook方法的具体用法?C# HwndSource.AddHook怎么用?C# HwndSource.AddHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Interop.HwndSource
的用法示例。
在下文中一共展示了HwndSource.AddHook方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HorizontalMouseScrollHelper
public HorizontalMouseScrollHelper(ScrollViewer scrollviewer, DependencyObject d)
{
scrollViewer = scrollviewer;
source = (HwndSource)PresentationSource.FromDependencyObject(d);
if (source != null)
source.AddHook(WindowProc);
}
示例2: StartListeningToClipboard
private void StartListeningToClipboard()
{
var lWindowInteropHelper = new WindowInteropHelper(this);
_HWndSource = HwndSource.FromHwnd(lWindowInteropHelper.Handle);
_HWndSource.AddHook(WinProc);
_HWndNextViewer = SetClipboardViewer(_HWndSource.Handle); // set this window as a viewer
} //
示例3: Start
private void Start()
{
if (hwndSource != null)
return;
var window = Application.Current.Windows[0];
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() =>
{
if (!window.IsInitialized)
window.SourceInitialized += (sender, args) =>
{
hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(window).Handle);
hwndSource.AddHook(WndProc);
};
else
{
hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(window).Handle);
hwndSource.AddHook(WndProc);
}
}));
}
示例4: OnLoaded
protected void OnLoaded(object sender, EventArgs e)
{
WindowInteropHelper helper = new WindowInteropHelper(this);
_hwndSource = HwndSource.FromHwnd(helper.Handle);
_wndProcHandler = new HwndSourceHook(HookHandler);
_hwndSource.AddHook(_wndProcHandler);
}
示例5: HotKeyManager
/// <summary>
/// Initializes a new instance of the <see cref="HotKeyManager"/> class.
/// </summary>
public HotKeyManager()
{
_windowHandleSource = new HwndSource(new HwndSourceParameters());
_windowHandleSource.AddHook(messagesHandler);
_registered = new Dictionary<HotKey, int>();
}
示例6: ShadowedWindow_OnLoaded
private void ShadowedWindow_OnLoaded(object sender, RoutedEventArgs e)
{
hwndSource = PresentationSource.FromVisual((Visual) sender) as HwndSource;
if (hwndSource != null)
hwndSource.AddHook(WndProc);
}
示例7: HotkeyManager
public HotkeyManager(Window window)
{
source = (HwndSource)PresentationSource.FromVisual(window);
hook = new HwndSourceHook(WndProc);
source.AddHook(hook);
ids = new List<int>();
}
示例8: InitCBViewer
private void InitCBViewer()
{
WindowInteropHelper wih = new WindowInteropHelper(this);
hWndSource = HwndSource.FromHwnd(wih.Handle);
hWndSource.AddHook(this.WndProc); // start processing window messages
hWndNextViewer = Win32.SetClipboardViewer(hWndSource.Handle); // set this window as a viewer
}
示例9: OnSourceInitialized
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
var helper = new WindowInteropHelper(this);
_source = HwndSource.FromHwnd(helper.Handle);
_source.AddHook(HwndHook);
RegisterHotKey();
}
示例10: AddHook
private void AddHook(Visual window)
{
if (_hwndSource != null) return;
_hwndSource = PresentationSource.FromVisual(window) as HwndSource;
if (_hwndSource != null)
{
_hwndSource.AddHook(HwndSourceHook);
}
}
示例11: OnSourceInitialized
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
hWndSrc = PresentationSource.FromVisual(this) as HwndSource;
DataContext = mainViewModel = new MainViewModel(this.Dispatcher, hWndSrc.Handle);
hWndSrc.AddHook(mainViewModel.ApiInstance.WndProc);
mainViewModel.ConnectToHost();
}
示例12: HotKey
public HotKey(HwndSource hwndSource)
{
hook = WndProc;
this.hwndSource = hwndSource;
hwndSource.AddHook(hook);
var rand = new Random((int)DateTime.Now.Ticks);
id = rand.Next();
}
示例13: WindowResizer
public WindowResizer(Window window)
{
activeWin = window as Window;
activeWin.SourceInitialized += (sender, e) =>
{
hwndSource = PresentationSource.FromVisual(sender as Visual) as HwndSource;
hwndSource.AddHook(new HwndSourceHook(WndProc));
};
}
示例14: Setup
/// <summary>
/// Setup wndproc handling so we can receive window messages (Win32 stuff)
/// </summary>
/// <exception cref="Exception">Failed to acquire window handle</exception>
public void Setup(Window window)
{
var windowHelper = new WindowInteropHelper(window);
windowHelper.EnsureHandle();
_hwndSource = HwndSource.FromHwnd(windowHelper.Handle);
if (_hwndSource == null) {
throw new Exception("Failed to acquire window handle");
}
_hwndSource.AddHook(HandleMessages);
}
示例15: OnSourceInitialized
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
_windowHandle = new WindowInteropHelper(this).Handle;
_source = HwndSource.FromHwnd(_windowHandle);
_source.AddHook(HwndHook);
RegisterHotKey(_windowHandle, HOTKEY_ID, MOD_CONTROL, VK_SPACE); //CTRL + SPACE
}