locked
WM_MOUSEWHEEL message does not propagate to parent RRS feed

  • Question

  • I have a RichTextBox with ScrollBars set to None.  According to MSDN

    > The DefWindowProc function propagates the message to the window's
    > parent. There should be no internal forwarding of the message, since
    > DefWindowProc propagates it up the parent chain until it finds a
    > window that processes it.

    I interpret this as, I should not need to hook into the message pump (IMessageFilter) and manually forward WM_MOUSEWHEEL events to the parent Form containing the richtextbox.  When I am inside of RichTextBox and perform a mouse scroll, the Form does not scroll.  Why not?  How can I get the Form to scroll?

    Keep in mind that scrollbars are set to none for RichTextBox and enabled for the Form.  So why isn't the form getting the scroll event?

        public partial class Form4 : Form
        {
            public Form4()
            {
                InitializeComponent();
                this.AutoScroll = true;
                richTextBox1.ScrollBars = RichTextBoxScrollBars.None;
            }
        }
    


    Blog

    Friday, September 21, 2012 1:35 PM

Answers

  • extract from MSDN article that you linked to:

    Sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it.

    Textbox controls process the message (even if the scrollbars are not visible) and so will not forward the message to their parent. In this case you will need to intercept and forward the message yourself.

    I would use a NativeWindow subclasss to catch and forward the message.


    Mick Doherty
    http://dotnetrix.co.uk
    http://glassui.codeplex.com

    • Proposed as answer by Bob Wu-MT Monday, September 24, 2012 9:32 AM
    • Marked as answer by P.Brian.Mackey Monday, September 24, 2012 1:00 PM
    Saturday, September 22, 2012 9:01 AM