From cb4d28cc1cb0e29990e0081fe1245620f3aab955 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 18 Aug 2014 19:01:56 -0400 Subject: Added OpenFile(), the first dialog to be added, and implemented it on Windows... mostly. --- redo/dialog_windows.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 redo/dialog_windows.go (limited to 'redo/dialog_windows.go') diff --git a/redo/dialog_windows.go b/redo/dialog_windows.go new file mode 100644 index 0000000..0346f56 --- /dev/null +++ b/redo/dialog_windows.go @@ -0,0 +1,33 @@ +// 18 august 2014 + +package ui + +import ( + "syscall" + "unsafe" + "reflect" +) + +// #include "winapi_windows.h" +import "C" + +// TODO move to common_windows.go +func wstrToString(wstr *C.WCHAR) string { + n := C.wcslen((*C.wchar_t)(unsafe.Pointer(wstr))) + xbuf := &reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(wstr)), + Len: int(n + 1), + Cap: int(n + 1), + } + buf := (*[]uint16)(unsafe.Pointer(xbuf)) + return syscall.UTF16ToString(*buf) +} + +func openFile() string { + name := C.openFile() + if name == nil { + return "" + } + defer C.free(unsafe.Pointer(name)) + return wstrToString(name) +} -- cgit v1.2.3