-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcs.go
42 lines (34 loc) · 1.17 KB
/
funcs.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
package vcl
import (
"reflect"
"gitee.com/ying32/govcl/vcl/api"
"gitee.com/ying32/govcl/vcl/rtl"
. "gitee.com/ying32/govcl/vcl/types"
)
// ShowMessage 显示一个消息框
func ShowMessage(msg string) {
api.DShowMessage(msg)
}
// MessageDlg 消息框,Buttons为按钮样式,祥见types.TMsgDlgButtons
func MessageDlg(Msg string, DlgType TMsgDlgType, Buttons ...uint8) int32 {
return api.DMessageDlg(Msg, DlgType, TMsgDlgButtons(rtl.Include(0, Buttons...)), 0)
}
// CheckPtr 检测接口是否被实例化,如果已经实例化则返回实例指针
func CheckPtr(value IObject) uintptr {
if value == nil || reflect.ValueOf(value).Pointer() == 0 {
return 0
}
return value.Instance()
}
// SelectDirectory1 选择目录
func SelectDirectory1(options TSelectDirOpts) (bool, string) {
return api.DSelectDirectory1(options)
}
// SelectDirectory2 选择目录,一般 options默认是SdNewUI,parent默认为nil
func SelectDirectory2(caption, root string, options TSelectDirExtOpts, parent IObject) (bool, string) {
return api.DSelectDirectory2(caption, root, options, CheckPtr(parent))
}
// ThreadSync 主线程中执行
func ThreadSync(fn TThreadProc) {
api.DSynchronize(fn)
}