diff options
| author | Pietro Gagliardi <[email protected]> | 2014-02-12 18:14:37 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-02-12 18:14:37 -0500 |
| commit | a9ff38894408e0a34da4742fc2b1aea0bb5ef60b (patch) | |
| tree | 2c4e58eb079cdd59537216943fc97fdd4fbd7a2d | |
| parent | 0a9f40812950ad00239e93141a37183666d5f3eb (diff) | |
Added Window.SetTitle(). Also oops, forgot to mark the window as created.
| -rw-r--r-- | main.go | 5 | ||||
| -rw-r--r-- | sysdata.go | 3 | ||||
| -rw-r--r-- | sysdata_windows.go | 18 | ||||
| -rw-r--r-- | todo.md | 1 | ||||
| -rw-r--r-- | window.go | 3 | ||||
| -rw-r--r-- | windows_windows.go | 1 |
6 files changed, 29 insertions, 2 deletions
@@ -16,7 +16,10 @@ mainloop: case <-w.Closing: break mainloop case <-b.Clicked: - println("clicked") + err := w.SetTitle("Button Clicked") + if err != nil { + panic(err) + } } } w.Close() @@ -25,6 +25,9 @@ func (c *cSysData) show() error { func (c *cSysData) hide() error { panic(runtime.GOOS + " sysData does not define hide()") } +func (c *cSysData) setText(text string) error { + panic(runtime.GOOS + " sysData does not define setText()") +} const ( c_window = iota diff --git a/sysdata_windows.go b/sysdata_windows.go index 586b320..9be3007 100644 --- a/sysdata_windows.go +++ b/sysdata_windows.go @@ -143,3 +143,21 @@ func (s *sysData) hide() (err error) { <-ret return nil } + +func (s *sysData) setText(text string) error { + ret := make(chan uiret) + defer close(ret) + uitask <- &uimsg{ + call: _setWindowText, + p: []uintptr{ + uintptr(s.hwnd), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))), + }, + ret: ret, + } + r := <-ret + if r.ret == 0 { // failure + return r.err + } + return nil +} @@ -1,6 +1,7 @@ so I don't forget: - Window.SizeToFit() or WIndow.OptimalSize() (use: `Window.SetSize(Window.OptimalSize())`) for sizing a window to the control's interest - Control.Show()/Control.Hide() +- Control.SetText() super ultra important things: - the windows build appears to be unstable: @@ -56,7 +56,7 @@ func (w *Window) SetTitle(title string) (err error) { defer w.lock.Unlock() if w.created { - panic("TODO") + return w.sysData.setText(title) } w.initTitle = title return nil @@ -93,6 +93,7 @@ func (w *Window) Open() (err error) { return err } } + w.created = true } return w.sysData.show() } diff --git a/windows_windows.go b/windows_windows.go index a8eb169..16f451d 100644 --- a/windows_windows.go +++ b/windows_windows.go @@ -170,6 +170,7 @@ var ( _getClientRect = user32.NewProc("GetClientRect") _enumChildWindows = user32.NewProc("EnumChildWindows") _setWindowPos = user32.NewProc("SetWindowPos") + _setWindowText = user32.NewProc("SetWindowTextW") _showWindow = user32.NewProc("ShowWindow") ) |
