harryjph / go-common-file-dialog Goto Github PK
View Code? Open in Web Editor NEWWindows Common File Dialog bindings for Go
License: MIT License
Windows Common File Dialog bindings for Go
License: MIT License
Firstly, thanks for a superb project!
I've noticed that as the HWND isn't specified, it can sometime appear beneath my application window. How easy would it be to add a method to set the parent HWND? Perhaps as a property on cfd.DialogConfig
? Cheers.
I'm trying to create an small application providing a file chooser, and I saw an unexpected error only on 386 binary running on Windows 10 64bit.
An amd64 binary built from the same source running on Windows 10 64bit works as expected.
Should this error be tracked on this project? Or, should I report this to other place?
Thanks,
Prepare a golang development environment. I'm using go1.16.6 linux/amd64 on Ubuntu on WSL1 on Windows 10.
Create testcase.go
under a directory, as:
package main
import (
"github.com/harry1453/go-common-file-dialog/cfd"
"github.com/harry1453/go-common-file-dialog/cfdutil"
"log"
)
func main() {
result, err := cfdutil.ShowOpenFileDialog(cfd.DialogConfig{
Title: "Title",
Role: "TestCaseRole",
FileFilters: []cfd.FileFilter{
{
DisplayName: "File",
Pattern: "*.*",
},
},
SelectedFileFilterIndex: 0,
FileName: "file",
DefaultExtension: ".txt",
})
log.Fatal(err)
log.Fatal(result)
}
Start bash on Ubuntu on WSL1.
Change working directory to the directory testcase.go
placed at.
Run gox -os="windows" .
to build binaries.
Then two binaries golang-testcase_windows_amd64.exe
and golang-testcase_windows_386.exe
are built.
Start cmd.exe
on Windows.
Run golang-testcase_windows_amd64.exe
on the command prompt. A file chooser dialog appears, so close it.
Run golang-testcase_windows_386.exe
on the command prompt.
A file chooser dialog appears, same as golang-testcase_windows_amd64.exe
.
No dialog appears and an error:
C:\Users\piro>>C:\Users\piro\golang-testcase_windows_386.exe
Exception 0xc0000005 0x0 0x140d8b64 0x779cef90
PC=0x779cef90
syscall.Syscall(0x75d08a90, 0x2, 0x1222df0, 0x1, 0x11c06290, 0x0, 0x0, 0x0)
/usr/local/go/src/runtime/syscall_windows.go:330 +0xbb
github.com/harry1453/go-common-file-dialog/cfd.(*iFileDialogVtbl).setFileTypes(0x75cc18b4, 0x1222df0, 0x11c04180, 0x1, 0x1, 0x1, 0x31d44c50)
/home/piro/go/src/github.com/harry1453/go-common-file-dialog/cfd/vtblCommonFunc.go:51 +0x11e
github.com/harry1453/go-common-file-dialog/cfd.(*iFileOpenDialog).SetFileFilters(0x1222df0, 0x11c04180, 0x1, 0x1, 0x1222df0, 0x11c06201)
/home/piro/go/src/github.com/harry1453/go-common-file-dialog/cfd/iFileOpenDialog.go:104 +0x41
github.com/harry1453/go-common-file-dialog/cfd.(*DialogConfig).apply(0x11c5deb8, 0x410754, 0x1222df0, 0x0, 0x0)
/home/piro/go/src/github.com/harry1453/go-common-file-dialog/cfd/DialogConfig.go:99 +0xef
github.com/harry1453/go-common-file-dialog/cfd.NewOpenFileDialog(0x3e659e, 0x5, 0x3e7965, 0xc, 0x0, 0x0, 0x0, 0x0, 0x11c04180, 0x1, ...)
/home/piro/go/src/github.com/harry1453/go-common-file-dialog/cfd/CommonFileDialog_windows.go:20 +0x76
github.com/harry1453/go-common-file-dialog/cfdutil.ShowOpenFileDialog(0x3e659e, 0x5, 0x3e7965, 0xc, 0x0, 0x0, 0x0, 0x0, 0x11c04180, 0x1, ...)
/home/piro/go/src/github.com/harry1453/go-common-file-dialog/cfdutil/CFDUtil.go:9 +0x68
main.main()
/home/piro/testcase.go:16 +0x8e
eax 0x140d8b64
ebx 0x0
ecx 0x1222de4
edx 0x140d8b66
edi 0x140d8b64
esi 0x0
ebp 0x10ff9d8
esp 0x10ff9d4
eip 0x779cef90
eflags 0x10202
cs 0x23
fs 0x53
gs 0x2b
C:\Users\piro>
I've not tested this on 32bit Windows environment yet.
Currently, if the user presses cancel or closes a dialog, it returns an error with the text "cancelled by user". It would be great if Show()
returned a flag indicating if it was cancelled. I realise this would be an API breaking change!
Added here wailsapp/wails#2814
Ola, when using this module, it seems that cfd.ErrorCancelled is no longer supported:
if err == cfd.ErrorCancelled { //<--- ErrorCancelled not declared by package cfdcompiler[UndeclaredImportedName]
log.Fatal("Dialog was cancelled by the user.")
}
Is there an alternative way to check if a dialog was cancelled?
It could just be a mistake on my end, this is literally my first go project
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.