-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1Impl.go
71 lines (58 loc) · 1.67 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
package main
import (
"fmt"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types/keys"
"github.com/energye/golcl/lcl/types"
)
//::private::
type TForm1Fields struct {
}
func (f *TForm1) OnFormCreate(sender lcl.IObject) {
fmt.Println(Form1.Caption(), f.PixelsPerInch())
// 遍历组件
// 只要owner设置为Form的都可以通过这个方法来遍历。
var i int32
for i = 0; i < f.ComponentCount(); i++ {
comp := f.Components(i)
//fmt.Println(i, "=", comp.Name())
if comp.Is().Memo() {
fmt.Println(i, "=", comp.Name(), ", 继承自TMemo")
mem := lcl.AsMemo(comp)
mem.SetOnKeyUp(f.memoOnKeyup)
}
}
}
func (f *TForm1) memoOnKeyup(sender lcl.IObject, key *types.Char, shift types.TShiftState) {
if shift.In(types.SsCtrl) && *key == /*keys.VkA*/ keys.VkB {
lcl.AsMemo(sender).SelectAll()
}
}
func (f *TForm1) OnActExitExecute(lcl.IObject) {
lcl.Application.Terminate()
}
func (f *TForm1) OnButton2Click(lcl.IObject) {
result := Form2.ShowModal()
if result == types.MrOk {
lcl.ShowMessage("Form2返回了OK")
} else if result == types.MrClose || result == types.MrNone {
lcl.ShowMessage("Form2返回了Close")
} else if result == types.MrCancel {
lcl.ShowMessage("Form2返回了Cancel")
}
}
func (f *TForm1) OnActFileNewExecute(lcl.IObject) {
lcl.ShowMessage("ActFileNew Execute.")
}
func (f *TForm1) OnFormCloseQuery(sender lcl.IObject, canClose *bool) {
fmt.Println("关闭。")
}
func (f *TForm1) OnCheckBox1Click(sender lcl.IObject) {
f.Button1.SetEnabled(f.CheckBox1.Checked())
}
func (f *TForm1) OnButton1Click(sender lcl.IObject) {
//lcl.ShowMessage("Hello!")
jpg := lcl.NewJPEGImage()
defer jpg.Free()
jpg.LoadFromFile("a.jpg")
}