From 8e2f3b136e041705098f9f8d11941c33f785258a Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 12 Feb 2014 21:28:58 -0500 Subject: [PATCH] Adjusted sysData.make() to make the new window class and fixed main(). Now to fix compiler errors... --- main.go | 5 ++--- sysdata_windows.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 273a13a..411eb36 100644 --- a/main.go +++ b/main.go @@ -5,8 +5,7 @@ func main() { w := NewWindow("Main Window", 320, 240) w.Closing = make(chan struct{}) b := NewButton("Click Me") - w.SetControl(b) - err := w.Open() + err := w.Open(b) if err != nil { panic(err) } @@ -22,6 +21,6 @@ mainloop: } } } - w.Close() + w.Hide() } diff --git a/sysdata_windows.go b/sysdata_windows.go index fc6b8c8..ab65879 100644 --- a/sysdata_windows.go +++ b/sysdata_windows.go @@ -30,7 +30,6 @@ const controlxstyle = 0 var classTypes = [nctypes]*classData{ c_window: &classData{ - name: stdWndClass, style: _WS_OVERLAPPEDWINDOW, xstyle: 0, }, @@ -59,17 +58,24 @@ func (s *sysData) make(initText string, initWidth int, initHeight int, window *s ret := make(chan uiret) defer close(ret) ct := classTypes[s.ctype] + classname := ct.name cid := _HMENU(0) pwin := uintptr(_NULL) if window != nil { // this is a child control cid = window.addChild(s) pwin = uintptr(window.hwnd) + } else { // need a new class + n, err := registerStdWndClass(s) + if err != nil { + return r.err + } + classname = n } uitask <- &uimsg{ call: _createWindowEx, p: []uintptr{ uintptr(ct.xstyle), - uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(ct.name))), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(classname))), uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(initText))), uintptr(ct.style), uintptr(_CW_USEDEFAULT), // TODO