您好,登錄后才能下訂單哦!
this.KeyPreview = true;
this.MouseWheel += new MouseEventHandler(Form1_MouseWheel);
this.KeyPreview = true是要讓窗體優先響應按鍵事件。
void Form1_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) { ShowPrevPicture(); } else { ShowNextPicture(); } }
我這里是讓鼠標滾輪往下滾時顯示下一張圖,往上滾時顯示上一張。
按鍵事件的話需要重載ProcessDialogKey函數
protected override bool ProcessDialogKey(Keys keyData) { switch (keyData) { case Keys.Left: case Keys.Up: ShowPrevPicture(); return true; case Keys.Right: case Keys.Down: case Keys.Enter: ShowNextPicture(); return true; case Keys.Delete: DeleteCurrentPicutreFromHardDisk(); return true; case Keys.Subtract: DownImageLevel(PictureList.ElementAt(curIndex)); DeleteCurrentPicutureFromShowList(); return true; case Keys.Add: case Keys.Insert: UpImageLevel(PictureList.ElementAt(curIndex)); DeleteCurrentPicutureFromShowList(); return true; } return false; }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。