List DefaultItems (windows).
This commit is contained in:
parent
7d3236562f
commit
589e1b5b01
3 changed files with 13 additions and 2 deletions
|
@ -52,6 +52,8 @@ const (
|
|||
WM_USER = 0x0400
|
||||
EM_SETSEL = 0x00b1
|
||||
LB_ADDSTRING = 0x0180
|
||||
LB_SETSEL = 0x0185
|
||||
LB_SETCURSEL = 0x0186
|
||||
LB_GETCURSEL = 0x0188
|
||||
LB_GETSELCOUNT = 0x0190
|
||||
LB_GETSELITEMS = 0x0191
|
||||
|
|
2
list.go
2
list.go
|
@ -52,7 +52,7 @@ const (
|
|||
radioListKind
|
||||
)
|
||||
|
||||
// DefaultItems returns an Option to set the items to initially select (macOS only).
|
||||
// DefaultItems returns an Option to set the items to initially select (Windows and macOS only).
|
||||
func DefaultItems(items ...string) Option {
|
||||
return funcOption(func(o *options) { o.defaultItems = items })
|
||||
}
|
||||
|
|
|
@ -107,8 +107,17 @@ func (dlg *listDialog) setup(text string, opts options) ([]string, error) {
|
|||
12, 206, 75, 24, dlg.wnd, win.IDNO, instance, nil)
|
||||
}
|
||||
|
||||
for _, item := range dlg.items {
|
||||
for i, item := range dlg.items {
|
||||
win.SendMessagePointer(dlg.listCtl, win.LB_ADDSTRING, 0, unsafe.Pointer(strptr(item)))
|
||||
for _, def := range opts.defaultItems {
|
||||
if def == item {
|
||||
if dlg.multiple {
|
||||
win.SendMessage(dlg.listCtl, win.LB_SETSEL, 1, uintptr(i))
|
||||
} else {
|
||||
win.SendMessage(dlg.listCtl, win.LB_SETCURSEL, uintptr(i), 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dlg.layout(getDPI(dlg.wnd))
|
||||
|
|
Loading…
Reference in a new issue