![]() |
|
Published 1998-04-01 Printer-friendly version
Having seen many programs that have this capability, I have always wanted to be able to add "Windows Styled" marking to my browses. You know what I mean, where you can click on a row, hold down the SHIFT key, then click on another row and have all of the rows in between become marked (or unmarked). Or hold the CONTROL key down and mark multiple records individually, or hold the SHIFT key down and press the down arrow to mark all records below the current row, etc. Windows styled marking.
The CW list control does have a built-in "Mark" attribute, but it doesn't behave like anything that my users or I are used to seeing. You actually have to click on each row to mark it, and a lot of the expected functionality of the listbox is disabled when the "Mark" attribute is used.
Before C4 came around, I thought about writing my own listbox marking class, using colors instead of the "Mark" attribute. Seemed quite feasible to do, but I lost interest because of the thought of having to manage a way to handle the color fields in the queue. You see, for each field in a listbox column, you need four LONG variables to hold the color information for foreground, background, selected foreground, and selected background colors. I had no idea how to write some re-usable code (ala an OOP class) using a queue with an unknown structure.
Then C4 was released. Wow! There are lots of fantastic new features. One of the ones that was particularly intriguing was the PROP:VLBProc property (Virtual Listbox Procedure). Although it can do much more than just handle the listbox coloring, this ability alone made it possible for me to reconsider the writing of a "Windows Styled Marking" class. With this property, you don't have to bother with peppering your queue structure with color fields. The programmer is in control over how the behavior of various aspects of the listbox (such as colors) is handled. If you haven't checked out PROP:VLBProc, I recommend that you do. The sample program in the C4 help file does a great job of demonstrating its use.
The class that I have written is just "Phase One" of what it will probably end up being. Right now, it only works on file loaded queues (not page loaded). The reason for this is that I use a MARK field (byte) that exists within the queue itself. The class can be further modified to use an external marking queue, which would enable the use of this class on a page loaded browse, but it hasn't been done yet.
One thing that is kind of neat, though, is the fact that the ABC File loaded drop list template creates all of the necessary logic to easily make a file loaded listbox. It already creates the MARK field that we need in the queue, so there is no modification necessary. All you have to do is populate the file loaded drop list, and set the DROP property to zero. That's it!
To add the marking functionality to your listbox is really quite simple. One of these days, maybe a template will emerge to place the code for you, but for now, there is a little bit of embedded code to be typed.
This code requires C4. The embeds used below are from the ABC template chain, but this class will still work with the CLARION chain.
In the AFTER GLOBAL INCLUDES embed, put this:
Include('WinMark.inc')
WMC JSWinMark
ClassName.Init(TheWindowLabel,|
TheListBoxFieldEquateLabel,|
TheQueue,|
TheMarkFieldOfTheQueue,|
TheNumberOfColumnsInTheListBox)
WMC.Init(Window, ?LOC:DummyName, Queue:FileDrop, Queue:FileDrop.Mark, 2)
ClassName.SetCol(TheColumnNumber, TheDataField, ThePicture)
WMC.SetCol(1,Queue:FileDrop.CON:Name,'@s30') WMC.SetCol(2,Queue:FileDrop.CON:Phone,'@s20')
WMC.EventHandler
Although this might seem a little bit complicated at first, it is really easy to add marking to your listboxes once you get the hang of it. Take a look at the sample application. It demonstrates the use of the FileLoaded drop list template and the four embeds necessary to add the marking. It also shows the use of the MarkAll(), UnMarkAll(), and FlipAll() methods.
Hopefully, in the future, I (or someone else) will write a template to enable even easier implementation of this class, and maybe even add the page-loaded browse capability.
Copyright © 1999-2008 by CoveComm Inc. All Rights Reserved. Reproduction in any form without the express written consent of CoveComm Inc., except as described in the subscription agreement, is prohibited.
Clarion Magazine ISSN 1718-9942
One year: $189
(includes all back issues since '99)
Renewals from $139
Two years: $289
Renewals from $239