我想弄清楚mouseWheel事件在winforms库中是如何工作的.
虽然在谈到时没有任何好的例子可供学习 F#
我希望你们其中一个人能告诉我.
我在想这样的事情:
onMouseWheelEvent = if MouseWheel event = scroll forward then printfn "zooming in" else printfn "zooming out"
我知道这是我发布的一些愚蠢的代码,但我真的无法找到任何关于winforms mousewheelevent的东西,除了它存在.它的工作原理仍然是一个谜.
提前致谢.
尝试在f#interactive中运行它(由Tomas Petricek的fssnip上的类似示例提供):
open System.Windows.Forms // Create form, label and add label to form let form = new Form(Text = "Scroller Test") let label = new Label() form.Controls.Add(label) // register mousewheel event handler and capture scrolling form.MouseWheel.Add(fun e -> match e.Delta with | n when n > 0 -> label.Text <- "Scrolled up" | n when n < 0 -> label.Text <- "Scrolled down" | _ -> ()) // making compiler happy even though e.Delta cannot be 0 // Show the form (in F# Interactive) form.Show()