示例#1
0
func (lb *ListBox) Get(i int) (text string, selected bool) {
	bufSize := 256
	buffer := make([]uint16, bufSize)
	w32.SendMessage(lb.handle, w32.LB_GETTEXT, uintptr(i), uintptr(unsafe.Pointer(&buffer[0])))

	text = syscall.UTF16ToString(buffer)
	selected = w32.SendMessage(lb.handle, w32.LB_GETSEL, uintptr(i), 0) != 0

	return
}
示例#2
0
func (lb *ListBox) Delete(i int) {
	_, sel := lb.GetSelection()

	w32.SendMessage(lb.handle, w32.LB_DELETESTRING, uintptr(i), 0)

	switch {
	case sel == -1:
		return
	case sel == i:
		lb.SetSelection(-1)
	case sel < i:
		lb.SetSelection(sel)
	case sel > i:
		lb.SetSelection(sel - 1)
	}
}
示例#3
0
func (c *control) setFont(f w32.HFONT) {
	w32.SendMessage(c.handle, w32.WM_SETFONT, uintptr(f), w32.MAKELONG(1, 0))
}
示例#4
0
func (lb *ListBox) Count() int {
	return int(w32.SendMessage(lb.handle, w32.LB_GETCOUNT, 0, 0))
}
示例#5
0
func (lb *ListBox) SetSelection(i int) {
	w32.SendMessage(lb.handle, w32.LB_SETCURSEL, uintptr(i), 0)
}
示例#6
0
func (lb *ListBox) Append(t string) int {
	tptr, _ := syscall.UTF16PtrFromString(t)
	w32.SendMessage(lb.handle, w32.LB_ADDSTRING, 0, uintptr(unsafe.Pointer(tptr)))
	return lb.Count() - 1
}
示例#7
0
func (lb *ListBox) Clear() {
	w32.SendMessage(lb.handle, w32.LB_RESETCONTENT, 0, 0)
}
示例#8
0
func (w *Window) SetIcon(icon Icon) {
	w32.SendMessage(w.handle, w32.WM_SETICON, w32.ICON_BIG, uintptr(icon))
	w32.SendMessage(w.handle, w32.WM_SETICON, w32.ICON_SMALL, uintptr(icon))
	w32.SendMessage(w.handle, w32.WM_SETICON, w32.ICON_SMALL2, uintptr(icon))
}