winform滑鼠滾輪事件

來源:互聯網
上載者:User

標籤:

 1 #region 進入表單時載入 2  3 public FormAlarmInfoQuery() 4 { 5     InitializeComponent(); 6     pictureBox1.ImageLocation = "f:\\1.jpg"; 7  8          this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseWheel); 9          //判斷是否已安裝帶滾輪的滑鼠10     //SystemInformation.MouseWheelPresent.ToString();11     //擷取滑鼠滾輪在滾動時所獲得的行數12     //SystemInformation.MouseWheelScrollLines.ToString();13     //判斷該作業系統是否支援滾輪滑鼠14     //SystemInformation.NativeMouseWheelSupport.ToString(); 15 }16 17 #endregion
1 private void panel1_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)2 {3     MessageBox.Show("滾動事件已被捕捉");4     System.Drawing.Size t = pictureBox1.Size;5     t.Width += e.Delta;6     t.Height += e.Delta;7     pictureBox1.Width = t.Width;8     pictureBox1.Height = t.Height;9 }

 

 

 

下面是滑鼠控制音樂播放器音量事件

 1         public Form1() 2         { 3             InitializeComponent(); 4             this.btnjin.MouseWheel += new MouseEventHandler(btnjin_MouseWheel); 5  6         } 7         int m1=30; 8         private void btnjin_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)  9         {10             if(m1>=0&&m1<=100)11             {12                 m1 += e.Delta / 24;13                 if (m1 > 100)14                 {15                     m1 = 100;16                 }17                 else if (m1 < 0)18                 {19                     m1 = 0;20                 }21                 lblvol.Width = (60 / 20) * m1 / 5;22                 Music.settings.volume = m1 ;23             }24             25 26         }27 28         private void btnjin_MouseEnter(object sender, EventArgs e)29         {30             panel2.Visible = true;31         }32 33         private void btnjin_MouseLeave(object sender, EventArgs e)34         {35             panel2.Visible = false;36         }

 

winform滑鼠滾輪事件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.