home *** CD-ROM | disk | FTP | other *** search
- unit Testpick;
-
- {Copyright 1995 by Robert Fabiszak
- TESTPICK - Sample program to demonstate the usage and benefits
- of the PICKLIST control.
-
- Free unrestricted use granted provided this copyright notice
- is maintained.
-
- PICKLIST is an enhanced list box control for Borland's Delphi
- product. Version 1.0. June, 1995}
-
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, picklist, StdCtrls, ExtCtrls, Buttons, Spin;
-
- type
- TForm1 = class(TForm)
- GroupBox1: TGroupBox;
- TestLB: TPickList;
- Label1: TLabel;
- Panel1: TPanel;
- Button1: TButton;
- GroupBox2: TGroupBox;
- PickList1: TPickList;
- Label2: TLabel;
- Panel2: TPanel;
- GroupBox3: TGroupBox;
- PickList2: TPickList;
- BitBtn1: TBitBtn;
- SpinEdit1: TSpinEdit;
- Label4: TLabel;
- Button2: TButton;
- Button3: TButton;
- BitBtn2: TBitBtn;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure PickList1Change(Sender: TObject);
- procedure UpdatePanel1;
- procedure UpdatePanel2;
- procedure BitBtn1Click(Sender: TObject);
- procedure SpinEdit1Change(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses od_test;
-
- {$R *.DFM}
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- TestLB.Items.Add('Item 1');
- TestLB.Items.Add('Item 2');
- TestLB.Items.Add('Item 3');
- PickList1.Items.Add('Test'#9'Row 1'#9'More');
- PickList1.Items.Add('Test'#9'Row 2');
- PickList1.Items.Add('Test'#9'Row 3');
- UpdatePanel1;
- UpdatePanel2;
- SpinEdit1.Value := TestLB.Font.Size;
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- if TestLB.SelectedStyle = psStandard then
- MessageDlg('Changing from the standard Windows listbox to ' +
- 'owner-draw or changing font size will remove any selections.', mtInformation, [mbOK], 0);
-
- {presssing the button will cycle through the two built-in
- owner draw formats}
- with TestLB do
- if SelectedStyle = psBoldText then
- SelectedStyle := psCheckbox
- else
- SelectedStyle := psBoldText;
- UpdatePanel1;
- end;
-
- procedure TForm1.UpdatePanel1;
- const
- LBStr: array[TSelectedStyle] of string = ('psStandard', 'psCheckbox',
- 'psBoldText', 'psOwnerDraw');
- begin
- Panel1.Caption := LBStr[TestLB.SelectedStyle];
- TestLB.Hint := 'Current style: ' + LBStr[TestLB.SelectedStyle];
- end;
-
-
- procedure TForm1.PickList1Change(Sender: TObject);
- begin
- {a simple method to demonstrate the OnClick event handler}
- MessageDlg('Processing Change Method; current selection = ' +
- IntToStr(PickList1.ItemIndex), mtCustom, [mbOK], 0);
- UpdatePanel2;
- end;
-
-
- procedure TForm1.UpdatePanel2;
- begin
- if PickList1.ItemIndex >= 0 then
- Panel2.Caption := PickList1.Items[PickList1.ItemIndex]
- else
- Panel2.Caption := 'no item selected';
- end;
-
-
- procedure TForm1.BitBtn1Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TForm1.SpinEdit1Change(Sender: TObject);
- begin
- {this demonstrates how the graphic will automatically
- resize to match the listbox font size}
- TestLB.Font.Size := SpinEdit1.Value;
-
- {keep the item height at about the same ratio as original}
- TestLB.ItemHeight := (14 * TestLB.Font.Size) div 8;
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- PickList2.SelectAll;
- end;
-
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- PickList2.ClearSelection;
- end;
-
-
- procedure TForm1.BitBtn2Click(Sender: TObject);
- begin
- PoemDialog.ShowModal;
- end;
-
- end.
-