Example #1
0
        private static IntPtr MessageBoxHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0)
            {
                return(MessageBoxManager.CallNextHookEx(MessageBoxManager.hHook, nCode, wParam, lParam));
            }
            MessageBoxManager.CWPRETSTRUCT cWPRETSTRUCT = (MessageBoxManager.CWPRETSTRUCT)Marshal.PtrToStructure(lParam, typeof(MessageBoxManager.CWPRETSTRUCT));
            IntPtr idHook = MessageBoxManager.hHook;

            if (cWPRETSTRUCT.message == 272u)
            {
                MessageBoxManager.GetWindowTextLength(cWPRETSTRUCT.hwnd);
                StringBuilder stringBuilder = new StringBuilder(10);
                MessageBoxManager.GetClassName(cWPRETSTRUCT.hwnd, stringBuilder, stringBuilder.Capacity);
                if (stringBuilder.ToString() == "#32770")
                {
                    MessageBoxManager.nButton = 0;
                    MessageBoxManager.EnumChildWindows(cWPRETSTRUCT.hwnd, MessageBoxManager.enumProc, IntPtr.Zero);
                    if (MessageBoxManager.nButton == 1)
                    {
                        IntPtr dlgItem = MessageBoxManager.GetDlgItem(cWPRETSTRUCT.hwnd, 2);
                        if (dlgItem != IntPtr.Zero)
                        {
                            MessageBoxManager.SetWindowText(dlgItem, MessageBoxManager.OK);
                        }
                    }
                }
            }
            return(MessageBoxManager.CallNextHookEx(idHook, nCode, wParam, lParam));
        }
Example #2
0
 public static void Unregister()
 {
     if (MessageBoxManager.hHook != IntPtr.Zero)
     {
         MessageBoxManager.UnhookWindowsHookEx(MessageBoxManager.hHook);
         MessageBoxManager.hHook = IntPtr.Zero;
     }
 }
Example #3
0
 public static void Register()
 {
     if (MessageBoxManager.hHook != IntPtr.Zero)
     {
         throw new NotSupportedException("One hook per thread allowed.");
     }
     MessageBoxManager.hHook = MessageBoxManager.SetWindowsHookEx(12, MessageBoxManager.hookProc, IntPtr.Zero, AppDomain.GetCurrentThreadId());
 }
Example #4
0
        /// <summary>
        /// Регистрирует с русскими названиями;
        /// </summary>
        public static void RegisterRU()
        {
            if (Registered)
            {
                return;
            }

            MessageBoxManager.Cancel = "Отмена";
            MessageBoxManager.OK     = "ОК";
            MessageBoxManager.Yes    = "Да";
            MessageBoxManager.No     = "Нет";
            MessageBoxManager.Retry  = "Повторить";
            MessageBoxManager.Ignore = "Игнорировать";
            MessageBoxManager.Abort  = "Прервать";

            MessageBoxManager.Register();
            Registered = true;
        }
Example #5
0
        private static bool MessageBoxEnumProc(IntPtr hWnd, IntPtr lParam)
        {
            StringBuilder stringBuilder = new StringBuilder(10);

            MessageBoxManager.GetClassName(hWnd, stringBuilder, stringBuilder.Capacity);
            if (stringBuilder.ToString() == "Button")
            {
                switch (MessageBoxManager.GetDlgCtrlID(hWnd))
                {
                case 1:
                    MessageBoxManager.SetWindowText(hWnd, MessageBoxManager.OK);
                    break;

                case 2:
                    MessageBoxManager.SetWindowText(hWnd, MessageBoxManager.Cancel);
                    break;

                case 3:
                    MessageBoxManager.SetWindowText(hWnd, MessageBoxManager.Abort);
                    break;

                case 4:
                    MessageBoxManager.SetWindowText(hWnd, MessageBoxManager.Retry);
                    break;

                case 5:
                    MessageBoxManager.SetWindowText(hWnd, MessageBoxManager.Ignore);
                    break;

                case 6:
                    MessageBoxManager.SetWindowText(hWnd, MessageBoxManager.Yes);
                    break;

                case 7:
                    MessageBoxManager.SetWindowText(hWnd, MessageBoxManager.No);
                    break;
                }
                MessageBoxManager.nButton++;
            }
            return(true);
        }
 static RtlMessageBox()
 {
     MessageBoxManager.Register();
 }