home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
m
/
mltpik.zip
/
MULTTEST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-04-09
|
4KB
|
122 lines
{
This program demonstrates the MULTPICK unit. MULTPICK provides a
MultiLinePickList object derived from the PickList. MultiLinePickList is good
for displaying and getting selections from a list where each item needs more
than one line for display. An example would be making a selection from a
mailing list; this test program demonstrates such an example.
To work with MultiLinePickList, you must write a specialized user string
procedure, as shown in the example below. The procedure is passed the record
number, the field number within the record, and whether the record is the
currently highlighted one. The procedure must always initialize the IString
parameter with an appropriate value for those parameters. Field numbers range
from 1 to the number of fields; record numbers range from 1 to the number of
records.
A MultiLinePickList is initialized with the InitDeluxe constructor. This
constructor takes the following parameters:
InitDeluxe(X1, Y1, X2, Y2 : Byte; -Window coordinates
var Colors : ColorSet; -Colors to use
Options : LongInt; -Window options
ItemWidth : Byte; -Width of each column
NumRecords : Word; -Total number of records
NumFields : Word; -Number of fields in each record
StringProc : mlStringProc; -The string procedure
PickOptions : Word); -Pick options
The MultiLinePickList is designed only for single choice picklists and
requires the PickSnaking orientation for proper operation. Therefore, related
PickList options are not available to MultiLinePickList. The object also uses
protected items internally, so the user routine cannot protect entire
records.
The height of the window should be an exact multiple of NumFields. If it
isn't, InitDeluxe adjusts Y2 until the nearest multiple is reached. If this
isn't possible, InitDeluxe will fail.
String searching applied to such a pick list will be limited to searching the
first field of each record.
Item2Record returns the record number corresponding to a given item. This
will often be used in combination with GetLastChoice, as shown in the example
below.
If you are reading the records directly from disk, you should consider using
the technique demonstrated in CACHE.LZH for improving performance.
Written by TurboPower Software, 4/8/90.
Requires Object Professional 1.01 or later to compile and run.
}
program MultTest;
uses
OpInline,
OpString,
OpRoot,
OpCrt,
{$IFDEF UseMouse}
OpMouse,
{$ENDIF}
OpCmd,
OpFrame,
OpWindow,
OpPick,
MultPick;
var
MLPL : MultiLinePickList;
{$F+}
procedure MLStringProc(RecNum : Word;
FieldNum : Word;
RecIsCurrent : Boolean;
var IString : String;
MLPickPtr : MultiLinePickListPtr);
var
PadLen : Byte;
begin
if RecNum > 999 then
PadLen := 6
else if RecNum > 99 then
PadLen := 5
else if RecNum > 9 then
PadLen := 4
else
PadLen := 3;
case FieldNum of
1: IString := Long2Str(RecNum)+'. First Last Name';
2: IString := CharStr(' ', PadLen)+'Address '+Long2Str(RecNum);
3: IString := CharStr(' ', PadLen)+'City, State ZIP '+Long2Str(RecNum);
else
IString := '';
Exit;
end;
if RecIsCurrent then
IString[PadLen] := #16;
end;
{$F-}
begin
ClrScr;
if not MLPL.InitDeluxe(3, 5, 77, 16, DefaultColorSet,
DefWindowOptions or wBordered,
25, {Each column is 25 characters wide}
100, {There are 100 records total}
4, {Each record has 4 fields}
MLStringProc,
DefPickOptions) then Halt;
MLPL.wFrame.AddScrollBar(frBB, 0, MaxLongInt, DefaultColorSet);
MLPL.wFrame.AddHeader(' Mailing Label Pick List ', heTC);
MLPL.AddMoreHeader(' ', heTR, #27, #26, '', 2, 3, 0);
MLPL.SetPadSize(1, 1);
MLPL.SetSearchMode(PickAltStringSearch);
MLPL.Process;
MLPL.Erase;
if MLPL.GetLastCommand = ccSelect then
WriteLn('You chose record ', MLPL.Item2Record(MLPL.GetLastChoice));
MLPL.Done;
end.