All build errors resolved. Now to test...

This commit is contained in:
Pietro Gagliardi 2014-02-11 19:18:03 -05:00
parent ecb2205e02
commit 73fa611b37
5 changed files with 18 additions and 10 deletions

View File

@ -1,4 +1,5 @@
// 10 february 2014
//package ui
package main
import (
@ -8,5 +9,5 @@ import (
// Menu notifications.
const (
WM_COMMAND = 0x0111
_WM_COMMAND = 0x0111
)

View File

@ -42,7 +42,7 @@ func stdWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESUL
uintptr(uMsg),
uintptr(wParam),
uintptr(lParam))
return LRESULT(r1)
return _LRESULT(r1)
}
panic(fmt.Sprintf("stdWndProc message %d did not return: internal bug in ui library", uMsg))
}
@ -66,18 +66,21 @@ func registerStdWndClass() (err error) {
_IDC_ARROW = 32512
)
icon, err := user32.NewProc("LoadIconW").Call(
r1, _, err := user32.NewProc("LoadIconW").Call(
uintptr(_NULL),
uintptr(_IDI_APPLICATION))
if err != nil {
return fmt.Errorf("error getting window icon: %v", err)
}
cursor, err := user32.NewProc("LoadCursorW").Call(
icon := _HANDLE(r1)
r1, _, err = user32.NewProc("LoadCursorW").Call(
uintptr(_NULL),
uintptr(_IDC_ARROW))
if err != nil {
return fmt.Errorf("error getting window cursor: %v", err)
}
cursor := _HANDLE(r1)
wc := &_WNDCLASS{
lpszClassName: syscall.StringToUTF16Ptr(stdWndClass),
@ -88,7 +91,7 @@ func registerStdWndClass() (err error) {
hbrBackground: _HBRUSH(_COLOR_BTNFACE + 1),
}
r1, _, err := user32.NewProc("RegisterClassW").Call(uintptr(unsafe.Pointer(wc)))
r1, _, err = user32.NewProc("RegisterClassW").Call(uintptr(unsafe.Pointer(wc)))
if r1 == 0 { // failure
return fmt.Errorf("error registering class: %v", err)
}

View File

@ -46,7 +46,7 @@ func (s *sysData) make() (err error) {
p: []uintptr{
uintptr(ct.xstyle),
ct.name,
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s.title))),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s.text))),
uintptr(ct.style),
uintptr(_CW_USEDEFAULT), // TODO
uintptr(_CW_USEDEFAULT),

View File

@ -31,7 +31,7 @@ func ui(initDone chan error) {
go msgloop()
for m := range uitask {
r1, _, err := m.msg.Call(m.p...)
r1, _, err := m.call.Call(m.p...)
m.ret <- uiret{
ret: r1,
err: err,
@ -47,6 +47,8 @@ var (
_translateMessage = user32.NewProc("TranslateMessage")
)
var getMessageFail = -1 // because Go doesn't let me
func msgloop() {
runtime.LockOSThread()
@ -60,7 +62,7 @@ func msgloop() {
}
for {
r1, _, err := getMessage.Call(
r1, _, err := _getMessage.Call(
uintptr(unsafe.Pointer(&msg)),
uintptr(_NULL),
uintptr(0),

View File

@ -24,8 +24,10 @@ type Window struct {
func NewWindow(title string) *Window {
return &Window{
sysData: &sysData{
ctype: c_window,
text: title,
cSysData: cSysData{
ctype: c_window,
text: title,
},
},
}
}