/
main.go
70 lines (55 loc) · 1.38 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"github.com/ying32/govcl/vcl"
"fmt"
_ "github.com/ying32/govcl/pkgs/winappres"
"github.com/ying32/govcl/vcl/types"
)
type TMainForm struct {
*vcl.TForm
Button1 *vcl.TButton
}
type TForm1 struct {
*vcl.TForm
Button1 *vcl.TButton
}
var (
mainForm *TMainForm
form1 *TForm1
)
func main() {
vcl.RunApp(&mainForm, &form1)
}
// --------------MainForm -----------------
func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
f.SetCaption("Hello")
f.EnabledMaximize(false)
f.SetWidth(300)
f.SetHeight(200)
f.ScreenCenter()
f.Button1 = vcl.NewButton(f)
f.Button1.SetParent(f)
f.Button1.SetCaption("窗口1")
f.Button1.SetLeft(50)
f.Button1.SetTop(50)
f.Button1.SetOnClick(f.OnButton1Click)
}
func (f *TMainForm) OnFormCloseQuery(Sender vcl.IObject, CanClose *bool) {
*CanClose = vcl.MessageDlg("是否退出?", types.MtConfirmation, types.MbYes, types.MbNo) == types.IdYes
}
func (f *TMainForm) OnButton1Click(object vcl.IObject) {
form1.Show()
}
// ---------- Form1 ----------------
func (f *TForm1) OnFormCreate(sender vcl.IObject) {
fmt.Println("onCreate")
f.Button1 = vcl.NewButton(f)
fmt.Println("f.Button1:", f.Button1.Instance())
f.Button1.SetParent(f)
//f.Button1.SetName("Button1")
f.Button1.SetCaption("我是按钮")
f.Button1.SetOnClick(f.OnButton1Click)
}
func (f *TForm1) OnButton1Click(object vcl.IObject) {
vcl.ShowMessage("Click")
}