forked from ying32/govcl
/
LoginFormImpl.go
49 lines (42 loc) · 997 Bytes
/
LoginFormImpl.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
// 在这里写你的事件
package main
import (
"fmt"
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/types"
"github.com/ying32/govcl/vcl/types/keys"
)
func (f *TLoginForm) OnFormCreate(sender vcl.IObject) {
f.SetShowInTaskBar(types.StAlways)
}
func (f *TLoginForm) OnFormClose(sender vcl.IObject, action *types.TCloseAction) {
if !isLogin {
vcl.Application.Terminate()
}
}
func (f *TLoginForm) OnButtonLoginClick(sender vcl.IObject) {
usr := f.EditUserName.Text()
if usr == "" {
fmt.Println("输入用户名吧")
f.EditUserName.SetFocus()
return
}
pwd := f.EditPassword.Text()
if pwd == "" {
fmt.Println("输入密码吧。")
f.EditPassword.SetFocus()
return
}
if usr == "admin" && pwd == "admin" {
isLogin = true
f.Close()
//MainForm.Show()
vcl.Application.MainForm().Show()
}
}
func (f *TLoginForm) OnFormKeyPress(sender vcl.IObject, key *types.Char) {
fmt.Println("key:", *key)
if *key == keys.VkReturn {
f.ButtonLogin.Click()
}
}