Skip to content

Commit

Permalink
1. The SelectDirectory2 parameter is changed, because it is no long…
Browse files Browse the repository at this point in the history
…er necessary to be compatible with Delphi.

2. Delete the `TSelectDirExtOpt` type and its enumeration value, because it is no longer necessary to be compatible with Delphi.
3. Delete the `TSelectDirExtOpts` type, because it is no longer necessary to be compatible with Delphi.
  • Loading branch information
ying32 committed Jul 9, 2020
1 parent d3548f6 commit a27005d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion samples/mp3Player/Form1Impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (f *TForm1) OnMIAddFileClick(sender vcl.IObject) {
}

func (f *TForm1) OnMIAddFolderClick(sender vcl.IObject) {
if ok, str := vcl.SelectDirectory2("选择目录", "", types.NewSet(types.SdNewUI, types.SdShowEdit), nil); ok {
if ok, str := vcl.SelectDirectory2("选择目录", "", false); ok {
f.addFoler(str)
}
}
Expand Down
3 changes: 1 addition & 2 deletions samples/sysdialog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ func main() {
btn.SetParent(mainForm)
btn.SetCaption("SelectDirectory2")
btn.SetOnClick(func(vcl.IObject) {
options := types.NewSet(types.SdNewFolder, types.SdShowEdit, types.SdNewUI)
if ok, dir := vcl.SelectDirectory2("标题了", "C:/", options, nil); ok {
if ok, dir := vcl.SelectDirectory2("标题了", "C:/", true); ok {
fmt.Println("选择的目录为:", dir)
}
})
Expand Down
5 changes: 2 additions & 3 deletions vcl/api/dfuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,9 @@ func DSelectDirectory1(options TSelectDirOpts) (bool, string) {
return false, ""
}

func DSelectDirectory2(caption, root string, options TSelectDirExtOpts, parent uintptr) (bool, string) {
func DSelectDirectory2(caption, root string, showHidden bool) (bool, string) {
var ptr uintptr
r, _, _ := dSelectDirectory2.Call(GoStrToDStr(caption), GoStrToDStr(root), uintptr(unsafe.Pointer(&ptr)),
uintptr(options), parent)
r, _, _ := dSelectDirectory2.Call(GoStrToDStr(caption), GoStrToDStr(root), GoBoolToDBool(showHidden), uintptr(unsafe.Pointer(&ptr)))
v := DBoolToGoBool(r)
if v {
return true, DStrToGoStr(ptr)
Expand Down
17 changes: 3 additions & 14 deletions vcl/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,9 @@ func SelectDirectory1(options TSelectDirOpts) (bool, string) {

// 选择目录,一般options默认是SdNewUI,parent默认为nil。
//
// Select directory, options defaults to SdNewUI, parent defaults to nil.
func SelectDirectory2(caption, root string, options TSelectDirExtOpts, parent IObject) (bool, string) {
return api.DSelectDirectory2(caption, root, options, CheckPtr(parent))
}

// 选择目录, options默认是SdNewUI,parent默认为nil。
//
// Select directory, options defaults to SdNewUI, parent defaults to nil.
func SelectDirectory3(caption, root string, options ...uint8) (bool, string) {
opts := NewSet(options...)
if len(options) == 0 {
opts = opts.Include(SdNewUI)
}
return SelectDirectory2(caption, root, opts, nil)
// Select directory.
func SelectDirectory2(caption, root string, showHidden bool) (bool, string) {
return api.DSelectDirectory2(caption, root, showHidden)
}

// 主线程中执行。
Expand Down
22 changes: 11 additions & 11 deletions vcl/types/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -1677,19 +1677,19 @@ type TSelectDirOpts = TSet

//TSelectDirExtOpt = (sdNewFolder, sdShowEdit, sdShowShares, sdNewUI, sdShowFiles,
//sdValidateDir);
type TSelectDirExtOpt int32

const (
SdNewFolder = iota + 0
SdShowEdit
SdShowShares
SdNewUI
SdShowFiles
SdValidateDir
)
//type TSelectDirExtOpt int32
//
//const (
// SdNewFolder = iota + 0
// SdShowEdit
// SdShowShares
// SdNewUI
// SdShowFiles
// SdValidateDir
//)

//TSelectDirExtOpts = set of TSelectDirExtOpt;
type TSelectDirExtOpts = TSet
//type TSelectDirExtOpts = TSet

// TFindOption
type TFindOption = uint32
Expand Down

0 comments on commit a27005d

Please sign in to comment.