public Everything() { var cp = new CreateParams { Caption = "PSEverything IPC Window", ClassName = "Static", ClassStyle = 0, Style = 0, ExStyle = 0, X = 0, Y = 0, Height = 1, Width = 1, Parent = IntPtr.Zero, Param = null }; CreateHandle(cp); var cs = new ChangeFilterStruct { Size = (uint)Marshal.SizeOf(typeof(ChangeFilterStruct)) }; if (!Win32.ChangeWindowMessageFilterEx(Handle, WindowMessage.CopyData, ChangeWindowMessageFilterExAction.Allow, ref cs)) { throw new Win32Exception(Marshal.GetLastWin32Error(), "Error allowing WM_COPYDATA mesasage from lower privilege processes."); } }
public static void EnableDragDropForWindow(Window window) { var source = new WindowInteropHelper(window); var changes = new ChangeFilterStruct(); ChangeWindowMessageFilterEx(source.Handle, WmDropFiles, ChangeWindowMessageFilterExAction.Allow, ref changes); ChangeWindowMessageFilterEx(source.Handle, WmCopyData, ChangeWindowMessageFilterExAction.Allow, ref changes); ChangeWindowMessageFilterEx(source.Handle, OtherOne, ChangeWindowMessageFilterExAction.Allow, ref changes); }
public static extern bool ChangeWindowMessageFilterEx( [In] IntPtr hwnd, // Window [In] WindowMessage message, // WM_ message [In] MessageFilterAction action, // Message filter action value [In, Out] ref ChangeFilterStruct pChangeFilterStruct); // Optional
internal static extern bool ChangeWindowMessageFilterEx(IntPtr hWnd, uint msg, ChangeWindowMessageFilterExAction action, ref ChangeFilterStruct changeInfo);
internal static void AddTabbedThumbnail(TabbedThumbnail preview) { // Create a TOP-LEVEL proxy window for the user's source window/control TaskbarWindow taskbarWindow = preview.WindowHandle == IntPtr.Zero ? GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail) : GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); // get the TaskbarWindow for UIElement/WindowHandle respectfully. //create taskbar, or set its TabbedThumbnail if (taskbarWindow == null) { taskbarWindow = new TaskbarWindow(preview); _taskbarWindowList.Add(taskbarWindow); } else if (taskbarWindow.TabbedThumbnail == null) { taskbarWindow.TabbedThumbnail = preview; } // Listen for Title changes preview.TitleChanged += new EventHandler(thumbnailPreview_TitleChanged); preview.TooltipChanged += new EventHandler(thumbnailPreview_TooltipChanged); // Get/Set properties for proxy window IntPtr windowHandle = taskbarWindow.WindowToTellTaskbarAbout; // Register this new tab and set it as being active. TaskbarList.Instance.RegisterTab(windowHandle, preview.ParentWindowHandle); TaskbarList.Instance.SetTabOrder(windowHandle, IntPtr.Zero); TaskbarList.Instance.SetTabActive(windowHandle, preview.ParentWindowHandle, 0); // We need to make sure we can set these properties even when running with admin var changeFilterResult = new ChangeFilterStruct { cbSize = (uint)Marshal.SizeOf <ChangeFilterStruct>() }; _ = HandlerNativeMethods.ChangeWindowMessageFilterEx( windowHandle, WindowMessage.DWMSendIconicThumbnail, MessageFilterAction.Allow, ref changeFilterResult); changeFilterResult = new ChangeFilterStruct { cbSize = (uint)Marshal.SizeOf <ChangeFilterStruct>() }; _ = HandlerNativeMethods.ChangeWindowMessageFilterEx( windowHandle, WindowMessage.DWMSendIconicLivePreviewBitmap, MessageFilterAction.Allow, ref changeFilterResult); // BUG: There should be somewhere to disable CustomWindowPreview. I didn't find it. DesktopWindowManager.EnableCustomWindowPreview(windowHandle, true); // Make sure we use the initial title set by the user // Trigger a "fake" title changed event, so the title is set on the taskbar thumbnail. // Empty/null title will be ignored. thumbnailPreview_TitleChanged(preview, EventArgs.Empty); thumbnailPreview_TooltipChanged(preview, EventArgs.Empty); // Indicate to the preview that we've added it on the taskbar preview.AddedToTaskbar = true; }