First, add this sentence to the form constructor.
C # Code
- This. Mousewheel + =NewSystem. Windows. Forms. mouseeventhandler (This. Panelappsmousewheel );
This. mousewheel + = new system. Windows. Forms. mouseeventhandler (this. panel?mousewheel );
C # code
-
- # Loading when region enters the form
-
- PublicFormalarminfoquery ()
-
- {
-
- Initializecomponent ();
-
- Picturebox1.imagelocation ="F: \ 1.jpg";
-
- This. Mousewheel + =NewSystem. Windows. Forms. mouseeventhandler (This. Panelappsmousewheel );
-
- // Determine whether a mouse with a scroll wheel is installed
-
- // Systeminformation. mousewheelpresent. tostring ();
- // Obtain the number of rows of the scroll wheel.
-
- // Systeminformation. mousewheelscrolllines. tostring ();
-
- // Determine whether the operating system supports scroll mouse
-
- // Systeminformation. nativemousewheelsupport. tostring ();
-
- }
-
- # Endregion
# When region enters the form, it loads public formalarminfoquery () {initializecomponent (); picturebox1.imagelocation = "F: \ 1.jpg"; this. mousewheel + = new system. windows. forms. mouseeventhandler (this. panelappsmousewheel); // determines whether a mouse with a scroll wheel is installed. // systeminformation. mousewheelpresent. tostring (); // obtain the number of rows obtained when the scroll wheel is scroll. // systeminformation. mousewheelscrolllines. tostring (); // determines whether the operating system supports scroll wheel and mouse. // systeminformation. nativemousewheelsupport. tostring () ;}# endregion
Then write a mouse event Method
C # code
- Private VoidPanelappsmousewheel (ObjectSender, system. Windows. Forms. mouseeventargs E)
-
- {
-
- MessageBox. Show ("Rolling event captured");
-
- System. Drawing. Size T = picturebox1.size;
-
- T. Width + = E. Delta;
- T. height + = E. Delta;
-
- Picturebox1.width = T. width;
-
- Picturebox1.height = T. height;
-
- }
Private void panelappsmousewheel (Object sender, system. windows. forms. mouseeventargs e) {MessageBox. show ("rolling event captured"); system. drawing. size T = picturebox1.size; T. width + = E. delta; T. height + = E. delta; picturebox1.width = T. width; picturebox1.height = T. height ;}
If the "rolling event captured" is output, the scroll wheel event is captured successfully, and you can write the event to be handled by the scroll wheel.