Esempio n. 1
0
        // Our wndproc
        private int WindowProc(IntPtr hwnd, uint msg, uint wParam, int lParam)
        {
            Message message = new Message();

            message.HWnd = hwnd;
            message.Msg  = (int)msg;
            // Need this casting, for flags that are passed as large unsigned values
            message.WParam = (IntPtr)(int)(((UIntPtr)wParam).ToUInt32());
            message.LParam = (IntPtr)lParam;

            // Call our usual code
            return(WndProc(ref message));
        }
Esempio n. 2
0
        /// <summary>
        /// handle vertical scroll
        /// </summary>
        /// <param name="m"></param>
        private void OnVScroll(ref Message m)
        {
            int newValue = Int32.MinValue;

            NativeScroll.SCROLLINFO sc = ScrollInfo(NativeScroll.SB_VERT);
            int value       = sc.nPos;
            int nScrollCode = NativeWindowCommon.LoWord((int)m.WParam);

            switch (nScrollCode)
            {
            case NativeScroll.SB_TOP:
                newValue = 0;
                break;

            case NativeScroll.SB_BOTTOM:
                newValue = sc.nMax;
                break;

            case NativeScroll.SB_LINEUP:
                newValue = value - 1;
                break;

            case NativeScroll.SB_LINEDOWN:
                newValue = value + 1;
                break;

            case NativeScroll.SB_PAGEUP:
                newValue = value - sc.nPage;
                break;

            case NativeScroll.SB_PAGEDOWN:
                newValue = value + sc.nPage;
                break;

            case NativeScroll.SB_THUMBPOSITION:
                EndThumbDrag();
                break;

            case NativeScroll.SB_THUMBTRACK:
                StartThumbDrag();
                newValue = GetThumbTrackVal(sc.nTrackPos);
                value    = GetPrevScrollVal(sc.nPos);
                break;
            }
            if (newValue != Int32.MinValue && newValue != value)
            {
                ScrollVertically((ScrollEventType)m.WParam, newValue, value, true);
            }
        }
Esempio n. 3
0
        protected int WndProc(ref Message m)
#endif
        {
            MouseEventArgs mouseEvents;

            switch (m.Msg)
            {
#if !PocketPC
            case NativeWindowCommon.CBN_DROPDOWN:
            {
                if (OriginalDropDownWindowProc == IntPtr.Zero)
                {
                    NativeWindowCommon.COMBOBOXINFO comboBoxInfo = new NativeWindowCommon.COMBOBOXINFO();
                    // alloc ptrComboBoxInfo
                    IntPtr ptrComboBoxInfo = Marshal.AllocHGlobal(Marshal.SizeOf(comboBoxInfo));

                    try
                    {
                        //get combo Box Info
                        comboBoxInfo.cbSize = (IntPtr)Marshal.SizeOf(comboBoxInfo);
                        Marshal.StructureToPtr(comboBoxInfo, ptrComboBoxInfo, true);
                        IntPtr intptr = NativeHeader.SendMessage(this.Handle, NativeWindowCommon.CB_GETCOMBOBOXINFO, 0, ptrComboBoxInfo);

                        //CB_GETCOMBOBOXINFO : If the send message succeeds, the return value is nonzero.
                        int returnValue = intptr.ToInt32();
                        if (returnValue > 0)
                        {
                            // get the info from ptrComboBoxInfo to comboBoxInfo
                            comboBoxInfo = (NativeWindowCommon.COMBOBOXINFO)Marshal.PtrToStructure(ptrComboBoxInfo, typeof(NativeWindowCommon.COMBOBOXINFO));

                            // save hwnd drop down list
                            HwndDropDownList = comboBoxInfo.hwndList;

                            //replace the window proc of the drop down list
                            CustomDropDownWindowProc = new ControlWndProc(DropDownWindowProc);

                            // save the original drop down list (most be member in the class so the garbig collection will not free it)
                            OriginalDropDownWindowProc = (IntPtr)NativeWindowCommon.SetWindowLong(HwndDropDownList,
                                                                                                  NativeWindowCommon.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(CustomDropDownWindowProc).ToInt32());
                        }
                        else
                        {
                            Debug.Assert(false);
                        }
                    }
                    finally
                    {
                        // free the ptrComboBoxInfo
                        Marshal.FreeHGlobal(ptrComboBoxInfo);
                    }
                }
            }
            break;
#endif
            case NativeWindowCommon.WM_LBUTTONDOWN:
            case NativeWindowCommon.WM_LBUTTONDBLCLK:
                if (!this.DroppedDown)
                {
                    // prevent drop down on combo - to prevent combo openning on non parkable controls
                    // - it must be handled manually
                    mouseEvents = new MouseEventArgs(MouseButtons.Left, 0,
                                                     NativeWindowCommon.LoWord((int)m.LParam), NativeWindowCommon.HiWord((int)m.LParam), 0);
                    this.OnMouseDown(mouseEvents);

                    // provide doubleclick event
#if !PocketPC
                    if (m.Msg == NativeWindowCommon.WM_LBUTTONDBLCLK)
                    {
                        this.OnMouseDoubleClick(mouseEvents);
                    }
                    return;
#else
                    return(0);
#endif
                }
                break;
            }

#if !PocketPC
            base.WndProc(ref m);
#else
            return(NativeWindowCommon.CallWindowProc(OrigWndProc, m.HWnd, (uint)m.Msg, (uint)m.WParam.ToInt32(), m.LParam.ToInt32()));
#endif
        }
Esempio n. 4
0
 protected override void WndProc(ref Message m)
Esempio n. 5
0
        /// <summary>
        /// handle horizontal scroll
        /// </summary>
        /// <param name="m"></param>
        private void OnHScroll(ref Message m)
        {
            int newValue = int.MinValue;

            NativeScroll.SCROLLINFO sc = new NativeScroll.SCROLLINFO();

            int nScrollCode = NativeWindowCommon.LoWord((int)m.WParam);

            sc = ScrollInfo(NativeScroll.SB_HORZ);
            int value    = sc.nPos;
            int maxValue = sc.nMax;

            switch (nScrollCode)
            {
            case NativeScroll.SB_LEFT:
                newValue = 0;
                break;

            case NativeScroll.SB_RIGHT:
                newValue = maxValue;
                break;

            case NativeScroll.SB_LINELEFT:
                newValue = value - 1;
                break;

            case NativeScroll.SB_LINERIGHT:
                if (value + 1 <= maxValue)
                {
                    newValue = value + 1;
                }
                break;

            case NativeScroll.SB_PAGELEFT:
                newValue = value - sc.nPage;
                break;

            case NativeScroll.SB_PAGERIGHT:
                newValue = value + sc.nPage;
                break;

            case NativeScroll.SB_THUMBTRACK:
                newValue = sc.nTrackPos;
                break;
            }
            //Sometimes we get here even if no horizontal scrollbar exsits
            //happens during load of RTL table in new studio designer
            //we should not Scroll if we do not have horizontal scollbar
            if (newValue != int.MinValue && isHorizontalScrollBarVisible)
            {
                ScrollEventArgs arg = new ScrollEventArgs((ScrollEventType)m.WParam, value, newValue, ScrollOrientation.HorizontalScroll);
                this.OnScroll(arg);
                ScrollHorizontally(value, newValue);
                Invalidate();
#if !PocketPC
                if (this.DesignMode)
                {
                    RefreshChildrensGlyphs();
                }
#endif
            }
            return;
        }