ToolPropertiesUnit.pas 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. unit ToolPropertiesUnit;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5. StdCtrls, ExtCtrls;
  6. type
  7. TToolPropertiesForm = class(TForm)
  8. Label1: TLabel;
  9. Label2: TLabel;
  10. Label3: TLabel;
  11. Label4: TLabel;
  12. TitleEdit: TEdit;
  13. CommandLineEdit: TEdit;
  14. WorkingDirEdit: TEdit;
  15. Bevel1: TBevel;
  16. OKButton: TButton;
  17. CancelButton: TButton;
  18. WindowStateEdit: TComboBox;
  19. CommandLineBrowseButton: TButton;
  20. WorkingDirBrowseButton: TButton;
  21. BrowseDialog: TOpenDialog;
  22. procedure EditChange(Sender: TObject);
  23. procedure CommandLineBrowseButtonClick(Sender: TObject);
  24. procedure WorkingDirBrowseButtonClick(Sender: TObject);
  25. private
  26. public
  27. end;
  28. implementation
  29. {$R *.DFM}
  30. uses
  31. ShlObj;
  32. procedure TToolPropertiesForm.EditChange(Sender: TObject);
  33. begin
  34. OKButton.Enabled := (Length (TitleEdit.Text) > 0) and (Length (CommandLineEdit.Text) > 0);
  35. end;
  36. procedure TToolPropertiesForm.CommandLineBrowseButtonClick(Sender: TObject);
  37. var
  38. S: string;
  39. begin
  40. with BrowseDialog do begin
  41. S := CommandLineEdit.Text;
  42. if (Length (S) > 0) and ((S [1] = '"') or (Pos (' ', S) <= 0)) then begin
  43. if S [1] = '"' then begin
  44. Delete (S, 1, 1);
  45. if Pos ('"', S) > 0 then
  46. Delete (S, Pos ('"', S), Length (S));
  47. end;
  48. FileName := S;
  49. end;
  50. if Execute then
  51. CommandLineEdit.Text := '"' + FileName + '"';
  52. end;
  53. end;
  54. procedure TToolPropertiesForm.WorkingDirBrowseButtonClick(Sender: TObject);
  55. var
  56. Info: TBrowseInfo;
  57. Path: PItemIDList;
  58. FolderName: array [0..MAX_PATH] of Char;
  59. begin
  60. FillChar (Info, SizeOf (Info), 0);
  61. with Info do begin
  62. hwndOwner := Handle;
  63. lpszTitle := 'Browse';
  64. ulFlags := BIF_RETURNONLYFSDIRS;
  65. end;
  66. Path := SHBrowseForFolder (Info);
  67. if Assigned (Path) then begin
  68. if SHGetPathFromIDList (Path, FolderName) then
  69. WorkingDirEdit.Text := FolderName;
  70. end;
  71. end;
  72. end.