protected override void WndProc(ref Message message)
        {
            base.WndProc(ref message);

            switch (message.Msg)
            {
            case NativeMethods.WM_COMMAND + NativeMethods.WM_REFLECT:
                int index = (int)message.WParam & 0xFFFF;
                this.PerformClick(this.items[index]);
                base.WndProc(ref message);
                this.ResetMouseEventArgs();
                break;

            case NativeMethods.WM_MENUCHAR:
                this.WmMenuChar(ref message);
                break;

            case NativeMethods.WM_NOTIFY:
            case NativeMethods.WM_NOTIFY + NativeMethods.WM_REFLECT:
                NativeMethods.NMHDR note = (NativeMethods.NMHDR)message.GetLParam(typeof(NativeMethods.NMHDR));
                switch (note.code)
                {
                case NativeMethods.TTN_NEEDTEXTA:
                    NotifyNeedTextA(ref message);
                    break;

                case NativeMethods.TTN_NEEDTEXTW:
                    NotifyNeedTextW(ref message);
                    break;

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

                case NativeMethods.TBN_DROPDOWN:
                    this.NotifyDropDown(ref message);
                    break;

                case NativeMethods.NM_CUSTOMDRAW:
                    this.NotifyCustomDraw(ref message);
                    break;

                case NativeMethods.TBN_HOTITEMCHANGE:
                    break;
                }
                break;
            }
        }
Example #2
0
        protected override void WndProc(ref Message m)
        {
            switch ((uint)m.Msg)
            {
            case 0x2000 | NativeMethods.WM_NOTIFY:
                //Reflected WM_NOTIFY from parent. Check that the handle is ours
                if (m.HWnd == Handle)
                {
                    //Then check the code of the message
                    NativeMethods.NMHDR nmHdr = (NativeMethods.NMHDR)
                                                m.GetLParam(typeof(NativeMethods.NMHDR));

                    //Handle only BCN_DROPDOWN messages
                    if (nmHdr.code == NativeMethods.BCN_DROPDOWN)
                    {
                        //The dropdown portion of the button is being pressed, show the menu
                        if (ContextMenuStrip != null)
                        {
                            Point point = new Point(Width - ContextMenuStrip.Width, Height);
                            ContextMenuStrip.Show(this, point, ToolStripDropDownDirection.BelowRight);
                            ContextMenuStrip.Closed += OnMenuClosed;
                        }
                    }
                }
                break;

            case NativeMethods.WM_PAINT:
                //Paint the control to have the dropdown portion as pressed when the
                //menu is shown.
                DropDownState = ContextMenuStrip != null && ContextMenuStrip.Visible;
                break;

            case NativeMethods.WM_CONTEXTMENU:
                //Swallow all context menu clicks on Vista and later -- otherwise
                //we will also show the context menu when the user right-clicks
                //the button.
                if (!IsSupportedOnCurrentPlatform)
                {
                    return;
                }
                break;
            }

            base.WndProc(ref m);
        }
        protected override void WndProc(ref Message message)
        {
            base.WndProc(ref message);

            switch (message.Msg)
            {
            case NativeMethods.WM_NOTIFY:
            case NativeMethods.WM_NOTIFY + NativeMethods.WM_REFLECT:
            {
                NativeMethods.NMHDR note = (NativeMethods.NMHDR)message.GetLParam(typeof(NativeMethods.NMHDR));
                switch (note.code)
                {
                case NativeMethods.RBN_HEIGHTCHANGE:
                    this.UpdateSize();
                    break;

                case NativeMethods.RBN_CHEVRONPUSHED:
                    this.NotifyChevronPushed(ref message);
                    break;
                }
            }
            break;
            }
        }