Just spent some time scratching my head about programatically selecting items in listbox configured for multiple selections. Listbox->Select function doesn't work here, as it sends LB_SETCURSEL =390 message. I've found one must send LB_SETSEL = 389 message instead for multi listboxes.

Listbox->SendMessage( LB_SETSEL,1/0, index)
where: 1 - selects, 0 - deselects

reference: http://www.pietschsoft.com/programming/vbapi/ref/l/lb_setsel.html or MSDN

LB_SETSEL: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listboxes/listboxreference/listboxmessages/lb_setsel.asp LB_SETCURSEL: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listboxes/listboxreference/listboxmessages/lb_setcursel.asp

It would be nice to implement this in WIN32::GUI. Or at least update the documentation, to say 'Select' only works for single-selection listboxes.

Matej Fundarek


Reply via email to