2014-07-12 10:29:54 -05:00
|
|
|
// 12 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"syscall"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2014-07-17 18:36:24 -05:00
|
|
|
// #cgo LDFLAGS: -luser32 -lkernel32 -lgdi32
|
|
|
|
// #include "winapi_windows.h"
|
|
|
|
import "C"
|
2014-07-12 10:29:54 -05:00
|
|
|
|
2014-07-17 18:36:24 -05:00
|
|
|
var msgwin C.HWND
|
2014-07-12 10:29:54 -05:00
|
|
|
|
|
|
|
func uiinit() error {
|
2014-07-17 21:33:03 -05:00
|
|
|
var errmsg *C.char
|
|
|
|
|
|
|
|
errcode := C.initWindows(&errmsg)
|
|
|
|
if errcode != 0 || errmsg != nil {
|
|
|
|
return fmt.Errorf("error initializing package ui on Windows: %s: %v", C.GoString(errmsg), syscall.Errno(errcode))
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|
2014-07-17 17:04:51 -05:00
|
|
|
if err := initCommonControls(); err != nil {
|
|
|
|
return fmt.Errorf("error initializing comctl32.dll version 6: %v", err)
|
|
|
|
}
|
2014-07-12 10:29:54 -05:00
|
|
|
if err := makemsgwin(); err != nil {
|
|
|
|
return fmt.Errorf("error creating message-only window: %v", err)
|
|
|
|
}
|
|
|
|
if err := makeWindowWindowClass(); err != nil {
|
|
|
|
return fmt.Errorf("error creating Window window class: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func uimsgloop() {
|
2014-07-17 18:36:24 -05:00
|
|
|
C.uimsgloop()
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-07-13 00:14:55 -05:00
|
|
|
func uistop() {
|
|
|
|
f_PostQuitMessage(0)
|
|
|
|
}
|
|
|
|
|
2014-07-12 10:29:54 -05:00
|
|
|
func issue(req *Request) {
|
2014-07-17 18:36:24 -05:00
|
|
|
C.issue(unsafe.Pointer(req))
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func makemsgwin() error {
|
2014-07-17 18:36:24 -05:00
|
|
|
var errmsg *C.char
|
2014-07-12 10:29:54 -05:00
|
|
|
|
2014-07-17 18:36:24 -05:00
|
|
|
err := C.makemsgwin(&errmsg)
|
|
|
|
if err != 0 || errmsg != nil {
|
|
|
|
return fmt.Errorf("%s: %v", C.GoString(errmsg), syscall.Errno(err))
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2014-07-17 18:36:24 -05:00
|
|
|
//export xperform
|
|
|
|
func xperform(xreq unsafe.Pointer) {
|
|
|
|
req := (*Request)(xreq)
|
|
|
|
perform(req)
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|