Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Mark or Multiple selection on a Listbox???

Browsers & ListBoxes

How to Mark or Multiple selection on a Listbox???

by  Gaudalier  Posted    (Edited  )
Well, One of the most commun task of list controls is to be used to multiple selection, and somehow Clarion default behavior, guess what??? [color blue]DOES NOT WORK[/color] according to the Windows Standards.

We're Lucky, there is a free template that solve ours existencial problem out there; just take a look at the [color red]DAS_TagUse Use Tags to Select Records[/color] from the TinMan Development Corp http://www.thetingroup.com/ This Template is usefull when we are taggin a Browse based on a Table (Default ABC/Legacy Templates)

But that TAG template is Useless when we try to tag a list wich Queue was manually loaded by ourself, I mean, HandCoding List.

So, Here is the code I've use to show the Archives within a Zip File. Using the excellent library of BigSpeed Zip Dll from www.bigSpeed.com

First. We have a List populated Without using the default template. This list will be based on a Queue declarated like this:

ZipQueue QUEUE,PRE(ZIP)
Name CSTRING(256) !Name of the File
Ext CSTRING(4) !File's Extension
Modified CSTRING(20) !Time/Date Stamp
Size LONG !Total File's size
Packed LONG !Packed File's size
Ratio BYTE !% of compresion
Path CSTRING(256) !Relative Path (if any)
Index LONG !Position within the zip Archive
Mark BYTE !To be use in Mark Attrib.
END

Rememeber that the Queue will hold information about the Files of a Zip Archive.

Well, once we'd put the LIST control in the window and choose the option "populate control Without control template" when the "Select control to use" Windows popups. After that, popups the Window "Select Column", we go to LOCAL DATA and select the ZIP:Name field from the QUEUE ZipQueue, repeat the step for every field until the ZIP:path.

Then we need to change the default "FROM" List's property from "List1:Queue" to our local Queue "ZipQueue", and fill in the "MARK" field with "ZIP:Mark", this last is located in the "Extra" Tab.

Finally we need to add serveral "ALERT" on the list:

CtrlA
MouseLeft
DownKey
UpKey
ShiftLeftMouse
ShiftUp
ShiftDown
CtrlDown
CtrlUp

The Default Clarion's mark behavior is simple, you tag a record by Cliking on it, to uncheck you need to click again.

If you try the windows default check/uncheck behavior like Exporer, will note that:
1. A simple click Untag All Selected Records but the one Clicked.
2. Arrow Up/down does the same like a simple Click.
3. ShiftClick will select from the last selected to the one we'd clicked on.
4. ShiftDown/up will goes marking selected every record as we press ShiftDown key secuence.
5. CtrlClick will tag the record altrough it not on secuential order.
6. CtrlDown/up will do like CtrlClick, but if we wanna mark a record we must to press SPACE bar to TOGGLE marked/unmarked evey record.

Ok. this is the Code:

[color red]At PreAlertKey Embed, priority 2500:[/color]

Code:
CASE KEYCODE()
  OF MOUSELEFT  !**********  MOUSE CLICK
    IF RECORDS(ZipQueue)
      J# =  ?List{PropList:MouseDownRow}
      LOOP I# = 1 TO RECORDS(ZipQueue)
        GET(ZipQueue,I#)
        ZIP:Mark = FALSE
        PUT(ZipQueue)
      END
      GET(ZipQueue,J#)
      ZIP:Mark = TRUE
      PUT(ZipQueue)
      SELECT(?List,J#)
    END
     RETURN(0)

   OF CTRLDOWN  !********** CONTROL+DOWN
    IF CHOICE(?List) <> RECORDS(ZipQueue)
      GET(ZipQueue,CHOICE(?List)+1)
    ELSE
      GET(ZipQueue,RECORDS(ZipQueue))
    END
     RETURN(0)

   OF CTRLUP    !********** CONTROL+UP
    IF CHOICE(?List) <> 1
      GET(ZipQueue,CHOICE(?List)-1)
    ELSE
      GET(ZipQueue,1)
    END
     RETURN(0)
END

[color red]And at AlertKey Embed, priority 2500:[/color]

Code:
CASE KEYCODE()
  OF UPKEY          !************* UPKEY  (48)
    IF CHOICE(?List) <> 1
      LOOP I# = 1 TO RECORDS(ZipQueue)
        GET(ZipQueue,I#)
        ZIP:Mark = FALSE
        PUT(ZipQueue)
      END
      GET(ZipQueue,CHOICE(?List)-1)
      ZIP:Mark = TRUE
      PUT(ZipQueue)
      SELECT(?List,CHOICE(?List)-1)
    END
  OF DOWNKEY          !************* DOWNKEY  (40)
    IF CHOICE(?List) <> RECORDS(ZipQueue)
      LOOP I# = 1 TO RECORDS(ZipQueue)
        GET(ZipQueue,I#)
        ZIP:Mark = FALSE
        PUT(ZipQueue)
      END
      GET(ZipQueue,CHOICE(?List)+1)
      ZIP:Mark = TRUE
      PUT(ZipQueue)
      SELECT(?List,CHOICE(?List)+1)
    END
  OF SHIFTMOUSELEFT   !************ MOUSE CLICK (257)
    IF ?List{PropList:MouseDownRow} > CHOICE(?List)
      FromHere# = CHOICE(?List)
      ToHere# = ?List{PropList:MouseDownRow}
      J# = ToHere#
    ELSE
      ToHere# = CHOICE(?List)
      FromHere# = ?List{PropList:MouseDownRow}
      J# = FromHere#
    END
    LOOP I# = 1 TO RECORDS(ZipQueue)
      GET(ZipQueue,I#)
      ZIP:Mark = INRANGE(I#,FromHere#,ToHere#)
      PUT(ZipQueue)
    END
    SELECT(?List,J#)

  OF SHIFTUP        !************* SHIFT + UP (294)
    IF CHOICE(?List) <> 1
      GET(ZipQueue,CHOICE(?List)-1)
      ZIP:Mark = TRUE
      PUT(ZipQueue)
      SELECT(?List,CHOICE(?List)-1)
    END

  OF SHIFTDOWN        !************* SHIFT DOWN (296)
    IF CHOICE(?List) <> RECORDS(ZipQueue)
      GET(ZipQueue,CHOICE(?List)+1)
      ZIP:Mark = TRUE
      PUT(ZipQueue)
      SELECT(?List,CHOICE(?List)+1)
    END

  OF CTRLUP      !************* CONTROL+UP  (550)
    IF CHOICE(?List) <> 1
      SELECT(?List,CHOICE(?List)-1)
      IF ZIP:Mark = FALSE
        PRESSKEY(SPACEKEY)
      END
    END

  OF CTRLDOWN      !************* CONTROL+DOWN  (552)
    IF CHOICE(?List) <> RECORDS(ZipQueue)
      SELECT(?List,CHOICE(?List)+1)
      IF ZIP:Mark = FALSE
        PRESSKEY(SPACEKEY)
      END
    END

  OF CTRLA            !************* CONTROL+A  (577)
    LOOP I# = 1 TO RECORDS(ZipQueue)
      GET(ZipQueue,I#)
      ZIP:Mark = TRUE
      PUT(ZipQueue)
    END
END

Finally I mention that the List has checked the "Hide Selection" property.

This Code Was Improved with a ROUTINE that Clears the ZIP:Mark on the Whole Queue. But I'd pretend to show the simplest way to mark the List.

REGARDS
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top