home *** CD-ROM | disk | FTP | other *** search
- unit SDropDemo1;
- {$A+,B-,G+,H+,O+,J-,T+,U-,V+,W-,X+} //Set up compiler
- {$D-,L-,Q-,R-,Y-} //Comment out to debug
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls, STools, SDropLst, ComCtrls;
-
- type
- TfrmDropDemo = class(TForm)
- SDropList2: TSDropList;
- SDropList3: TSDropList;
- Panel1: TPanel;
- SDropList1: TSDropList;
- Edit2: TEdit;
- rgOnSelect: TRadioGroup;
- cbStyle: TCheckBox;
- cbDropFocus: TCheckBox;
- cbDropAltDn: TCheckBox;
- rgBorderStyle: TRadioGroup;
- rgShowButton: TRadioGroup;
- rgButtonPos: TRadioGroup;
- SDropList4: TSDropList;
- PageControl1: TPageControl;
- TabSheet1: TTabSheet;
- TabSheet2: TTabSheet;
- Memo1: TMemo;
- Memo2: TMemo;
- cbCaret: TCheckBox;
- cbStayDown: TCheckBox;
- ComboBox1: TComboBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- SDropList5: TSDropList;
- Label4: TLabel;
- SDropEdit1: TSDropEdit;
- Label5: TLabel;
- procedure rgOnSelectClick(Sender: TObject);
- procedure cbStyleClick(Sender: TObject);
- procedure cbDropFocusClick(Sender: TObject);
- procedure cbDropAltDnClick(Sender: TObject);
- procedure cbCaretClick(Sender: TObject);
- procedure rgBorderStyleClick(Sender: TObject);
- procedure rgShowButtonClick(Sender: TObject);
- procedure rgButtonPosClick(Sender: TObject);
- procedure cbStayDownClick(Sender: TObject);
- procedure SDropList5DrawListItem(Control: TWinControl; Index: Integer;
- Rect: TRect; State: TOwnerDrawState);
- procedure SDropEdit1WantForm(Sender: TObject; var SubForm: TForm;
- var DestroyOnClose: Boolean);
- procedure SDropEdit1Exit(Sender: TObject);
- procedure SDropList4AutoExpand(Sender: TObject; Hit: Boolean;
- var Revert: Boolean; var NewText: String);
- procedure SDropList2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- frmDropDemo: TfrmDropDemo;
-
- implementation
-
- uses SDropDemo2;
-
- {$R *.DFM}
-
-
-
-
-
- procedure TfrmDropDemo.rgOnSelectClick(Sender: TObject);
- begin
- Case rgOnSelect.ItemIndex Of
- 0: begin SDropList1.List.DoOnClick:= doTakeValue;
- SDropList1.List.DoOnReturnKey:= doTakeValue; end;
- 1: begin SDropList1.List.DoOnClick:= doDefault;
- SDropList1.List.DoOnReturnKey:= doDefault; end;
- 2: begin SDropList1.List.DoOnClick:= doGoAway;
- SDropList1.List.DoOnReturnKey:= doGoAway; end;
- End;
- SDropList1.DisplayForm(Sender);
- end;
-
- procedure TfrmDropDemo.cbStyleClick(Sender: TObject);
- begin
- if cbStyle.checked then SDropList1.Style:= dlsDropDownList
- else SDropList1.Style:= dlsDropDown;
- SDropList1.SetFocus;
- end;
-
- procedure TfrmDropDemo.cbDropFocusClick(Sender: TObject);
- begin
- with SDropList1 do
- if cbDropFocus.Checked then
- DropDownOn:= DropDownOn+[DropOnGetFocus]
- else DropDownOn:= DropDownOn-[DropOnGetFocus];
- SDropList1.SetFocus;
- end;
-
- procedure TfrmDropDemo.cbDropAltDnClick(Sender: TObject);
- begin
- with SDropList1 do
- if cbDropFocus.Checked then
- DropDownOn:= DropDownOn+[DropOnAltArrow]
- else DropDownOn:= DropDownOn-[DropOnAltArrow];
- SDropList1.SetFocus;
- end;
-
-
- procedure TfrmDropDemo.cbCaretClick(Sender: TObject);
- begin
- SDropList1.CaretAtEnd:=cbCaret.Checked;
- SDropList1.SetFocus;
- end;
-
- procedure TfrmDropDemo.rgBorderStyleClick(Sender: TObject);
- begin
- Case rgBorderStyle.ItemIndex of
- 0: With SDropList1 do begin
- ParentColor:=True; BorderStyle:=bsNone; end;
- 1: With SDropList1 do begin
- Color:=clWindow; BorderStyle:=bsSingle; Ctl3D:=False; end;
- 2: With SDropList1 do begin
- Color:=clWindow; BorderStyle:=bsSingle; Ctl3D:=True; end;
- end; // Case
- end;
-
- procedure TfrmDropDemo.rgShowButtonClick(Sender: TObject);
- begin
- Case rgShowButton.ItemIndex of
- 0: SDropList1.ButtonShow:=btnShowYes;
- 1: SDropList1.ButtonShow:=btnShowNo;
- 2: SDropList1.ButtonShow:=btnShowFocus;
- end; // Case
- end;
-
- procedure TfrmDropDemo.rgButtonPosClick(Sender: TObject);
- begin
- Case rgButtonPos.ItemIndex of
- 0: SDropList1.ButtonAlign:=btnRight;
- 1: SDropList1.ButtonAlign:=btnLeft;
- end; // Case
- end;
-
-
- procedure TfrmDropDemo.cbStayDownClick(Sender: TObject);
- begin
- SDropList1.ButtonStayDown:=cbStayDown.Checked;
- end;
-
-
- procedure TfrmDropDemo.SDropList5DrawListItem(Control: TWinControl;
- Index: Integer; Rect: TRect; State: TOwnerDrawState);
- var
- TempStr1, TempStr2: String;
- Rect1, Rect2: TRect;
- I,J,K: Integer;
- begin
- TempStr1:= TSDropList(Control.Owner).Items[Index];
- SetLength(TempStr1, Pos('::',TempStr1)-1);
- TempStr2:= TSDropList(Control.Owner).Items[Index];
- Delete(TempStr2, 1, Pos('::',TempStr2)+1);
- I:=Pos('&',TempStr2);J:=0;K:=0;
- While I > 0 do begin
- J:=J+I+K; Insert('&',TempStr2,J); Inc(K);
- I:=Pos('&',PChar(TempStr2)+J+K); end;
- with TDropListLB(Control).Canvas do begin
- with Rect do begin
- SetRect(Rect1,Left,Top,Left+TextWidth('WWW'),Bottom);
- SetRect(Rect2,Rect1.Right,Top,Right,Bottom); end;
- DrawTextEx(Handle,PChar(TempStr1),Length(TempStr1),
- Rect1,DT_END_ELLIPSIS, nil);
- DrawTextEx(Handle,PChar(TempStr2),Length(TempStr2),
- Rect2,DT_END_ELLIPSIS, nil); end;
- end;
-
-
- procedure TfrmDropDemo.SDropEdit1WantForm(Sender: TObject;
- var SubForm: TForm; var DestroyOnClose: Boolean);
- begin
- SubForm:=frmDropEdit;
- end;
-
- procedure TfrmDropDemo.SDropEdit1Exit(Sender: TObject);
- begin
- SDropEdit1.CloseForm;
- end;
-
- procedure TfrmDropDemo.SDropList4AutoExpand(Sender: TObject; Hit: Boolean;
- var Revert: Boolean; var NewText: String);
- begin
- if not Hit then begin Revert:=True; Beep; end;
- end;
-
- procedure TfrmDropDemo.SDropList2Click(Sender: TObject);
- begin
- With SDropList2 do if Showing then CloseForm else DisplayForm(Sender);
- end;
-
- end.
-