SetWindowText() private method

private SetWindowText ( IntPtr hWnd, string lpString ) : bool
hWnd IntPtr
lpString string
return bool
Ejemplo n.º 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));
        }
Ejemplo n.º 2
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);
        }