F# windowsforms application with custom class

116 views Asked by At

I have a button class derived from Button()
with position attribute

namespace fgame15

open System
open System.Windows.Forms
open System.Drawing

module Game15Button =
   type Game15Button(position:Point) as button =
      inherit Button()
      member this.Pozition = position

This is my main module that shows a form
It is compiling without any errors, but
not displayed form with button

namespace fgame15

open System
open System.Drawing
open System.Windows.Forms

module Main = 
 do
    let form = new Form(BackColor = Color.Pink , Text = "My Window Application")
    let btn=new Button()
    btn.Text <- "Ok"
    form.Controls.Add(btn)
    Application.Run(form)

Prints the following warning

Warning 1   Main module of program is empty: nothing will happen when it is run
1

There are 1 answers

0
Danny Tuppeny On BEST ANSWER

If this is not your last file fs in the project, it will not execute when the app starts. You can re-order files using Alt+Up/Alt+Down in VS, or using the context menu on each file.