RefForm.pas
资源名称:delphi.rar [点击查看]
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:6k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit RefForm;
- interface
- uses
- SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
- ComCtrls, Menus, ImgList;
- type
- TForm1 = class(TForm)
- ListView1: TListView;
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- Exit1: TMenuItem;
- View1: TMenuItem;
- LargeIcons1: TMenuItem;
- SmallIcons1: TMenuItem;
- List1: TMenuItem;
- Details1: TMenuItem;
- Help1: TMenuItem;
- About1: TMenuItem;
- N1: TMenuItem;
- CheckBoxes1: TMenuItem;
- AddItems1: TMenuItem;
- N2: TMenuItem;
- procedure FormCreate(Sender: TObject);
- procedure LargeIcons1Click(Sender: TObject);
- procedure SmallIcons1Click(Sender: TObject);
- procedure List1Click(Sender: TObject);
- procedure Details1Click(Sender: TObject);
- procedure Exit1Click(Sender: TObject);
- procedure About1Click(Sender: TObject);
- procedure CheckBoxes1Click(Sender: TObject);
- procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);
- procedure ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
- Data: Integer; var Compare: Integer);
- procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure FormDestroy(Sender: TObject);
- procedure AddItems1Click(Sender: TObject);
- procedure ListView1DblClick(Sender: TObject);
- public
- { Public declarations }
- private
- nSortCol: Integer;
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.DFM}
- {$R BITMAPS.RES}
- uses
- StdCtrls, NewDial;
- procedure TForm1.FormCreate(Sender: TObject);
- var
- ImageList1, ImageList2: TImageList;
- List: TStringList;
- NewItem: TListItem;
- I: Integer;
- begin
- // avoid warning
- NewItem := nil;
- // load the large images
- ImageList1 := TImageList.Create (Self);
- ImageList1.Height := 32;
- ImageList1.Width := 32;
- ImageList1.ResourceLoad (rtBitmap,
- 'LargeImages', clWhite);
- ListView1.LargeImages := ImageList1;
- // load the small images
- ImageList2 := TImageList.Create (Self);
- ImageList2.ResourceLoad (rtBitmap,
- 'SmallImages', clWhite);
- ListView1.SmallImages := ImageList2;
- // load the items
- ListView1.Items.Clear;
- List := TStringList.Create;
- try
- List.LoadFromFile (
- ExtractFilePath (Application.ExeName) + 'Items.txt');
- for I := 0 to List.Count - 1 do
- if List [I][1] = #9 then
- NewItem.SubItems.Add (Trim (List [I]))
- else if List [I][1] = '@' then
- NewItem.ImageIndex := StrToIntDef (List [I][2], 0)
- else
- begin
- // a new item
- NewItem := ListView1.Items.Add;
- NewItem.Caption := List [I];
- end;
- finally
- List.Free;
- end;
- end;
- procedure TForm1.LargeIcons1Click(Sender: TObject);
- begin
- ListView1.ViewStyle := vsIcon;
- LargeIcons1.Checked := True;
- end;
- procedure TForm1.SmallIcons1Click(Sender: TObject);
- begin
- ListView1.ViewStyle := vsSmallIcon;
- SmallIcons1.Checked := True;
- end;
- procedure TForm1.List1Click(Sender: TObject);
- begin
- ListView1.ViewStyle := vsList;
- List1.Checked := True;
- end;
- procedure TForm1.Details1Click(Sender: TObject);
- begin
- ListView1.ViewStyle := vsReport;
- Details1.Checked := True;
- end;
- procedure TForm1.Exit1Click(Sender: TObject);
- begin
- Close;
- end;
- procedure TForm1.About1Click(Sender: TObject);
- begin
- MessageDlg ('Reference List (ListView example)' +
- #13'from "Mastering Delphi"'#13'author: Marco Cant