private void CreateMessageWindow() { //generate a unique ID for the window WindowId = "MessageSinkWindow" + Guid.NewGuid(); //register window message handler messageHandler = OnWindowMessageReceived; WindowClass wc; wc.style = 0; wc.lpfnWndProc = messageHandler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = IntPtr.Zero; wc.hIcon = IntPtr.Zero; wc.hCursor = IntPtr.Zero; wc.hbrBackground = IntPtr.Zero; wc.lpszMenuName = string.Empty; wc.lpszClassName = WindowId; RegisterClass(ref wc); WindowHandle = CreateWindowEx(0, WindowId, "", 0, 0, 0, 1, 1, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); if (WindowHandle == IntPtr.Zero) { throw new Exception("Message sink could not be created."); } }
/// <summary> /// Creates the helper message window that is used to receive messages from the taskbar icon. /// </summary> private void CreateMessageWindow() { // Generate a unique ID for the window WindowClassId = "MP2-ServiceeMonitor_" + DateTime.Now.Ticks; // Register window message handler _messageHandler = OnWindowMessageReceived; // Create a simple window class which is reference through the messageHandler delegate WindowClass wc; wc.style = 0; wc.lpfnWndProc = _messageHandler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = IntPtr.Zero; wc.hIcon = IntPtr.Zero; wc.hCursor = IntPtr.Zero; wc.hbrBackground = IntPtr.Zero; wc.lpszMenuName = ""; wc.lpszClassName = WindowClassId; // Register the window class WinApi.RegisterClass(ref wc); // Create the message window MessageWindowHandle = WindowsAPI.CreateWindowEx(0, WindowClassId, "", 0, 0, 0, 1, 1, 0, 0, 0, 0); if (MessageWindowHandle == IntPtr.Zero) { throw new Win32Exception(); } }
static ClipboardHandle() { _wndProc = NativeMethods.DefWindowProc; _clsName = "ClipboardGap_" + DateTime.Now.Ticks; WindowClass wc; wc.style = 0; wc.lpfnWndProc = _wndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = IntPtr.Zero; wc.hIcon = IntPtr.Zero; wc.hCursor = IntPtr.Zero; wc.hbrBackground = IntPtr.Zero; wc.lpszMenuName = ""; wc.lpszClassName = _clsName; // we just create one window for this process, it will be used for all future clipboard handles. // this class will be unregistered when the process exits. _clsAtom = NativeMethods.RegisterClass(ref wc); if (_clsAtom == 0) { throw new Win32Exception(); } _hWindow = NativeMethods.CreateWindowEx(0, _clsName, "", 0, 0, 0, 1, 1, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); if (_hWindow == IntPtr.Zero) { throw new Win32Exception(); } }
private void method_3(bool bool_2) { if (!this.IsDisposed && bool_2) { this.IsDisposed = true; Class5.DestroyWindow(this.IntPtr_0); this.windowProcedureHandler_0 = null; } }
/// <summary> /// Removes the windows hook that receives window /// messages and closes the underlying helper window. /// </summary> private void Dispose(bool disposing) { //don't do anything if the component is already disposed if (IsDisposed || !disposing) { return; } IsDisposed = true; WinApi.DestroyWindow(MessageWindowHandle); messageHandler = null; }
/// <summary> /// Removes the windows hook that receives window messages and closes the underlying helper window. /// </summary> /// <param name="disposing">The disposing.</param> private void Dispose(bool disposing) { // don't do anything if the component is already disposed if (this.IsDisposed || !disposing) { return; } this.IsDisposed = true; NativeMethods.DestroyWindow(this.MessageWindowHandle); this.messageHandler = null; }
/// <summary> /// Removes the windows hook that receives window /// messages and closes the underlying helper window. /// </summary> private void Dispose(bool disposing) { //don't do anything if the component is already disposed if (this.IsDisposed) { return; } this.IsDisposed = true; //always destroy the unmanaged handle (even if called from the GC) NativeMethods.DestroyWindow(this.MessageWindowHandle); this.messageHandler = null; }
/// <summary> /// Removes the windows hook that receives window /// messages and closes the underlying helper window. /// </summary> private void Dispose(bool disposing) { //don't do anything if the component is already disposed if (IsDisposed) { return; } IsDisposed = true; //always destroy the unmanaged handle (even if called from the GC) WinApi.DestroyWindow(MessageWindowHandle); messageHandler = null; }
/// <summary> /// Creates the helper message window that is used /// to receive messages from the taskbar icon. /// </summary> private void CreateMessageWindow() { // generate a unique ID for the window this.WindowId = "WPFTaskbarMessageWindow_" + DateTime.Now.Ticks; // register window message handler this.messageHandler = this.OnWindowMessageReceived; // Create a simple window class which is reference through the messageHandler delegate WindowClass wc; wc.style = 0; wc.lpfnWndProc = this.messageHandler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = IntPtr.Zero; wc.hIcon = IntPtr.Zero; wc.hCursor = IntPtr.Zero; wc.hbrBackground = IntPtr.Zero; wc.lpszMenuName = string.Empty; wc.lpszClassName = this.WindowId; // Register the window class WinApi.RegisterClass(ref wc); // Get the message used to indicate the taskbar has been restarted // This is used to re-add icons when the taskbar restarts this.taskbarRestartMessageId = WinApi.RegisterWindowMessage("TaskbarCreated"); // Create the message window this.MessageWindowHandle = WinApi.CreateWindowEx( 0, WindowId, string.Empty, 0, 0, 0, 0, 0, HWND_MESSAGE, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero ); if (this.MessageWindowHandle == IntPtr.Zero) { throw new Win32Exception("Message window handle was not a valid pointer"); } }
public static WindowClass Create(string id, WindowProcedureHandler callback) { return(new WindowClass() { style = 0, lpfnWndProc = callback, cbClsExtra = 0, cbWndExtra = 0, hInstance = IntPtr.Zero, hIcon = IntPtr.Zero, hCursor = IntPtr.Zero, hbrBackground = IntPtr.Zero, lpszMenuName = "", lpszClassName = id }); }
/// <summary> /// Disposes the object. /// </summary> public void Dispose() { if (IsDisposed) { return; } WindowsAPI.DestroyWindow(MessageWindowHandle); _messageHandler = null; IsDisposed = true; // This object will be cleaned up by the Dispose method. // Therefore, we call GC.SupressFinalize to take this object off the finalization queue // and prevent finalization code for this object from executing a second time. GC.SuppressFinalize(this); }
/// <summary> /// Creates the helper message window that is used to receive messages from the taskbar icon. /// </summary> private void CreateMessageWindow() { // generate a unique ID for the window // ReSharper disable LocalizableElement this.WindowId = "WPFTaskbarIcon_" + DateTime.Now.Ticks; // ReSharper restore LocalizableElement // register window message handler this.messageHandler = this.OnWindowMessageReceived; // Create a simple window class which is reference through // the messageHandler delegate var wc = new WindowClass(); wc.Style = 0; wc.LpfnWndProc = this.messageHandler; wc.CBClsExtra = 0; wc.CBWndExtra = 0; wc.HInstance = IntPtr.Zero; wc.HIcon = IntPtr.Zero; wc.HCursor = IntPtr.Zero; wc.HbrBackground = IntPtr.Zero; wc.LpszMenuName = string.Empty; wc.LpszClassName = this.WindowId; // Register the window class NativeMethods.RegisterClass(ref wc); // Get the message used to indicate the taskbar has been restarted // This is used to re-add icons when the taskbar restarts // ReSharper disable LocalizableElement this.taskbarRestartMessageId = NativeMethods.RegisterWindowMessage("TaskbarCreated"); // ReSharper restore LocalizableElement // Create the message window this.MessageWindowHandle = NativeMethods.CreateWindowEx(0, this.WindowId, string.Empty, 0, 0, 0, 1, 1, 0, 0, 0, 0); if (this.MessageWindowHandle == IntPtr.Zero) { throw new Win32Exception(); } }
/// <summary> /// Creates the helper message window that is used /// to receive messages from the taskbar icon. /// </summary> private void CreateMessageWindow() { //generate a unique ID for the window WindowId = "WPFTaskbarIcon_" + Guid.NewGuid(); //register window message handler messageHandler = OnWindowMessageReceived; // Create a simple window class which is reference through //the messageHandler delegate WindowClass wc; wc.style = 0; wc.lpfnWndProc = messageHandler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = IntPtr.Zero; wc.hIcon = IntPtr.Zero; wc.hCursor = IntPtr.Zero; wc.hbrBackground = IntPtr.Zero; wc.lpszMenuName = ""; wc.lpszClassName = WindowId; // Register the window class WinApi.RegisterClass(ref wc); // Get the message used to indicate the taskbar has been restarted // This is used to re-add icons when the taskbar restarts taskbarRestartMessageId = WinApi.RegisterWindowMessage("TaskbarCreated"); // Create the message window MessageWindowHandle = WinApi.CreateWindowEx(0, WindowId, "", 0, 0, 0, 1, 1, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); if (MessageWindowHandle == IntPtr.Zero) { #if SILVERLIGHT throw new Exception("Message window handle was not a valid pointer."); #else throw new Win32Exception("Message window handle was not a valid pointer"); #endif } }
public MessageSink() { WindowId = "WPFTaskbarIcon_" + DateTime.Now.Ticks; _msgHandler = OnWindowMessageReceived; WindowClass wc; wc.style = 0; wc.lpfnWndProc = _msgHandler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = IntPtr.Zero; wc.hIcon = IntPtr.Zero; wc.hCursor = IntPtr.Zero; wc.hbrBackground = IntPtr.Zero; wc.lpszMenuName = ""; wc.lpszClassName = WindowId; Win32Api.RegisterClass(ref wc); MsgWinHandle = Win32Api.CreateWindowEx(0, WindowId, "", 0, 0, 0, 1, 1, 0, 0, 0, 0); }
private void method_0() { WindowClass class2; this.String_0 = "WPFTaskbarIcon_" + DateTime.Now.Ticks; this.windowProcedureHandler_0 = new WindowProcedureHandler(this.method_1); class2.style = 0; class2.lpfnWndProc = this.windowProcedureHandler_0; class2.cbClsExtra = 0; class2.cbWndExtra = 0; class2.hInstance = IntPtr.Zero; class2.hIcon = IntPtr.Zero; class2.hCursor = IntPtr.Zero; class2.hbrBackground = IntPtr.Zero; class2.lpszMenuName = ""; class2.lpszClassName = this.String_0; Class5.RegisterClassW(ref class2); this.uint_0 = Class5.RegisterWindowMessageW("TaskbarCreated"); this.IntPtr_0 = Class5.CreateWindowExW(0, this.String_0, "", 0, 0, 0, 1, 1, 0, 0, 0, 0); if (this.IntPtr_0 == IntPtr.Zero) { throw new Win32Exception(); } }
/// <summary> /// Removes the windows hook that receives window /// messages and closes the underlying helper window. /// </summary> private void Dispose(bool disposing) { //don't do anything if the component is already disposed if (IsDisposed || !disposing) return; IsDisposed = true; WinApi.DestroyWindow(MessageWindowHandle); messageHandler = null; }
/// <summary> /// Creates the helper message window that is used /// to receive messages from the taskbar icon. /// </summary> private void CreateMessageWindow() { //generate a unique ID for the window WindowId = "WPFTaskbarIcon_" + DateTime.Now.Ticks; //register window message handler messageHandler = OnWindowMessageReceived; // Create a simple window class which is reference through //the messageHandler delegate WindowClass wc; wc.style = 0; wc.lpfnWndProc = messageHandler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = IntPtr.Zero; wc.hIcon = IntPtr.Zero; wc.hCursor = IntPtr.Zero; wc.hbrBackground = IntPtr.Zero; wc.lpszMenuName = ""; wc.lpszClassName = WindowId; // Register the window class WinApi.RegisterClass(ref wc); // Get the message used to indicate the taskbar has been restarted // This is used to re-add icons when the taskbar restarts taskbarRestartMessageId = WinApi.RegisterWindowMessage("TaskbarCreated"); // Create the message window MessageWindowHandle = WinApi.CreateWindowEx(0, WindowId, "", 0, 0, 0, 1, 1, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); if (MessageWindowHandle == IntPtr.Zero) { throw new Win32Exception(); } }
/// <summary> /// Removes the windows hook that receives window /// messages and closes the underlying helper window. /// </summary> private void Dispose(bool disposing) { //don't do anything if the component is already disposed if (this.IsDisposed) return; this.IsDisposed = true; //always destroy the unmanaged handle (even if called from the GC) if (this.MessageWindowHandle != IntPtr.Zero) { WinApi.DestroyWindow(this.MessageWindowHandle); this.MessageWindowHandle = IntPtr.Zero; this.messageHandler = null; } }
/// <summary> /// Creates the helper message window that is used to receive messages from the taskbar icon. /// </summary> private void CreateMessageWindow() { // Generate a unique ID for the window WindowClassId = "MP2-ServiceeMonitor_" + DateTime.Now.Ticks; // Register window message handler _messageHandler = OnWindowMessageReceived; // Create a simple window class which is reference through the messageHandler delegate WindowClass wc; wc.style = 0; wc.lpfnWndProc = _messageHandler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = IntPtr.Zero; wc.hIcon = IntPtr.Zero; wc.hCursor = IntPtr.Zero; wc.hbrBackground = IntPtr.Zero; wc.lpszMenuName = ""; wc.lpszClassName = WindowClassId; // Register the window class WinApi.RegisterClass(ref wc); // Create the message window MessageWindowHandle = WindowsAPI.CreateWindowEx(0, WindowClassId, "", 0, 0, 0, 1, 1, 0, 0, 0, 0); if (MessageWindowHandle == IntPtr.Zero) throw new Win32Exception(); }
/// <summary> /// Removes the windows hook that receives window /// messages and closes the underlying helper window. /// </summary> private void Dispose(bool disposing) { //don't do anything if the component is already disposed if (IsDisposed) return; IsDisposed = true; //always destroy the unmanaged handle (even if called from the GC) WinApi.DestroyWindow(MessageWindowHandle); messageHandler = null; }
private void Dispose(bool disposing) { if (disposing) { Win32Api.DestroyWindow(MsgWinHandle); _msgHandler = null; } }
/// <summary> /// Disposes the object. /// </summary> public void Dispose() { if (IsDisposed) return; WindowsAPI.DestroyWindow(MessageWindowHandle); _messageHandler = null; IsDisposed = true; // This object will be cleaned up by the Dispose method. // Therefore, we call GC.SupressFinalize to take this object off the finalization queue // and prevent finalization code for this object from executing a second time. GC.SuppressFinalize(this); }