First attempt at running WPF libui in Go just to have fun. It fails :(

This commit is contained in:
Pietro Gagliardi 2015-11-25 16:48:21 -05:00
parent 0e0c314bea
commit 554cd31fa2
3 changed files with 35 additions and 0 deletions

BIN
wpf/libui.dll Executable file

Binary file not shown.

BIN
wpf/xtest.exe Executable file

Binary file not shown.

35
wpf/xtest.go Normal file
View File

@ -0,0 +1,35 @@
// 25 november 2015
package main
import "fmt"
import "runtime"
import "syscall"
import "unsafe"
var libui = syscall.NewLazyDLL("libui.dll")
var uiInit = libui.NewProc("uiInit")
var uiNewWindow = libui.NewProc("uiNewWindow")
var uiWindowOnClosing = libui.NewProc("uiWindowOnClosing")
var uiControlShow = libui.NewProc("uiControlShow")
var uiMain = libui.NewProc("uiMain")
var uiQuit = libui.NewProc("uiQuit")
var uiUninit = libui.NewProc("uiUninit")
func onClosing(w uintptr, data uintptr) int32 {
fmt.Println("in closing")
uiQuit.Call()
return 1
}
func main() {
runtime.LockOSThread()
b := make([]byte, 256) // to compensate for uiInitOptions
e, _, _ := uiInit.Call(uintptr(unsafe.Pointer(&b[0])))
if e != 0 { panic(e) }
s := "Hello from Go"
w, _, _ := uiNewWindow.Call(
uintptr(unsafe.Pointer(&s)),
320, 240, 0)
uiWindowOnClosing.Call(w, syscall.NewCallbackCDecl(onClosing), 0)
uiControlShow.Call(w)
uiMain.Call(w)
fmt.Println("after main")
uiUninit.Call(w)
fmt.Println("out")
}