-
Notifications
You must be signed in to change notification settings - Fork 229
/
Form1Impl.go
130 lines (102 loc) · 3.27 KB
/
Form1Impl.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package main
import (
"fmt"
"strconv"
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/types"
)
//::private::
type TForm1Fields struct {
}
func (f *TForm1) OnFormCreate(object vcl.IObject) {
fmt.Println("OnForm1Create被调用了:", object.Instance())
vcl.Application.SetTitle("我是新标题")
f.SetKeyPreview(true)
f.Edit2.SetText("1")
f.Edit2.SetNumbersOnly(true)
f.ActFileNew.SetCaption("我是一个共享的动作")
}
func (f *TForm1) OnButton1Click(object vcl.IObject) {
fmt.Println("f:", f.Button1.Name())
fmt.Println("窗口1的Button1单击")
img := vcl.NewJPEGImage()
defer img.Free()
img.LoadFromFile("111.jpg")
}
func (f *TForm1) OnButton2Click(object vcl.IObject) {
fmt.Println("f:", f.Button2.Name(), "xxx:", object.ClassName())
fmt.Println("窗口1的Button2单击")
result := Form2.ShowModal()
if result == types.MrOk {
vcl.ShowMessage("Form2返回了OK")
} else if result == types.MrClose || result == types.MrNone {
vcl.ShowMessage("Form2返回了Close")
} else if result == types.MrCancel {
vcl.ShowMessage("Form2返回了Cancel")
}
}
func (f *TForm1) OnActExitExecute(sender vcl.IObject) {
vcl.Application.Terminate()
}
func (f *TForm1) OnActFileNewExecute(sender vcl.IObject) {
vcl.ShowMessage("ActFileNew Execute.")
}
func (f *TForm1) OnCheckBox1Click(sender vcl.IObject) {
f.Button1.SetEnabled(f.CheckBox1.Checked())
}
func (f *TForm1) OnFormClick(sender vcl.IObject) {
fmt.Println("OnForm1Click")
}
func (f *TForm1) OnFormDestroy(sender vcl.IObject) {
fmt.Println("OnForm1Destroy")
}
func (f *TForm1) OnFormKeyDown(sender vcl.IObject, key *types.Char, shift types.TShiftState) {
fmt.Println("OnForm1KeyDown:", *key, ", ", shift)
}
func (f *TForm1) OnFormMouseDown(sender vcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
fmt.Println("OnForm1MouseDown:", button, ", ", shift, ", ", x, ", ", y)
}
func (f *TForm1) OnFormCloseQuery(sender vcl.IObject, canClose *bool) {
fmt.Println("OnForm1CloseQuery")
//*canClose = false
}
func (f *TForm1) OnFormClose(sender vcl.IObject, action *types.TCloseAction) {
fmt.Println("OnForm1Close")
//*canClose = false
}
func (f *TForm1) OnApplicationException(sender vcl.IObject, e *vcl.Exception) {
fmt.Println("OnApplicationException")
vcl.ShowMessage(e.Message())
}
func (f *TForm1) OnApplicationMinimize(sender vcl.IObject) {
fmt.Println("OnApplicationMinimize")
}
func (f *TForm1) OnApplicationRestore(sender vcl.IObject) {
fmt.Println("OnApplicationRestore")
}
func (f *TForm1) OnComboBox1Change(sender vcl.IObject) {
fmt.Println("OnComboBox1Change: ", f.ComboBox1.ItemIndex())
}
func (f *TForm1) OnImageButton1Click(sender vcl.IObject) {
vcl.ShowMessage("查杀,查杀,我查。。。")
}
func (f *TForm1) OnEdit2Change(sender vcl.IObject) {
val, _ := strconv.Atoi(f.Edit2.Text())
if val >= 0 && val <= 100 {
f.Gauge1.SetProgress(int32(val))
}
}
func (f *TForm1) OnMemo1Click(vcl.IObject) {
fmt.Println("OnMemo1Click")
}
func (f *TForm1) OnListView1Click(vcl.IObject) {
idx := f.ListView1.ItemIndex()
if idx != -1 {
item := f.ListView1.Items().Item(idx)
fmt.Println(item.Caption())
fmt.Println("subitem:", item.SubItems().Text())
}
}
//func (f *TForm1) OnApplicationHint(sender vcl.IObject) {
// fmt.Println("提示了:", vcl.Application.Hint())
//}