From a27005d97a589c361b73581cf890724cbf2712d6 Mon Sep 17 00:00:00 2001 From: ying32 Date: Fri, 10 Jul 2020 00:19:21 +0800 Subject: [PATCH] 1. The `SelectDirectory2` parameter is changed, because it is no longer 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. --- samples/mp3Player/Form1Impl.go | 2 +- samples/sysdialog/main.go | 3 +-- vcl/api/dfuncs.go | 5 ++--- vcl/funcs.go | 17 +++-------------- vcl/types/enums.go | 22 +++++++++++----------- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/samples/mp3Player/Form1Impl.go b/samples/mp3Player/Form1Impl.go index cecabecc..5c007927 100644 --- a/samples/mp3Player/Form1Impl.go +++ b/samples/mp3Player/Form1Impl.go @@ -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) } } diff --git a/samples/sysdialog/main.go b/samples/sysdialog/main.go index d7b0c9c2..22a70e18 100644 --- a/samples/sysdialog/main.go +++ b/samples/sysdialog/main.go @@ -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) } }) diff --git a/vcl/api/dfuncs.go b/vcl/api/dfuncs.go index d2b212a2..c10e4dce 100644 --- a/vcl/api/dfuncs.go +++ b/vcl/api/dfuncs.go @@ -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) diff --git a/vcl/funcs.go b/vcl/funcs.go index 04793b0c..fb2fd4c8 100644 --- a/vcl/funcs.go +++ b/vcl/funcs.go @@ -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) } // 主线程中执行。 diff --git a/vcl/types/enums.go b/vcl/types/enums.go index d71131a1..32c902d2 100644 --- a/vcl/types/enums.go +++ b/vcl/types/enums.go @@ -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