WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Control Manager
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to deal with "*SOME*" Listboxes that have checkboxes

Keywords:       system Listboxes list box checkboxes check box

Question:

I am trying to see whether a check box is selected within a listbox. Do you have any suggestions on how to do this using the Control Manager Extender?

Answer:

Here's a script fragment that seems to work for "*SOME*" List Box controls with Check boxes. It clears and then restores the selected items.

 
; Get text associated with every list item.
AllText = cGetLBText(hwnd)
 
; Get the selected item's text.
SelText = cGetLBSelText(hwnd)
 
if SelText == "*EMPTY*" 
   message( "cGetLBSelText", "No selected items.")
   exit
endif
 
; Clear the current selection.
if !cclearlball(hwnd)
    goto ahem
endif
 
;Restore the orginal selection.
SelectCount = Itemcount(SelText, @tab)
for i=1 to SelectCount
 
   ItemText = ItemExtract(i, SelText, @tab)
   Index    = ItemLocate(ItemText, AllText, @tab)
 
   ; Select an item from the list control.
   if !csetlbitemex(hwnd, index)
     goto ahem
   endif
next
 
exit
 
:ahem
message("We Blew up", "Should not be here.")
 
exit

Specific example

This example was designed using the listbox in the Control panel | Network | NetBeui properties | Bindings.... (it is a Multi selection listbox)
;make sure the "NetBeui properties" window is open
;and the "bindings" tab is selected before running....
AddExtender("wwctl34I.dll")
hwnd=DLLHWND("IPX/SPX-compatible Protocol Properties")
child2hwnd=cWndbyName(hwnd,"Bindings")

listboxhwnd=cWndbyID(child2hwnd,206); Get text associated with every list item.
AllText = cGetLBText(listboxhwnd)
message("List of text in list box",alltext)
 
; Get the selected item's text.
SelText = cGetLBSelText(listboxhwnd)
 
if SelText == "*EMPTY*" 
   message( "cGetLBSelText", "No selected items.")
   exit
endif
message("List of SELECTED text in list box",seltext)

;exit 
; Clear the current selection.
if !cclearlball(listboxhwnd)
    goto ahem
endif
 
;Restore the original selection.
SelectCount = Itemcount(SelText, @tab)
for i=1 to SelectCount
 
   ItemText = ItemExtract(i, SelText, @tab)
   Index    = ItemLocate(ItemText, AllText, @tab)
 
   ; Select an item from the list control.
   if !csetlbitemex(listboxhwnd, index)
     goto ahem
   endif
next
 
exit
 
:ahem
message("We Blew up", "Should not be here.")
 
exit

Article ID:   W12509
Filename:   How to deal with SOME Listboxes that have check boxes.txt
File Created: 2001:03:02:14:37:00
Last Updated: 2001:03:02:14:37:00