Added Window.SetTitle(). Also oops, forgot to mark the window as created.
This commit is contained in:
parent
0a9f408129
commit
a9ff388944
5
main.go
5
main.go
|
@ -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
|
||||
|
|
|
@ -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
todo.md
1
todo.md
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue