From: Johan L. <jo...@ba...> - 2001-06-15 11:57:53
|
Henning wrote: >HOWEVER, if I remove the -multisel statement from the ListBox >defintion, items *do* get selected (only one at a time, though, >obviously)! Is this a bug? And is there a known workaround for it? >Surely I cannot be the first person to try selecting multiple >items from within program code! :-) Working piece of code: ---------- =head2 controlSelect() Sync the ListBox with the selected controls. Return 1 on success, else 0. =cut sub controlSelect { my $self = shift; my $pkg = ref($self); my $check = ( keys %{$self->objCanvas()->rhControlSelected()} ) ? 0 : 1; $self->winMain()->lbControl()->SendMessage(0x0185, $check, 0); #LB_SETSEL my $i = 1; for my $objControl (@{$self->objDesign()->raControl()}) { $self->winMain()->lbControl()->SendMessage(0x0185, $objControl->designIsSelected(), $i); #LB_SETSEL $i++; } return(1); } ---------- It appears that selecting a single line vs. multiple lines are two different things. Look at the SendMessage call. Note: The index is 0-based, I just manage the first item in my list separate from the others. Ideally, this should go into a single sub and eventually into Win32::GUI. Spreading custom messages and constants in your program is both unreadable and bad for maintenance in the long run. /J ------ ---- --- -- -- -- - - - - - Johan Lindström Boss Casinos Sourcerer jo...@ba... http://www.bahnhof.se/~johanl/ If the only tool you have is a hammer, everything tends to look like a nail |