home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / Calmira / Src / SRC / REFEDIT.PAS < prev    next >
Pascal/Delphi Source File  |  1997-02-15  |  4KB  |  133 lines

  1. {**************************************************************************}
  2. {                                                                          }
  3. {    Calmira shell for Microsoft« Windows(TM) 3.1                          }
  4. {    Source Release 1.0                                                    }
  5. {    Copyright (C) 1997  Li-Hsin Huang                                     }
  6. {                                                                          }
  7. {    This program is free software; you can redistribute it and/or modify  }
  8. {    it under the terms of the GNU General Public License as published by  }
  9. {    the Free Software Foundation; either version 2 of the License, or     }
  10. {    (at your option) any later version.                                   }
  11. {                                                                          }
  12. {    This program is distributed in the hope that it will be useful,       }
  13. {    but WITHOUT ANY WARRANTY; without even the implied warranty of        }
  14. {    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         }
  15. {    GNU General Public License for more details.                          }
  16. {                                                                          }
  17. {    You should have received a copy of the GNU General Public License     }
  18. {    along with this program; if not, write to the Free Software           }
  19. {    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             }
  20. {                                                                          }
  21. {**************************************************************************}
  22.  
  23. unit Refedit;
  24.  
  25. interface
  26.  
  27. uses Classes, Forms, Controls, Buttons, StdCtrls, ExtCtrls, Dialogs,
  28.   StylSped, Icondlg, SysUtils, TabNotBk, Menus;
  29.  
  30. type
  31.   TRefEditDlg = class(TForm)
  32.     OKBtn: TBitBtn;
  33.     CancelBtn: TBitBtn;
  34.     IconDialog: TIconDialog;
  35.     Notebook: TTabbedNotebook;
  36.     Label1: TLabel;
  37.     Label2: TLabel;
  38.     TargetLabel: TLabel;
  39.     BrowseIcon: TStyleSpeed;
  40.     CapEdit: TEdit;
  41.     FilePanel: TGroupBox;
  42.     ParamLabel: TLabel;
  43.     Label3: TLabel;
  44.     FolderEdit: TEdit;
  45.     DocFolder: TCheckBox;
  46.     ParamEdit: TEdit;
  47.     TargetEdit: TEdit;
  48.     IconEdit: TEdit;
  49.     ShowGroup: TRadioGroup;
  50.     HelpBtn: TBitBtn;
  51.     KindMenu: TPopupMenu;
  52.     DriveKind: TMenuItem;
  53.     FolderKind: TMenuItem;
  54.     FileKind: TMenuItem;
  55.     procedure FormCreate(Sender: TObject);
  56.     procedure FormDestroy(Sender: TObject);
  57.     procedure BrowseIconClick(Sender: TObject);
  58.     procedure FolderEditDblClick(Sender: TObject);
  59.     procedure DriveKindClick(Sender: TObject);
  60.   private
  61.     { Private declarations }
  62.     SaveHistory : Boolean;
  63.   public
  64.     { Public declarations }
  65.   end;
  66.  
  67. var
  68.   RefEditDlg: TRefEditDlg;
  69.  
  70. function ExtractIconFile(const s: string): TFilename;
  71. function ExtractIconIndex(const s: string): Integer;
  72.  
  73. implementation
  74.  
  75. {$R *.DFM}
  76.  
  77. uses Graphics, FileCtrl, ShellAPI, Strings, Settings, WinProcs, Tree;
  78.  
  79. function ExtractIconFile(const s: string): TFilename;
  80. begin
  81.   Result := '';
  82.   Unformat(s, '%s(', [@Result, 79]);
  83. end;
  84.  
  85. function ExtractIconIndex(const s: string): Integer;
  86. begin
  87.   Result := 0;
  88.   try Unformat(s, '%S(%d', [@Result]);
  89.   except on EConvertError do;
  90.   end;
  91. end;
  92.  
  93.  
  94. procedure TRefEditDlg.FormCreate(Sender: TObject);
  95. begin
  96.   Notebook.PageIndex := 0;
  97.   ini.ReadStrings('IconSources', IconDialog.HistoryList);
  98. end;
  99.  
  100. procedure TRefEditDlg.FormDestroy(Sender: TObject);
  101. begin
  102.   if SaveHistory then ini.WriteStrings('IconSources', IconDialog.HistoryList);
  103. end;
  104.  
  105. procedure TRefEditDlg.BrowseIconClick(Sender: TObject);
  106. begin
  107.   with IconDialog do begin
  108.     if IconEdit.Text > '' then Filename := ExtractIconFile(IconEdit.Text)
  109.     else Filename := TargetEdit.Text;
  110.     IconIndex := ExtractIconIndex(IconEdit.Text);
  111.  
  112.     if Execute then begin
  113.       IconEdit.Text := Format('%s(%d)', [Filename, IconIndex]);
  114.       SaveHistory := True;
  115.     end;
  116.   end;
  117. end;
  118.  
  119. procedure TRefEditDlg.FolderEditDblClick(Sender: TObject);
  120. begin
  121.   FolderEdit.Text := SelectFolder(FolderEdit.Text);
  122. end;
  123.  
  124. procedure TRefEditDlg.DriveKindClick(Sender: TObject);
  125. begin
  126.   DriveKind.Checked := False;
  127.   FolderKind.Checked := False;
  128.   FileKind.Checked := False;
  129.   (Sender as TMenuItem).Checked := True;
  130. end;
  131.  
  132. end.
  133.