当前位置: 首页>>代码示例>>C#>>正文


C# HwndSource.AddHook方法代码示例

本文整理汇总了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);
 }
开发者ID:jayhill,项目名称:FluentFilters,代码行数:7,代码来源:HorizontalMouseScrollHelper.cs

示例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
 } //
开发者ID:huoxudong125,项目名称:HQF.Tutorial.WPF,代码行数:7,代码来源:MainWindow.xaml.cs

示例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);
				}
			}));



		}
开发者ID:heinzsack,项目名称:DEV,代码行数:26,代码来源:DeviceChangeDetector.cs

示例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);
 }
开发者ID:vebin,项目名称:PhotoBrushProject,代码行数:7,代码来源:FloatingWindow.xaml.cs

示例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>();
        }
开发者ID:kirmir,项目名称:GlobalHotKey,代码行数:10,代码来源:HotKeyManager.cs

示例6: ShadowedWindow_OnLoaded

    private void ShadowedWindow_OnLoaded(object sender, RoutedEventArgs e)
    {
      hwndSource = PresentationSource.FromVisual((Visual) sender) as HwndSource;

      if (hwndSource != null)
        hwndSource.AddHook(WndProc);
    }
开发者ID:maxschmeling,项目名称:flamecage,代码行数:7,代码来源:ShadowedWindow.cs

示例7: HotkeyManager

 public HotkeyManager(Window window)
 {
     source = (HwndSource)PresentationSource.FromVisual(window);
     hook = new HwndSourceHook(WndProc);
     source.AddHook(hook);
     ids = new List<int>();
 }
开发者ID:alexhorn,项目名称:BrightnessControl,代码行数:7,代码来源:HotkeyManager.cs

示例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
        }
开发者ID:CharlesLiyh,项目名称:MakeItStar,代码行数:8,代码来源:MainWindow.xaml.cs

示例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();
 }
开发者ID:markashleybell,项目名称:openthings,代码行数:8,代码来源:MainWindow.xaml.cs

示例10: AddHook

 private void AddHook(Visual window)
 {
     if (_hwndSource != null) return;
     _hwndSource = PresentationSource.FromVisual(window) as HwndSource;
     if (_hwndSource != null)
     {
         _hwndSource.AddHook(HwndSourceHook);
     }
 }
开发者ID:robertiagar,项目名称:Windows-10-Login-Background-Changer,代码行数:9,代码来源:SystemMenuHelper.cs

示例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();
        }
开发者ID:arghlolrofl,项目名称:mpchcfrontend,代码行数:9,代码来源:MainWindow.xaml.cs

示例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();
        }
开发者ID:servitola,项目名称:WpfBaggage,代码行数:9,代码来源:HotKey.cs

示例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));
            };
        }
开发者ID:Aosamesan,项目名称:NZNZ-WPF,代码行数:10,代码来源:WindowResizer.cs

示例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);
 }
开发者ID:jameshy,项目名称:else,代码行数:14,代码来源:Win32MessagePump.cs

示例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
        }
开发者ID:macedes,项目名称:YareNote,代码行数:10,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Interop.HwndSource.AddHook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。