Exemple #1
0
        protected override void WndProc(ref Message m)
        {
            if ((m.Msg == NativeMethods.WM_NOTIFY_REFLECT) && m_bSupported)
            {
                try
                {
                    NativeMethods.NMHDR nm = (NativeMethods.NMHDR)m.GetLParam(
                        typeof(NativeMethods.NMHDR));
                    if (nm.code == BCN_DROPDOWN)
                    {
                        if (m_ctx != null)
                        {
                            m_ctx.ShowEx(this);
                            return;                             // We handled it
                        }
                        else
                        {
                            Debug.Assert(false);
                        }
                    }
                }
                catch (Exception) { Debug.Assert(false); }
            }

            base.WndProc(ref m);
        }
 protected override void WndProc(ref Message m)
 {
     switch (m.Msg)
     {
     case 0x4e:
     case 0x204e: {
         NativeMethods.NMHDR nmhdr = (NativeMethods.NMHDR)System.Runtime.InteropServices.Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NMHDR));
         if (nmhdr.code == -327)     //NativeMethods.HDN_ENDTRACK)
         {
             try {
                 ((IComponentChangeService)this.GetService(typeof(IComponentChangeService))).OnComponentChanged(base.Component, null, null, null);
             }
             catch (InvalidOperationException /*exception*/) {
                 //if (!this.inShowErrorDialog)
                 //{
                 //    IUIService service = (IUIService) base.Component.Site.GetService(typeof(IUIService));
                 //    this.inShowErrorDialog = true;
                 //    try
                 //    {
                 //        DataGridViewDesigner.ShowErrorDialog(service, exception, (ListView) base.Component);
                 //    }
                 //    finally
                 //    {
                 //        this.inShowErrorDialog = false;
                 //    }
                 //}
                 return;
             }
         }
         break;
     }
     }
     base.WndProc(ref m);
 }
        /// <include file='doc\PageSelector.uex' path='docs/doc[@for="PageSelector.WndProc"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == NativeMethods.WM_REFLECT + NativeMethods.WM_NOTIFY)
            {
                NativeMethods.NMHDR nmh = (NativeMethods.NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NMHDR));
                if (nmh.code == NativeMethods.NM_CUSTOMDRAW)
                {
                    OnCustomDraw(ref m);
                    return;
                }
            }

            base.WndProc(ref m);
        }
Exemple #4
0
        private void WmReflectNotify(ref Message m)
        {
            NativeMethods.NMHDR note = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR));
            switch (note.code)
            {
            case NativeMethods.NM_CUSTOMDRAW:
                WmNotifyCustomDraw(ref m);
                break;

            case NativeMethods.TBN_BEGINDRAG:
                WmNotifyBeginDrag(ref m);
                break;

            case NativeMethods.TBN_ENDDRAG:
                WmNotifyEndDrag(ref m);
                break;

            case NativeMethods.TBN_DRAGOUT:
                WmNotifyDragOut(ref m);
                break;

            case NativeMethods.TBN_GETOBJECT:
                WmNotifyGetObject(ref m);
                break;

            case NativeMethods.TBN_DROPDOWN:
                WmNotifyDropDown(ref m);
                break;

            case NativeMethods.TBN_HOTITEMCHANGE:
                WmNotifyHotItemChange(ref m);
                break;

            case NativeMethods.TBN_QUERYINSERT:
                m.Result = (IntPtr)1;
                break;

            case NativeMethods.TTN_NEEDTEXTA:
                WmNotifyNeedTextA(ref m);
                m.Result = (IntPtr)1;
                return;

            case NativeMethods.TTN_NEEDTEXTW:
                WmNotifyNeedTextW(ref m);
                m.Result = (IntPtr)1;
                return;
            }
        }
Exemple #5
0
        private void WmReflectNotify(ref Message m)
        {
            NativeMethods.NMHDR note = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR));
            switch (note.code)
            {
            case NativeMethods.TBN_HOTITEMCHANGE:
                WmNotifyHotItemChange(ref m);
                break;

            case NativeMethods.NM_CUSTOMDRAW:
                WmCustomDraw(ref m);
                break;

            case NativeMethods.TBN_QUERYINSERT:
                m.Result = (IntPtr)1;
                break;
            }
        }
Exemple #6
0
        protected override void WndProc(ref Message m)
        {
            if (!_allowColumnResize)
            {
                if (m.Msg == NativeMethods.WM_NOTIFY)
                {
                    NativeMethods.NMHDR nmhdr = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR));

                    switch (nmhdr.code)
                    {
                    case NativeMethods.HDN_BEGINTRACKA:
                    case NativeMethods.HDN_BEGINTRACKW:
                        m.Result = new IntPtr(1);
                        return;
                    }
                }
            }

            base.WndProc(ref m);
        }
Exemple #7
0
            /// <devdoc>
            ///     Override for WndProc to handle our PSP messages
            /// </devdoc>
            protected override void WndProc(ref Message m)
            {
                CancelEventArgs ce;

                switch (m.Msg)
                {
                case NativeMethods.WM_NOTIFY:
                    NativeMethods.NMHDR nmhdr = (NativeMethods.NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NMHDR));
                    switch (nmhdr.code)
                    {
                    case NativeMethods.PSN_RESET:
                        _closeCalled = true;
                        _page.OnClosed(EventArgs.Empty);
                        return;

                    case NativeMethods.PSN_APPLY:
                        PageApplyEventArgs pae = new PageApplyEventArgs();
                        _page.OnApply(pae);
                        switch (pae.ApplyBehavior)
                        {
                        case ApplyKind.Cancel:
                            m.Result = (IntPtr)NativeMethods.PSNRET_INVALID;
                            break;

                        case ApplyKind.CancelNoNavigate:
                            m.Result = (IntPtr)NativeMethods.PSNRET_INVALID_NOCHANGEPAGE;
                            break;

                        case ApplyKind.Apply:
                        default:
                            m.Result = IntPtr.Zero;
                            break;
                        }
                        UnsafeNativeMethods.SetWindowLong(m.HWnd, NativeMethods.DWL_MSGRESULT, m.Result);
                        return;

                    case NativeMethods.PSN_KILLACTIVE:
                        ce = new CancelEventArgs();
                        _page.OnDeactivate(ce);
                        m.Result = (IntPtr)(ce.Cancel ? 1 : 0);
                        UnsafeNativeMethods.SetWindowLong(m.HWnd, NativeMethods.DWL_MSGRESULT, m.Result);
                        return;

                    case NativeMethods.PSN_SETACTIVE:
                        _closeCalled = false;
                        ce           = new CancelEventArgs();
                        _page.OnActivate(ce);
                        m.Result = (IntPtr)(ce.Cancel ? -1 : 0);
                        UnsafeNativeMethods.SetWindowLong(m.HWnd, NativeMethods.DWL_MSGRESULT, m.Result);
                        return;
                    }
                    break;

                case NativeMethods.WM_DESTROY:

                    // we can't tell the difference between OK and Apply (see above), so
                    // if we get a destroy and close hasn't been called, make sure we call it
                    //
                    if (!_closeCalled && _page != null)
                    {
                        _page.OnClosed(EventArgs.Empty);
                    }
                    break;
                }

                base.WndProc(ref m);
            }
Exemple #8
0
        private void WmReflectNotify(ref Message m)
        {
            if (m.HWnd != Handle)
            {
                base.WndProc(ref m);
            }
            else
            {
                NativeMethods.NMHDR hdr = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR));
                switch (hdr.code)
                {
                case NativeMethods.EN_PROTECTED:
                    // WinForms is blocking edits at the beginning of the text
                    // if the first character is locked, and between two locked
                    // sections if they are adjacent to each other. If we have
                    // a zero-length character range that falls at the beginning
                    // of a locked field then stop the EN_PROTECTED notification
                    // from reaching the base. Note that the OnProtected override
                    // is especially lame: you get the notification after the
                    // response to the notification is determined and after the control
                    // has beeped!
                    NativeMethods.ENPROTECTED protectedInfo = NativeMethods.ENPROTECTED.Create(ref m);
                    NativeMethods.CHARRANGE   range         = protectedInfo.chrg;
                    int characterIndex = range.cpMin;
                    if (characterIndex == range.cpMax)
                    {
                        LockedField[] fields = myLockedFields;
                        if (fields != null)
                        {
                            for (int i = 0; i < fields.Length; ++i)
                            {
                                int fieldIndex = fields[i].Index;
                                int diff       = fieldIndex - characterIndex;
                                if (diff >= 0)
                                {
                                    if (diff == 0)
                                    {
                                        if (protectedInfo.msg == NativeMethods.WM_KEYDOWN)
                                        {
                                            // If we a keydown, then we can't let through
                                            // a delete and we can't let through a backspace
                                            // if we're touching the previous field
                                            bool keepProtected = false;
                                            switch ((Keys)protectedInfo.wParam)
                                            {
                                            case Keys.Delete:
                                                keepProtected = true;
                                                break;

                                            case Keys.Back:
                                                if (i > 0)
                                                {
                                                    LockedField previousField = fields[i - 1];
                                                    // If we're touching the previous field, then don't allow
                                                    // a backspace.
                                                    keepProtected = (previousField.Index + previousField.Length) == fieldIndex;
                                                }
                                                break;
                                            }
                                            if (keepProtected)
                                            {
                                                break;
                                            }
                                        }
                                        myAllowedProtectedEdit = true;
                                        m.Result = (IntPtr)0;
                                        return;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    break;
                }
                base.WndProc(ref m);
            }
        }
Exemple #9
0
 /// <summary>
 /// Overrides WndProc to intercept custom draw messages in  the message queue
 /// </summary>
 /// <param name="m"></param>
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == 20)
     {
         m.Result = IntPtr.Zero;
     }
     else
     {
         base.WndProc(ref m);
         if (m.Msg == 0x204e)
         {
             NativeMethods.NMHDR structure = (NativeMethods.NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NMHDR));
             if (structure.code == -12)
             {
                 IntPtr ptr;
                 Marshal.StructureToPtr(structure, m.LParam, false);
                 NativeMethods.NMCUSTOMDRAW nmcustomdraw = (NativeMethods.NMCUSTOMDRAW)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NMCUSTOMDRAW));
                 if (nmcustomdraw.dwDrawStage == NativeMethods.CustomDrawDrawStage.CDDS_PREPAINT)
                 {
                     Graphics       graphics = Graphics.FromHdc(nmcustomdraw.hdc);
                     PaintEventArgs e        = new PaintEventArgs(graphics, this.Bounds);
                     e.Graphics.TranslateTransform((float)(0 - this.Left), (float)(0 - this.Top));
                     this.InvokePaintBackground(this.Parent, e);
                     this.InvokePaint(this.Parent, e);
                     SolidBrush brush = new SolidBrush(this.BackColor);
                     e.Graphics.FillRectangle(brush, this.Bounds);
                     brush.Dispose();
                     e.Graphics.ResetTransform();
                     e.Dispose();
                     graphics.Dispose();
                     ptr      = new IntPtr(0x30);
                     m.Result = ptr;
                 }
                 else if (nmcustomdraw.dwDrawStage == NativeMethods.CustomDrawDrawStage.CDDS_POSTPAINT)
                 {
                     this.OnDrawTicks(nmcustomdraw.hdc);
                     this.OnDrawChannel(nmcustomdraw.hdc);
                     this.OnDrawThumb(nmcustomdraw.hdc);
                 }
                 else if (nmcustomdraw.dwDrawStage == NativeMethods.CustomDrawDrawStage.CDDS_ITEMPREPAINT)
                 {
                     if (nmcustomdraw.dwItemSpec.ToInt32() == 2)
                     {
                         this.ThumbBounds = nmcustomdraw.rc.ToRectangle();
                         if (this.Enabled)
                         {
                             if (nmcustomdraw.uItemState == NativeMethods.CustomDrawItemState.CDIS_SELECTED)
                             {
                                 this.ThumbState = 3;
                             }
                             else
                             {
                                 this.ThumbState = 1;
                             }
                         }
                         else
                         {
                             this.ThumbState = 5;
                         }
                         this.OnDrawThumb(nmcustomdraw.hdc);
                     }
                     else if (nmcustomdraw.dwItemSpec.ToInt32() == 3)
                     {
                         this.ChannelBounds = nmcustomdraw.rc.ToRectangle();
                         this.OnDrawChannel(nmcustomdraw.hdc);
                     }
                     else if (nmcustomdraw.dwItemSpec.ToInt32() == 1)
                     {
                         this.OnDrawTicks(nmcustomdraw.hdc);
                     }
                     ptr      = new IntPtr(4);
                     m.Result = ptr;
                 }
             }
         }
     }
 }
Exemple #10
0
        /// <summary>
        /// Overrides <see cref="M:System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message@)"/>.
        /// </summary>
        /// <param name="m">The Windows <see cref="T:System.Windows.Forms.Message"/> to process.</param>
        protected override void WndProc(ref Message m)
        {
            if (!DesignMode)
            {
                switch (m.Msg)
                {
                case 123:     // WM_CONTEXTMENU
                {
                    uint pos = unchecked ((uint)m.LParam);

                    Select();

                    OnShowContextMenu(new MouseEventArgs(Control.MouseButtons, 1,
                                                         unchecked ((short)(ushort)(pos & 0xFFFF)),
                                                         unchecked ((short)(ushort)(pos >> 16)), 0));

                    return;
                }

                case NativeMethods.OCM_NOTIFY:
                    // Receives ListView notifications
                    if (CheckBoxes && StrictCheckboxesClick)
                    {
                        NativeMethods.NMHDR hdr = (NativeMethods.NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NMHDR));

                        if (hdr.code == NativeMethods.NM_DBLCLK)
                        {
                            Point mp = PointToClient(MousePosition);
                            ListViewHitTestInfo hi = HitTest(mp);

                            if (hi != null && hi.Location != ListViewHitTestLocations.StateImage)
                            {
                                MouseEventArgs me = new MouseEventArgs(MouseButtons.Left, 2, mp.X, mp.Y, 0);
                                OnDoubleClick(me);
                                OnMouseDoubleClick(me);
                                return;
                            }
                        }
                    }
                    break;

                case NativeMethods.WM_NOTIFY:
                    // Receives child control notifications (like that of the header control)
                    if (CheckBoxes && ShowSelectAllCheckBox)
                    {
                        NativeMethods.NMHDR hdr = (NativeMethods.NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NMHDR));

                        if (hdr.code == NativeMethods.HDN_ITEMSTATEICONCLICK)
                        {
                            CancelEventArgs ce = new CancelEventArgs();

                            PerformSelectAllCheckedChange(ce);

                            if (ce.Cancel)
                            {
                                return;
                            }
                        }
                    }
                    break;

                case NativeMethods.WM_HSCROLL:
                    WmHScroll(ref m);
                    break;

                case NativeMethods.WM_VSCROLL:
                    WmVScroll(ref m);
                    break;
                }
            }
            base.WndProc(ref m);
        }