home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / Calmira / Src / VCL / ICONDLG.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-02-15  |  2.3 KB  |  95 lines

  1. {*********************************************************}
  2. {                                                         }
  3. {    Calmira Visual Component Library 1.0                 }
  4. {    by Li-Hsin Huang,                                    }
  5. {    released into the public domain January 1997         }
  6. {                                                         }
  7. {*********************************************************}
  8.  
  9. unit Icondlg;
  10.  
  11. interface
  12.  
  13. uses
  14.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  15.   Forms, Dialogs;
  16.  
  17. type
  18.   TIconDialog = class(TComponent)
  19.   private
  20.     { Private declarations }
  21.     FFilename  : TFilename;
  22.     FIconIndex : Word;
  23.     FHistory : TStrings;
  24.     procedure SetHistory(value : TStrings);
  25.   protected
  26.     { Protected declarations }
  27.   public
  28.     { Public declarations }
  29.     constructor Create(AOwner : TComponent); override;
  30.     destructor Destroy; override;
  31.     function Execute : Boolean;
  32.   published
  33.     { Published declarations }
  34.     property Filename : TFilename read FFilename write FFilename;
  35.     property IconIndex : Word read FIconIndex write FIconIndex default 0;
  36.     property HistoryList : TStrings read FHistory write SetHistory;
  37.   end;
  38.  
  39. procedure Register;
  40.  
  41. implementation
  42.  
  43. uses IconSel;
  44.  
  45. constructor TIconDialog.Create(AOwner : TComponent);
  46. begin
  47.   inherited Create(AOwner);
  48.   FFilename := Application.Exename;
  49.   FIconIndex := 0;
  50.   FHistory := TStringList.Create;
  51. end;
  52.  
  53. destructor TIconDialog.Destroy;
  54. begin
  55.   FHistory.Free;
  56.   inherited Destroy;
  57. end;
  58.  
  59. procedure TIconDialog.SetHistory(value : TStrings);
  60. begin
  61.   FHistory.Assign(value);
  62. end;
  63.  
  64.  
  65. function TIconDialog.Execute : Boolean;
  66. var form : TIconSelForm;
  67. begin
  68.   form := TIconSelForm.Create(Application);
  69.   with Form do
  70.   try
  71.     FileEdit.Text := Filename;
  72.     OpenDialog.HistoryList.Assign(FHistory);
  73.     Index := IconIndex;
  74.  
  75.     if ShowModal = mrOK then begin
  76.       Result := True;
  77.       Filename := Lowercase(FileEdit.Text);
  78.       IconIndex := Grid.Col;
  79.       if FHistory.IndexOf(Filename) = -1 then FHistory.Insert(0, Filename);
  80.       if FHistory.Count > 24 then FHistory.Delete(24);
  81.     end
  82.     else Result := False;
  83.   finally
  84.     Free;
  85.   end;
  86. end;
  87.  
  88.  
  89. procedure Register;
  90. begin
  91.   RegisterComponents('Dialogs', [TIconDialog]);
  92. end;
  93.  
  94. end.
  95.