1 #regionLoad when entering form2 3 Publicformalarminfoquery ()4 {5 InitializeComponent ();6Picturebox1.imagelocation ="f:\\1.jpg";7 8 This. MouseWheel + =NewSystem.Windows.Forms.MouseEventHandler ( This. Panel1_mousewheel);9 //determine if a mouse with a scroll wheel is installedTen //SystemInformation.MouseWheelPresent.ToString (); One //gets the number of rows that the mouse wheel obtains when scrolling A //SystemInformation.MouseWheelScrollLines.ToString (); - //determine if the operating system supports wheel mouse - //SystemInformation.NativeMouseWheelSupport.ToString (); the } - - #endregion
1 Private voidPanel1_mousewheel (Objectsender, System.Windows.Forms.MouseEventArgs e)2 {3MessageBox.Show ("scrolling events have been snapped");4System.Drawing.Size T =picturebox1.size;5T.width + =E.delta;6T.height + =E.delta;7Picturebox1.width =T.width;8Picturebox1.height =T.height;9}
Here is the mouse control music player Volume event
1 PublicForm1 ()2 {3 InitializeComponent ();4 This. Btnjin. MouseWheel + =NewMouseEventHandler (btnjin_mousewheel);5 6 }7 intm1= -;8 Private voidBtnjin_mousewheel (Objectsender, System.Windows.Forms.MouseEventArgs e)9 {Ten if(m1>=0&&m1<= -) One { AM1 + = E.delta/ -; - if(M1 > -) - { theM1 = -; - } - Else if(M1 <0) - { +M1 =0; - } +Lblvol. Width = ( -/ -) * M1/5; AMusic.settings.volume =M1; at } - - - } - - Private voidBtnjin_mouseenter (Objectsender, EventArgs e) in { -Panel2. Visible =true; to } + - Private voidBtnjin_mouseleave (Objectsender, EventArgs e) the { *Panel2. Visible =false; $}
WinForm Mouse wheel Events