Multi-list behavior under win32lib
- Posted by jjnick at cvn.com Apr 22, 2001
- 390 views
This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C0CB8F.EE79DEA0 boundary="----=_NextPart_001_0008_01C0CB8F.EE79DEA0" ------=_NextPart_001_0008_01C0CB8F.EE79DEA0 charset="iso-8859-1" I am confident the following is a problem with win32lib (has this been = fixed in later version of win32lib, I am using v0.50)? Here is the sample code for those worried about viruses: -- Under win32lib v0.50, the following behavior occurs using = multi-select list boxes . . . --=20 -- Gathering whether a user selected items in a multi-select list box = gives -- erroneous info using provided functions in win32lib. Running the = sample below showcases -- this behavior. The ability to check whether or not a user has = selected anything is -- because if this is not done before accessing the getMultItems(), an = error occurs -- within win32lib. -- -- getIndex() works fine in a single select list box. --=20 -- Please note: LB_GETANCHORINDEX works initially, but once an item is = selected and then -- deselected, LB_ANCHORINDEX remembers previous item = selected and returns result include win32lib.ew without warning constant Win =3D create ( Window, "Showcase Multi-List problem", = 0, Default, Default, 300, 150, 0 ), Button1 =3D create ( PushButton, "Use getIndex()", = Win, 120, 10, 150, 30, 0 ), Button2 =3D create ( PushButton, "Use LB_GETSELCOUNT", = Win, 120, 60, 150, 30, 0 ), List1 =3D create ( SortedList, "", = Win, 10, 10, 100, 100, LBS_EXTENDEDSEL ) addItem(List1, "> Item 1 <") addItem(List1, "> Item 2 <") addItem(List1, "> Item 3 <") addItem(List1, "> Item 4 <") addItem(List1, "> Item 5 <") addItem(List1, "> Item 6 <") addItem(List1, "> Item 7 <") setEnable ( List1, False ) procedure onClick_Button1() atom test object result =20 test =3D getIndex( List1 ) result =3D message_box (sprintf( "getIndex() still returns a value = even though nothing is selected!: %d", test ), "Test multi-list", = MB_ICONERROR+MB_TASKMODAL ) =20 end procedure procedure onClick_Button2() atom test object result test =3D sendMessage(List1, LB_GETSELCOUNT, 0, 0) result =3D message_box(sprintf( "However, using LB_GETSELCOUNT = provides the correct result: %d", test ), "Test multi-list", = MB_ICONINFORMATION+MB_TASKMODAL ) end procedure onClick [ Button1 ] =3D routine_id( "onClick_Button1" ) onClick [ Button2 ] =3D routine_id( "onClick_Button2" ) WinMain( Win, Normal ) ------=_NextPart_001_0008_01C0CB8F.EE79DEA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY> <DIV><FONT face=3DArial size=3D2>I am confident the following is a = problem=20 with win32lib (has this been fixed in later version of = win32lib, I am=20 using v0.50)?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Here is the sample code for those = worried about=20 viruses:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>-- Under win32lib v0.50, the = following=20 behavior occurs using multi-select list boxes . . .<BR>-- <BR>-- = Gathering=20 whether a user selected items in a multi-select list box gives<BR>-- = erroneous=20 info using provided functions in win32lib. Running the sample = below=20 showcases<BR>-- this behavior. The ability to check whether or not = a user=20 has selected anything is<BR>-- because if this is not done before = accessing the=20 getMultItems(), an error occurs<BR>-- within win32lib.<BR>--<BR>-- = getIndex()=20 works fine in a single select list box.<BR>-- <BR>-- Please note:=20 LB_GETANCHORINDEX works initially, but once an item is selected and=20 then<BR>-- &nb= sp; =20 deselected, LB_ANCHORINDEX remembers previous item selected and returns=20 result</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>include win32lib.ew<BR>without=20 warning</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>constant<BR> =20 Win =3D create (=20 Window, "Showcase Multi-List=20 problem", &nbs= p; =20 0, Default, Default, 300, 150, 0=20 ),<BR> Button1 =3D create (=20 PushButton, "Use=20 getIndex()", &= nbsp; &n= bsp;=20 Win, 120, 10, = 150, =20 30, 0 ),<BR> Button2 =3D create (=20 PushButton, "Use=20 LB_GETSELCOUNT", &nb= sp; =20 Win, 120, 60, = 150, =20 30, 0 ),<BR> List1 =3D create (=20 SortedList, =20 "", &nbs= p;  = ; = =20 Win, 10, 10, = 100,=20 100, LBS_EXTENDEDSEL )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>addItem(List1, "> Item 1=20 <")<BR>addItem(List1, "> Item 2 <")<BR>addItem(List1, "> = Item 3=20 <")<BR>addItem(List1, "> Item 4 <")<BR>addItem(List1, "> = Item 5=20 <")<BR>addItem(List1, "> Item 6 <")<BR>addItem(List1, "> = Item 7=20 <")</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>setEnable ( List1, False = )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>procedure = onClick_Button1()<BR> atom=20 test<BR> object result<BR> <BR> test =3D getIndex( List1=20 )<BR> result =3D message_box (sprintf( "getIndex() still returns a = value=20 even though nothing is selected!: %d", test ), "Test multi-list",=20 MB_ICONERROR+MB_TASKMODAL ) = <BR>end=20 procedure</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>procedure = onClick_Button2()<BR> atom=20 test<BR> object result</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1> test =3D = sendMessage(List1,=20 LB_GETSELCOUNT, 0, 0)<BR> result =3D message_box(sprintf( = "However, using=20 LB_GETSELCOUNT provides the correct result: %d", test ), "Test = multi-list",=20 MB_ICONINFORMATION+MB_TASKMODAL )<BR>end procedure</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>onClick [=20 Button1 ] =3D routine_id( = "onClick_Button1"=20 )<BR>onClick [ Button2 ] =3D = routine_id(=20 "onClick_Button2" )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>WinMain( Win, Normal=20 ------=_NextPart_001_0008_01C0CB8F.EE79DEA0-- ------=_NextPart_000_0007_01C0CB8F.EE79DEA0 Content-Type: application/octet-stream; name="Multi-list problem.exw" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Multi-list problem.exw" -- Under win32lib v0.50, the following behavior occurs using = multi-select list boxes . . . --=20 -- Gathering whether a user selected items in a multi-select list box = gives -- erroneous info using provided functions in win32lib. Running the = sample below showcases -- this behavior. The ability to check whether or not a user has = selected anything is -- because if this is not done before accessing the getMultItems(), an = error occurs -- within win32lib. -- -- getIndex() works fine in a single select list box. --=20 -- Please note: LB_GETANCHORINDEX works initially, but once an item is = selected and then -- deselected, LB_ANCHORINDEX remembers previous item = selected and returns result include win32lib.ew without warning constant Win =3D create ( Window, "Showcase Multi-List problem", = 0, Default, Default, 300, 150, 0 ), Button1 =3D create ( PushButton, "Use getIndex()", = Win, 120, 10, 150, 30, 0 ), Button2 =3D create ( PushButton, "Use LB_GETSELCOUNT", = Win, 120, 60, 150, 30, 0 ), List1 =3D create ( SortedList, "", = Win, 10, 10, 100, 100, LBS_EXTENDEDSEL ) addItem(List1, "> Item 1 <") addItem(List1, "> Item 2 <") addItem(List1, "> Item 3 <") addItem(List1, "> Item 4 <") addItem(List1, "> Item 5 <") addItem(List1, "> Item 6 <") addItem(List1, "> Item 7 <") setEnable ( List1, False ) procedure onClick_Button1() atom test object result =09 test =3D getIndex( List1 ) result =3D message_box (sprintf( "getIndex() still returns a value = even though nothing is selected!: %d", test ), "Test multi-list", = MB_ICONERROR+MB_TASKMODAL ) =20 end procedure procedure onClick_Button2() atom test object result test =3D sendMessage(List1, LB_GETSELCOUNT, 0, 0) result =3D message_box(sprintf( "However, using LB_GETSELCOUNT = provides the correct result: %d", test ), "Test multi-list", = MB_ICONINFORMATION+MB_TASKMODAL ) end procedure onClick [ Button1 ] =3D routine_id( "onClick_Button1" ) onClick [ Button2 ] =3D routine_id( "onClick_Button2" ) WinMain( Win, Normal ) ------=_NextPart_000_0007_01C0CB8F.EE79DEA0--