ToolPropertiesUnit.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. {
  2. TIGCC IDE
  3. Copyright (C) 2000-2004 Sebastian Reichelt
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. }
  16. unit ToolPropertiesUnit;
  17. interface
  18. uses
  19. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  20. StdCtrls, ExtCtrls;
  21. type
  22. TToolPropertiesForm = class(TForm)
  23. Label1: TLabel;
  24. Label2: TLabel;
  25. Label3: TLabel;
  26. Label4: TLabel;
  27. TitleEdit: TEdit;
  28. CommandLineEdit: TEdit;
  29. WorkingDirEdit: TEdit;
  30. Bevel1: TBevel;
  31. OKButton: TButton;
  32. CancelButton: TButton;
  33. WindowStateEdit: TComboBox;
  34. CommandLineBrowseButton: TButton;
  35. WorkingDirBrowseButton: TButton;
  36. BrowseDialog: TOpenDialog;
  37. procedure EditChange(Sender: TObject);
  38. procedure CommandLineBrowseButtonClick(Sender: TObject);
  39. procedure WorkingDirBrowseButtonClick(Sender: TObject);
  40. private
  41. public
  42. end;
  43. implementation
  44. {$R *.DFM}
  45. uses
  46. ShlObj;
  47. procedure TToolPropertiesForm.EditChange(Sender: TObject);
  48. begin
  49. OKButton.Enabled := (Length (TitleEdit.Text) > 0) and (Length (CommandLineEdit.Text) > 0);
  50. end;
  51. procedure TToolPropertiesForm.CommandLineBrowseButtonClick(Sender: TObject);
  52. var
  53. S: string;
  54. begin
  55. with BrowseDialog do begin
  56. S := CommandLineEdit.Text;
  57. if (Length (S) > 0) and ((S [1] = '"') or (Pos (' ', S) <= 0)) then begin
  58. if S [1] = '"' then begin
  59. Delete (S, 1, 1);
  60. if Pos ('"', S) > 0 then
  61. Delete (S, Pos ('"', S), Length (S));
  62. end;
  63. FileName := S;
  64. end;
  65. if Execute then
  66. CommandLineEdit.Text := '"' + FileName + '"';
  67. end;
  68. end;
  69. procedure TToolPropertiesForm.WorkingDirBrowseButtonClick(Sender: TObject);
  70. var
  71. Info: TBrowseInfo;
  72. Path: PItemIDList;
  73. FolderName: array [0..MAX_PATH] of Char;
  74. begin
  75. FillChar (Info, SizeOf (Info), 0);
  76. with Info do begin
  77. hwndOwner := Handle;
  78. lpszTitle := 'Browse';
  79. ulFlags := BIF_RETURNONLYFSDIRS;
  80. end;
  81. Path := SHBrowseForFolder (Info);
  82. if Assigned (Path) then begin
  83. if SHGetPathFromIDList (Path, FolderName) then
  84. WorkingDirEdit.Text := FolderName;
  85. end;
  86. end;
  87. end.