Button to scroll the middle button in the text box

I have a multi-line text box in my application, and when I press the middle click to scroll up or down, it does not work.

It works in Notepad, but not in my text box. Does anyone know why? or, if it is possible to program the start of scrolling in the desired direction by pressing the middle button?

+3
source share
2 answers

To make the mouse wheel scroll to work, create your own TextBox class that inherits the TextBox.

Override the WndProc method.

Look at the type of message.

For message type 0x207 (WM_MBUTTONDOWN) call DefWndProc (ref m); For any other type of message, call base.WndProc (ref m);

Then your text box will have a middle button scroll.

Typically, Windows.Forms overrides the inline function of the middle button of a text field, so the control may have a MouseDown event on the middle button, but it also disables the native scroll function. Return to the default window handler call, and the text box returns its scroll function.

+3
source

Do you have a ScrollBars property set to Vertical or Both ?
For me, this does not work only when ScrollBars = None or Horizontal

0
source

Source: https://habr.com/ru/post/1338457/


All Articles