Exemplo n.º 1
0
        private void SetHScroll(SyncTextBox toSync, int value)
        {
            var wParam = new Win32.WParam((int)Win32.ScrollBarCommands.SB_THUMBPOSITION, value);
            var msg    = new Message();

            msg.HWnd   = toSync.Handle;
            msg.Msg    = Win32.WM_HSCROLL;
            msg.WParam = (IntPtr)wParam.Ptr();
            msg.LParam = (IntPtr)0;
            toSync.WndProc(ref msg);
        }
Exemplo n.º 2
0
        private void ProcessSelection(SyncTextBox toSync, int line)
        {
            if (!blockSel && line != selLine)
            {
                toSync.childLock       = true;
                toSync.SelectionLength = 0;
                int childIndex = toSync.GetFirstCharIndexFromLine(line);
                if (line < toSync.Lines.Length && childIndex >= 0)
                {
                    toSync.SelectionStart = childIndex;
                }
                toSync.childLock = false;
            }
            int thisScroll  = Win32.GetScrollPos(Handle, Orientation.Horizontal);
            int childScroll = Win32.GetScrollPos(toSync.Handle, Orientation.Horizontal);

            if (childScroll != thisScroll)
            {
                toSync.childLock = true;
                SetHScroll(toSync, thisScroll);
                toSync.childLock = false;
            }
        }
Exemplo n.º 3
0
        private bool ProcessMessage(SyncTextBox toSync, ref Message message)
        {
            var wParam = new Win32.WParam(message.WParam);

            switch (message.Msg)
            {
            case Win32.WM_KEYDOWN:
            case Win32.WM_KEYUP:
                switch (wParam.Message)
                {
                case 0x21:
                case 0x22:
                    blockSel = true;
                    base.WndProc(ref message);
                    message.HWnd     = toSync.Handle;
                    toSync.childLock = true;
                    toSync.WndProc(ref message);
                    toSync.childLock = false;
                    blockSel         = false;
                    return(false);
                }
                break;

            case Win32.WM_VSCROLL:
                switch ((Win32.ScrollBarCommands)wParam.Message)
                {
                case Win32.ScrollBarCommands.SB_LINEUP:
                case Win32.ScrollBarCommands.SB_LINEDOWN:
                case Win32.ScrollBarCommands.SB_PAGEUP:
                case Win32.ScrollBarCommands.SB_PAGEDOWN:
                    base.WndProc(ref message);
                    message.HWnd     = toSync.Handle;
                    toSync.childLock = true;
                    toSync.WndProc(ref message);
                    toSync.childLock = false;
                    return(false);

                case Win32.ScrollBarCommands.SB_THUMBTRACK:
                    toSync.childLock = true;
                    SetVScroll(toSync, wParam.Value);
                    toSync.childLock = false;
                    break;

                case Win32.ScrollBarCommands.SB_THUMBPOSITION:
                case Win32.ScrollBarCommands.SB_ENDSCROLL:
                    break;

                default:
                    break;
                }
                break;

            case Win32.WM_HSCROLL:
                switch ((Win32.ScrollBarCommands)wParam.Message)
                {
                case Win32.ScrollBarCommands.SB_LINELEFT:
                case Win32.ScrollBarCommands.SB_LINERIGHT:
                case Win32.ScrollBarCommands.SB_PAGELEFT:
                case Win32.ScrollBarCommands.SB_PAGERIGHT:
                    base.WndProc(ref message);
                    message.HWnd     = toSync.Handle;
                    toSync.childLock = true;
                    toSync.WndProc(ref message);
                    toSync.childLock = false;
                    return(false);

                case Win32.ScrollBarCommands.SB_THUMBTRACK:
                    toSync.childLock = true;
                    SetHScroll(toSync, wParam.Value);
                    toSync.childLock = false;
                    break;

                case Win32.ScrollBarCommands.SB_THUMBPOSITION:
                case Win32.ScrollBarCommands.SB_ENDSCROLL:
                    break;

                default:
                    break;
                }
                break;

            case Win32.WM_MOUSEWHEEL:
                int thisScroll = Win32.GetScrollPos((IntPtr)Handle, Orientation.Vertical);
                thisScroll -= (wParam.Value / 40) * (PreferredSize.Height / Lines.Length - 1);
                if (thisScroll < 0)
                {
                    thisScroll = 0;
                }
                SetVScroll(this, thisScroll);
                toSync.childLock = true;
                SetVScroll(toSync, thisScroll);
                toSync.childLock = false;
                return(false);
            }
            return(true);
        }