Ejemplo n.º 1
0
        public static DialogResult Show(string msg, string title, MessageBoxButtons btns, MessageBoxIcon icon,
                                        MessageBoxDefaultButton defBtn, Font customTextFont)
        {
            // Create a callback delegate
            _hookProcDelegate = HookCallback;

            // Remember the title & message that we'll look for.
            // The hook sees *all* windows, so we need to make sure we operate on the right one.
            _msg            = msg;
            _title          = title;
            _customTextFont = customTextFont;

            // Set the hook.
            // Suppress "GetCurrentThreadId() is deprecated" warning.
            // It's documented that Thread.ManagedThreadId doesn't work with SetWindowsHookEx()
#pragma warning disable 0618
            _hHook = Win32.SetWindowsHookEx(Win32.WH_CBT, _hookProcDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId());
#pragma warning restore 0618

            // Pop a standard MessageBox. The hook will center it.
            var rslt = MessageBox.Show(msg, title, btns, icon, defBtn);

            // Release hook, clean up (may have already occurred)
            Unhook();

            return(rslt);
        }
Ejemplo n.º 2
0
		public static DialogResult Show(string msg, string title, MessageBoxButtons btns, MessageBoxIcon icon)
		{
			// Create a callback delegate
			_hookProcDelegate = new Win32.WindowsHookProc(HookCallback);

			// Remember the title & message that we'll look for.
			// The hook sees *all* windows, so we need to make sure we operate on the right one.
			_msg = msg;
			_title = title;

			// Set the hook.
			// Suppress "GetCurrentThreadId() is deprecated" warning. 
			// It's documented that Thread.ManagedThreadId doesn't work with SetWindowsHookEx()
#pragma warning disable 0618
			_hHook = Win32.SetWindowsHookEx(Win32.WH_CBT, _hookProcDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId());
#pragma warning restore 0618

			// Pop a standard MessageBox. The hook will center it.
			DialogResult rslt = MessageBox.Show(msg, title, btns, icon);

			// Release hook, clean up (may have already occurred)
			Unhook();

			return rslt;
		}
Ejemplo n.º 3
0
		private static void Unhook()
		{
			Win32.UnhookWindowsHookEx(_hHook);
			_hHook = 0;
			_hookProcDelegate = null;
			_msg = null;
			_title = null;
		}
Ejemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 public LowLevelMouseHook(string name)
 {
     _name = name;
     _hookID = IntPtr.Zero;
     _hookProc = HookCallback;
     _state = DoubleClickState.Empty;
     _strategy = MoveStrategy.Standard;
 }
Ejemplo n.º 5
0
 private static void Unhook()
 {
     Win32.UnhookWindowsHookEx(_hHook);
     _hHook            = 0;
     _hookProcDelegate = null;
     _msg   = null;
     _title = null;
 }
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 public LowLevelMouseHook(string name)
 {
     _name     = name;
     _hookID   = IntPtr.Zero;
     _hookProc = HookCallback;
     _state    = DoubleClickState.Empty;
     _strategy = MoveStrategy.Standard;
 }
Ejemplo n.º 7
0
        public static DialogResult Show(string msg_, string title_, MessageBoxButtons btns, MessageBoxIcon icon)
        {
            hookProcDelegate = new Win32.WindowsHookProc(HookCallback);

            msg = msg_;
            title = title_;

            #pragma warning disable 0618
            hHook = Win32.SetWindowsHookEx(Win32.WH_CBT, hookProcDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId());
            #pragma warning restore 0618

            DialogResult rslt = MessageBox.Show(msg_, title_, btns, icon);

            Unhook();

            return rslt;
        }
Ejemplo n.º 8
0
 private static void Unhook()
 {
     Win32.UnhookWindowsHookEx(hHook);
     hHook = 0;
     hookProcDelegate = null;
     msg = null;
     title = null;
 }