|
The following is a hello world WinForms example:
open System
open System.Windows.Forms
let form = new Form()
do form.Width <- 400
do form.Height <- 300
do form.Text <- "Hello World Form"
(* Menu bar, menus *)
let mMain = form.Menu <- new MainMenu()
let mFile = form.Menu.MenuItems.Add("&File")
let miQuit = new MenuItem("&Quit")
let _ = mFile.MenuItems.Add(miQuit)
(* RichTextView *)
let textB = new RichTextBox()
do textB.Dock <- DockStyle.Fill
do textB.Text <- "Hello World\n\nCongratulations!"
do form.Controls.Add(textB)
(* callbacks *)
let opExitForm sender args = form.Close ()
do miQuit .add_Click (new EventHandler(opExitForm))
(* run! *)
do Application.Run(form)
If you save the above as
\dev\src\helloforms.fs
then assuming fsc is in your path, you can compile and run it as follows:
cd \dev\src
fsc \dev\src\helloforms.fs
helloforms.exe
|