[Ocs-comps-commits] OCS2/Samples/VCL/PluginManager/ETools ConfigureForm.dfm,NONE,1.1 ConfigureForm.p
Brought to you by:
tectsoft
From: Si C. <tec...@us...> - 2005-11-21 10:33:50
|
Update of /cvsroot/ocs-comps/OCS2/Samples/VCL/PluginManager/ETools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10593/Samples/VCL/PluginManager/ETools Added Files: ConfigureForm.dfm ConfigureForm.pas ETools.cfg ETools.dof ETools.dpr ETools.dsk ExternalToolsPluginUnit.pas PropertiesForm.dfm PropertiesForm.pas Log Message: Initially added to source control --- NEW FILE: PropertiesForm.pas --- unit PropertiesForm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, OrckaEdit, StdCtrls, ComCtrls; type TToolProperties = record DisplayName: array[0..40] of char; ProgramName: array[0..500] of char; Path: array[0..500] of char; Parameters: array[0..500] of char; end; TToolsProperties = class(TForm) btnOK: TButton; btnCancel: TButton; TabGeneral: TTabControl; lblDisplayName: TLabel; edtDisplayName: TEdit; lblProgram: TLabel; edtProgram: TOrckaButtonEdit; edtPath: TOrckaButtonEdit; lblPath: TLabel; lblParameters: TLabel; edtParameters: TEdit; OpenDialog: TOpenDialog; procedure btnOKClick(Sender: TObject); procedure edtProgramButtonClick(Sender: TObject); procedure edtPathButtonClick(Sender: TObject); private { Private declarations } public { Public declarations } end; function ShowToolProperties(Parent: HWND; var Properties: TToolProperties): Boolean; implementation uses FileCtrl; {$R *.DFM} resourcestring sNoProgram = '%s'#13'Does not exist'; sNoName = 'You must specify a display name'; sSelPath = 'Select Path'; const sBlank = ''; function ShowToolProperties(Parent: HWND; var Properties: TToolProperties): Boolean; var frm: TToolsProperties; OldParent: HWND; begin OldParent := Application.Handle; Application.Handle := Parent; try frm := TToolsProperties.Create(nil); try frm.edtDisplayName.Text := Properties.DisplayName; frm.edtProgram.Text := Properties.ProgramName; frm.edtPath.Text := Properties.Path; frm.edtParameters.Text := Properties.Parameters; Result := frm.ShowModal = mrOK; if Result then begin StrLCopy(Properties.DisplayName, PChar(frm.edtDisplayName.Text), 40); StrLCopy(Properties.ProgramName, PChar(frm.edtProgram.Text), 500); StrLCopy(Properties.Path, PChar(frm.edtPath.Text), 500); StrLCopy(Properties.Parameters, PChar(frm.edtParameters.Text), 500); end; finally frm.Free; end; finally Application.Handle := OldParent; end; end; procedure TToolsProperties.btnOKClick(Sender: TObject); begin if not FileExists(edtProgram.Text) then begin ShowMessage(Format(sNoProgram, [edtProgram.Text])); Exit; end; if edtDisplayName.Text = sBlank then begin ShowMessage(Format(sNoName, [edtDisplayName.Text])); Exit; end; ModalResult := mrOK; end; procedure TToolsProperties.edtProgramButtonClick(Sender: TObject); begin if OpenDialog.Execute then begin edtProgram.Text := OpenDialog.FileName; if edtPath.Text = sBlank then edtPath.Text := ExtractFilePath(edtProgram.Text); if edtDisplayName.Text = sBlank then edtDisplayName.Text := Copy(ExtractFileName(edtProgram.Text), 1, Length(ExtractFileName(edtProgram.Text)) -4); end; end; procedure TToolsProperties.edtPathButtonClick(Sender: TObject); var Path: string; begin if SelectDirectory(sSelPath, sBlank, Path) then edtPath.Text := Path; end; end. --- NEW FILE: ETools.dpr --- library ETools; uses ExternalToolsPluginUnit in 'ExternalToolsPluginUnit.pas', ConfigureForm in 'ConfigureForm.pas' {Configure}, PropertiesForm in 'PropertiesForm.pas' {ToolsProperties}; {$R *.res} begin end. --- NEW FILE: ETools.dsk --- [Closed Files] File_0=SourceModule,'D:\Program Files\Orcka\Component Suite\Source\OrckaAddinManagerShared.pas',0,1,51,18,58,0,0 File_1=SourceModule,'D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ToolsPlugin.pas',0,1,111,1,129,0,0 File_2=SourceModule,'D:\Program Files\Orcka\Component Suite\Source\OrckaEdit.pas',0,1,22,9,38,0,0 File_3=SourceModule,'D:\Program Files\Orcka\Component Suite\Source\OrckaDV.inc',0,1,94,26,101,0,0 File_4=SourceModule,'D:\Orcka\Source\OrckaScreenSaver.pas',0,1,520,28,526,0,0 File_5=SourceModule,'C:\temp\OrckaScreenSaver.pas',0,1,517,10,531,0,0 File_6=SourceModule,'D:\Orcka\Source\OrckaAddinManager.pas',0,4,137,66,148,0,0 File_7=SourceModule,'D:\Orcka\Source\OrckaAddinManagerShared.pas',0,1,184,83,189,0,0 File_8=SourceModule,'D:\Program Files\Borland\Delphi5\Projects\SyncMemo.pas',0,1,27,1,49,0,0 File_9=SourceModule,'d:\program files\borland\delphi5\source\rtl\Win\Messages.pas',0,1,757,13,773,0,0 [Modules] Module0=D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ExternalToolsPluginUnit.pas Module1=D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ConfigureForm.pas Module2=D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ETools.dpr Module3=D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\PropertiesForm.pas Count=4 EditWindowCount=1 [D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ExternalToolsPluginUnit.pas] ModuleType=SourceModule FormState=0 FormOnTop=0 [D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ConfigureForm.pas] ModuleType=SourceModule FormState=1 FormOnTop=0 [D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ETools.dpr] ModuleType=SourceModule FormState=0 FormOnTop=0 [D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\PropertiesForm.pas] ModuleType=SourceModule FormState=0 FormOnTop=0 [D:\Program Files\Borland\Delphi5\Bin\ProjectGroup1.bpg] FormState=0 FormOnTop=0 [EditWindow0] ViewCount=4 CurrentView=2 View0=0 View1=1 View2=2 View3=3 CodeExplorer=CodeExplorer@EditWindow0 MessageView=MessageView@EditWindow0 Create=1 Visible=1 State=0 Left=271 Top=110 Width=743 Height=546 MaxLeft=-1 MaxTop=-1 ClientWidth=735 ClientHeight=519 LeftPanelSize=0 RightPanelSize=0 BottomPanelSize=0 BottomPanelClients=MessageView@EditWindow0 BottomPanelData=00000400010000000B0000004D657373616765566965770000000000000000000000000000000000FFFFFFFF [View0] Module=D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ETools.dpr CursorX=14 CursorY=4 TopLine=1 LeftCol=1 [View1] Module=D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\PropertiesForm.pas CursorX=1 CursorY=1 TopLine=1 LeftCol=1 [View2] Module=D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ExternalToolsPluginUnit.pas CursorX=65 CursorY=19 TopLine=6 LeftCol=1 [View3] Module=D:\Program Files\Orcka\Component Suite\Samples\VCL\PluginManager\ETools\ConfigureForm.pas CursorX=15 CursorY=93 TopLine=58 LeftCol=1 [Watches] Count=0 [Breakpoints] Count=0 [AddressBreakpoints] Count=0 [Main Window] Create=1 Visible=1 State=0 Left=0 Top=0 Width=1024 Height=105 MaxLeft=-1 MaxTop=-1 ClientWidth=1016 ClientHeight=78 [ProjectManager] Create=1 Visible=1 State=0 Left=0 Top=0 Width=223 Height=477 MaxLeft=-1 MaxTop=-1 ClientWidth=223 ClientHeight=477 TBDockHeight=303 LRDockWidth=438 Dockable=1 [AlignmentPalette] Create=1 Visible=0 State=0 Left=200 Top=107 Width=156 Height=82 MaxLeft=-1 MaxTop=-1 ClientWidth=150 ClientHeight=60 [PropertyInspector] Create=1 Visible=1 State=0 Left=0 Top=0 Width=223 Height=477 MaxLeft=-1 MaxTop=-1 ClientWidth=221 ClientHeight=475 TBDockHeight=494 LRDockWidth=190 Dockable=1 SplitPos=85 ArrangeBy=Name SelectedItem=Name ExpandedItems=Value HiddenCategories=Legacy ShowStatusBar=1 [WatchWindow] Create=1 Visible=0 State=0 Left=10 Top=554 Width=516 Height=179 MaxLeft=-1 MaxTop=-1 ClientWidth=508 ClientHeight=155 TBDockHeight=149 LRDockWidth=421 Dockable=1 [BreakpointWindow] Create=1 Visible=0 State=0 Left=10 Top=554 Width=516 Height=179 MaxLeft=-1 MaxTop=-1 ClientWidth=508 ClientHeight=155 TBDockHeight=197 LRDockWidth=737 Dockable=1 Column0Width=100 Column1Width=75 Column2Width=200 Column3Width=200 Column4Width=75 Column5Width=75 [CallStackWindow] Create=1 Visible=0 State=0 Left=10 Top=554 Width=516 Height=179 MaxLeft=-1 MaxTop=-1 ClientWidth=508 ClientHeight=155 TBDockHeight=161 LRDockWidth=294 Dockable=1 [ModuleWindow] Create=1 Visible=0 State=0 Left=10 Top=554 Width=516 Height=179 MaxLeft=-1 MaxTop=-1 ClientWidth=508 ClientHeight=155 TBDockHeight=118 LRDockWidth=353 Dockable=1 Column0Width=125 Column1Width=100 Column2Width=155 EntryPointPane=225 CompUnitPane=104 [DebugLogView] Create=1 Visible=0 State=0 Left=10 Top=554 Width=516 Height=179 MaxLeft=-1 MaxTop=-1 ClientWidth=508 ClientHeight=155 TBDockHeight=291 LRDockWidth=417 Dockable=1 [CodeExplorer@EditWindow0] Create=1 Visible=1 State=0 Left=0 Top=0 Width=223 Height=477 MaxLeft=-1 MaxTop=-1 ClientWidth=223 ClientHeight=477 TBDockHeight=305 LRDockWidth=140 Dockable=1 [MessageView@EditWindow0] Create=1 Visible=0 State=0 Left=-77 Top=-527 Width=443 Height=52 MaxLeft=-1 MaxTop=-1 ClientWidth=443 ClientHeight=52 TBDockHeight=52 LRDockWidth=443 Dockable=1 [DockHosts] DockHostCount=1 [DockSite0] DockSiteType=1 Create=1 Visible=1 State=0 Left=1 Top=121 Width=258 Height=511 MaxLeft=-1 MaxTop=-1 ClientWidth=250 ClientHeight=487 TBDockHeight=511 LRDockWidth=258 Dockable=1 TabPosition=2 ActiveTab=Exploring ExternalToolsPluginUnit.pas TabDockClients=PropertyInspector,ProjectManager,CodeExplorer@EditWindow0 --- NEW FILE: PropertiesForm.dfm --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ETools.cfg --- -$A8 -$B- -$C- -$D- -$E- -$F- -$G+ -$H+ -$I- -$J- -$K- -$L- -$M- -$N+ -$O+ -$P+ -$Q- -$R- -$S- -$T- -$U- -$V+ -$W- -$X+ -$Y- -$Z1 -cg -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; -H+ -W+ -M -$M16384,1048576 -K$00400000 -E"C:\Projects\nws\plugins" -LE"c:\program files\borland\delphi6\Projects\Bpl" -LN"c:\program files\borland\delphi6\Projects\Bpl" --- NEW FILE: ConfigureForm.dfm --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ETools.dof --- [FileVersion] Version=6.0 [Compiler] A=8 B=0 C=0 D=0 E=0 F=0 G=1 H=1 I=0 J=0 K=0 L=0 M=0 N=1 O=1 P=1 Q=0 R=0 S=0 T=0 U=0 V=1 W=0 X=1 Y=0 Z=1 ShowHints=1 ShowWarnings=1 UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [Linker] MapFile=0 OutputObjs=0 ConsoleApp=1 DebugInfo=0 RemoteSymbols=0 MinStackSize=16384 MaxStackSize=1048576 ImageBase=4194304 ExeDescription= [Directories] OutputDir=C:\Projects\nws\plugins UnitOutputDir= PackageDLLOutputDir= PackageDCPOutputDir= SearchPath= Packages=Vcl50;Vclx50;crbide50;proide50;Vclmid50;Inet50;Inetdb50;Vcldb50;vclado50;dclaxserver50;Vclbde50;vcldbx50;Dss50;VCLIB50;vclie50;NMFast50;dclocx50;Qrpt50;VclSmp50;TeeUI50;TeeDB50;Tee50;TeeQR50;webmid50;direct50;dphcrb50;rcpkg50;stride50;OrckaD5;ras;Lynx;Trayicon Conditionals= DebugSourceDirs= UsePackages=0 [Parameters] RunParams= HostApplication=D:\Program Files\Other\TB2K\Demo\Project1.exe Launcher= UseLauncher=0 DebugCWD= [Language] ActiveLang= ProjectLang=$00000809 RootDir= [Version Info] IncludeVerInfo=1 AutoIncBuild=1 MajorVer=2 MinorVer=0 Release=0 Build=27 Debug=0 PreRelease=0 Special=0 Private=0 DLL=1 Locale=2057 CodePage=1252 [Version Info Keys] CompanyName=Orcka Development FileDescription=External Tools Plugin FileVersion=2.0.0.27 InternalName=etools.dll LegalCopyright=Copyright © 1999 - 2002. Orcka Development. All Rights Reserved. LegalTrademarks= OriginalFilename=etools ProductName=Orcka Plugin Manager ProductVersion=2.0 Comments= [HistoryLists\hlUnitAliases] Count=1 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [HistoryLists\hlOutputDirectorry] Count=3 Item0=C:\Projects\nws\plugins Item1=D:\Program Files\Orcka\Project1\Plugins Item2=D:\Program Files\Orcka\Project1 --- NEW FILE: ExternalToolsPluginUnit.pas --- unit ExternalToolsPluginUnit; interface uses Windows, Messages, Classes, OrckaPluginManagerShared; type TExternalMenu = record Menu: TOMenuItem; Path: TLargeString; Executable: TLargeString; Paramaters: TLargeString; end; pExternalMenu = ^TExternalMenu; TExternalToolsPlugin = class(TPluginClient) private FService: TPluginServices; FDynamicMenus: TList; FToolsCreated: Boolean; (* Button's *) FToolsConfig: TOButtonItem; (* Menu's *) FmnuTools: TOMenuItem; FmnuToolsSep: TOMenuItem; FmnuToolsConfig: TOMenuItem; protected (* Button Click Events *) procedure ToolsConfigClickEvent(Sender: TOButtonItem); (* Menu Click Events *) procedure MenuToolsCongifClickEvent(Sender: TOMenuITem); procedure LoadExternalTools(Parent: TOMenuItem); procedure ShowConfig; procedure UnloadExternalTools; procedure ExternalClick(Sender: TOMenuItem); public constructor CreateNew(AService: TPluginServices); destructor Destroy; override; (* Returns the name of the plugin *) function GetName: TMediumString; override; (* Functions which control the creation and deletion of menu items and toolbar buttons *) procedure CreateMenuItems; override; procedure DeleteMenuItems; override; procedure CreateButtons; override; procedure DeleteButtons; override; (* General functions for applications, can be used to control open/save/close/create documents, Close the application *) procedure Open(PEType: TPluginEventType; var Name: TLargeString; var Handled: Boolean); override; procedure Save(PEType: TPluginEventType; var Name: TLargeString; var Handled: Boolean); override; procedure BeforeClose(PEType: TPluginEventType; var Cancel: Boolean); override; procedure AfterClose(PEType: TPluginEventType); override; procedure BeforeNew(PEType: TPluginEventType; var Cancel: Boolean); override; procedure AfterNew(PEType: TPluginEventType); override; (* Application Events *) procedure OnActivate; override; procedure OnDeactivate; override; procedure OnMinimize; override; procedure OnRestore; override; procedure OnException(ClassName: TMediumString; ErrorMessage: TLargeString); override; procedure OnHelp(Command: Word; Data: Longint; var CallHelp: Boolean); override; procedure OnHint; override; procedure OnIdle(var Done: Boolean); override; procedure OnMessage(var Msg: TMsg; var Handled: Boolean); override; procedure OnSettingsChanged(Flag: Integer; const Section: string; var Result: Longint); override; procedure OnShortCut(var Msg: TWMKey; var Handled: Boolean); override; end; implementation uses SysUtils, ShellAPI, ConfigureForm; var Plugin: TExternalToolsPlugin = nil; const sBlank = ''; resourcestring sHelpFile = 'Help File'; sTopic = 'Help Topic'; sCaption = 'Display Name'; sProgram = 'Executable'; sPath = 'Path'; sParams = 'Parameters'; sDelete = 'Are you sure you want to delete %s.'; sTitle = 'Tools Configuration'; sNewToolReg = '%s\%s\'; sRegFail = 'Failed to create an entry in the registry.'; sToolExist = '%s is already configured.'; procedure PluginUnload; stdcall; begin Plugin.Free; end; function PluginLoad(InParams: TOrckaPluginManagerParams; var ExitProc: Pointer): Boolean; stdcall; begin Result := True; try Plugin := TExternalToolsPlugin.CreateNew(TPluginServices(InParams.PluginService)); ExitProc := @PluginUnload; except Result := False; end; end; procedure PluginDescription(var Name, Description: TMediumString); stdcall; begin FillChar(Name, SizeOf(TMediumString), 0); StrPCopy(Name, 'External Tools '); FillChar(Description, SizeOf(TMediumString), 0); StrPCopy(Description, 'External Tools Plugin Manages external applications'); end; exports PluginLoad name OrckaPluginManagerExportProc2, PluginDescription name OrckaPluginManagerDescription; { TNewPlugin } { Button Click Events } procedure TExternalToolsPlugin.ToolsConfigClickEvent(Sender: TOButtonItem); begin ShowConfig; end; { Standard methods } procedure TExternalToolsPlugin.AfterClose(PEType: TPluginEventType); begin end; procedure TExternalToolsPlugin.AfterNew(PEType: TPluginEventType); begin end; procedure TExternalToolsPlugin.BeforeClose(PEType: TPluginEventType; var Cancel: Boolean); begin end; procedure TExternalToolsPlugin.BeforeNew(PEType: TPluginEventType; var Cancel: Boolean); begin end; procedure TExternalToolsPlugin.CreateButtons; begin (* Add the Toolbar's *) //FService.InsertToolbar(StringToOString('Tools')); (* Insert the Button's *) //FToolsConfig := FService.InsertButton(1, StringToOString('Tools'), // StringToOString('Configure Tools'), ToolsConfigClickEvent); //FToolsConfig.SetCaption('Tools'); end; procedure TExternalToolsPlugin.CreateMenuItems; var mnu: TOMenuItem; begin mnu := FService.FindMenu('Tools'); if not Assigned(mnu) then FmnuTools := FService.InsertMenu(FService.GetMenuCount -1, nil, StringToOString('&Tools'), nil) else FmnuTools := mnu; FmnuToolsConfig := FService.InsertMenu(fmnuTools.GetItemCount -1, FmnuTools, StringToOString('&Configure'), MenuToolsCongifClickEvent); LoadExternalTools(FmnuTools); end; constructor TExternalToolsPlugin.CreateNew(AService: TPluginServices); begin inherited Create; FDynamicMenus := TList.Create; FToolsCreated := False; FService := AService; FService.PluginClientInsert(Self); FService.PluginClientIncludeAppEvent(Self, poAllowInsertToolbars); FService.PluginClientIncludeAppEvent(Self, poAllowRemoveToolbars); end; procedure TExternalToolsPlugin.DeleteButtons; begin (* Remove the Button's *) //FService.RemoveButton(FToolsConfig); (* Remove the Toolbar's *) FService.DeleteToolbar(StringToOString('Tools')); end; procedure TExternalToolsPlugin.DeleteMenuItems; begin end; destructor TExternalToolsPlugin.Destroy; begin FService.PluginClientExcludeAppEvent(Self, poAllowInsertToolbars); FService.PluginClientExcludeAppEvent(Self, poAllowRemoveToolbars); FService.PluginClientRemove(Self); FDynamicMenus.Free; inherited Destroy; end; function TExternalToolsPlugin.GetName: TMediumString; begin Result := StringToOString('External Tools '); end; procedure TExternalToolsPlugin.OnActivate; begin end; procedure TExternalToolsPlugin.OnDeactivate; begin end; procedure TExternalToolsPlugin.OnException(ClassName: TMediumString; ErrorMessage: TLargeString); begin end; procedure TExternalToolsPlugin.OnHelp(Command: Word; Data: Integer; var CallHelp: Boolean); begin end; procedure TExternalToolsPlugin.OnHint; begin end; procedure TExternalToolsPlugin.OnIdle(var Done: Boolean); begin end; procedure TExternalToolsPlugin.OnMessage(var Msg: TMsg; var Handled: Boolean); begin end; procedure TExternalToolsPlugin.OnMinimize; begin end; procedure TExternalToolsPlugin.OnRestore; begin end; procedure TExternalToolsPlugin.OnSettingsChanged(Flag: Integer; const Section: string; var Result: Integer); begin end; procedure TExternalToolsPlugin.OnShortCut(var Msg: TWMKey; var Handled: Boolean); begin end; procedure TExternalToolsPlugin.Open(PEType: TPluginEventType; var Name: TLargeString; var Handled: Boolean); begin end; procedure TExternalToolsPlugin.Save(PEType: TPluginEventType; var Name: TLargeString; var Handled: Boolean); begin end; procedure TExternalToolsPlugin.LoadExternalTools(Parent: TOMenuItem); var Caption: string; Menu: pExternalMenu; sl: TStringList; I, ToolCount: Longint; begin ToolCount := FService.ReadInteger('External Tools', 'Tool Count', 0); if ToolCount > 0 then begin sl := TStringList.Create; try for I := 1 to ToolCount do sl.Add(Format('ETool%d', [I])); for I := 0 to sl.Count -1 do begin Caption := FService.ReadString('External Tools', StringToOString(sl[I] + sCaption), sBlank); if Caption <> sBlank then begin GetMem(Menu, SizeOf(TExternalMenu)); Menu^.Menu := FService.InsertMenu(Parent.GetItemCount, Parent, StringToOString(Caption), ExternalClick); StrPCopy(Menu^.Executable, FService.ReadString('External Tools', StringToOString(sl[I] + sProgram), '')); StrPCopy(Menu.Path, FService.ReadString('External Tools', StringToOString(sl[I] + sPath), '')); StrPCopy(Menu^.Paramaters, FService.ReadString('External Tools', StringToOString(sl[I] + sParams), '')); FDynamicMenus.Add(Menu); end; end; finally sl.Free; end; if FDynamicMenus.Count > 0 then FmnuToolsSep := FService.InsertMenu(FmnuToolsConfig.GetItemCount +1, FmnuTools, '-', nil); end; end; procedure TExternalToolsPlugin.ExternalClick(Sender: TOMenuItem); var I: Longint; Menu: pExternalMenu; begin for I := 0 to FDynamicMenus.Count -1 do begin Menu := pExternalMenu(FDynamicMenus.Items[I]); if Menu^.Menu = Sender then begin if ShellExecute(FService.GetHandle, 'open', Menu^.Executable, Menu^.Paramaters, Menu^.Path, SW_SHOW) < 32 then begin FService.MsgBox(StringToOString(SysErrorMessage(GetLastError)), MB_OK or MB_ICONSTOP); end; Break; end; end; end; procedure TExternalToolsPlugin.ShowConfig; var HelpFile: string; TopicID: Longint; begin HelpFile := FService.ReadString('External Tools', StringToOString(sHelpFile), sBlank); TopicID := FService.ReadInteger('External Tools', StringToOString(sTopic), 0); UnloadExternalTools; if HelpFile = sBlank then ShowConfigure(FService.GetHandle, FService, nil, TopicID) else ShowConfigure(FService.GetHandle, FService, PChar(HelpFile), TopicID); LoadExternalTools(FmnuTools); end; procedure TExternalToolsPlugin.UnloadExternalTools; var I: Longint; Menu: pExternalMenu; begin for I := FDynamicMenus.Count -1 downto 0 do begin Menu := pExternalMenu(FDynamicMenus.Items[I]); FService.RemoveMenu(Menu^.Menu); FDynamicMenus.Items[I] := nil; FreeMem(Menu); end; FDynamicMenus.Pack; if Assigned(FmnuToolsSep) then begin FService.RemoveMenu(FmnuToolsSep); FmnuToolsSep := nil; end; end; procedure TExternalToolsPlugin.MenuToolsCongifClickEvent( Sender: TOMenuITem); begin ShowConfig; end; end. --- NEW FILE: ConfigureForm.pas --- unit ConfigureForm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ImgList, ComCtrls, Menus, OrckaPluginManagerShared; type TConfigure = class(TForm) btnClose: TButton; btnHelp: TButton; grpTools: TGroupBox; btnAdd: TButton; btnModify: TButton; btnDelete: TButton; lstTools: TListView; ilSmall: TImageList; ilLarge: TImageList; mnuPopup: TPopupMenu; mnuPopupLargeIcons: TMenuItem; mnuPopupSmallIcons: TMenuItem; mnuPopupList: TMenuItem; mnuPopupDetails: TMenuItem; procedure btnHelpClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure mnuPopupLargeIconsClick(Sender: TObject); procedure mnuPopupSmallIconsClick(Sender: TObject); procedure mnuPopupListClick(Sender: TObject); procedure mnuPopupDetailsClick(Sender: TObject); procedure lstToolsSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); procedure btnDeleteClick(Sender: TObject); procedure btnAddClick(Sender: TObject); procedure btnModifyClick(Sender: TObject); private FHelpFile: string; FTopic: Cardinal; FRegLoc: string; procedure DisplayExternalTools; protected FService: TPluginServices; public property HelpFile: string read FHelpFile write FHelpFile; property Topic: Cardinal read FTopic write FTopic; property RegLoc: string read FRegLoc write FRegLoc; end; procedure ShowConfigure(Parent: HWND; AService: TPluginServices; HelpFile: PChar; TopicID: Cardinal); const sBlank = ''; sDefaultReg = 'Software\Orcka\Clients\Tools\%s'; resourcestring sCaption = 'Display Name'; sProgram = 'Executable'; sPath = 'Path'; sParams = 'Parameters'; sDelete = 'Are you sure you want to delete %s.'; sTitle = 'Tools Configuration'; sNewToolReg = '%s\%s\'; sRegFail = 'Failed to create an entry in the registry.'; sToolExist = '%s is already configured.'; implementation uses ShellAPI, PropertiesForm; {$R *.DFM} procedure ShowConfigure(Parent: HWND; AService: TPluginServices; HelpFile: PChar; TopicID: Cardinal); var Configure: TConfigure; OldParent: HWND; begin OldParent := Application.Handle; Application.Handle := Parent; Configure := TConfigure.Create(nil); try Configure.Caption := sTitle; if not Assigned(HelpFile) then Configure.btnHelp.Visible := False else begin Configure.FHelpFile := HelpFile; Configure.Topic := TopicID; end; Configure.FService := AService; Configure.ShowModal; finally Configure.Free; end; Application.Handle := OldParent; end; procedure TConfigure.btnHelpClick(Sender: TObject); begin Application.HelpFile := HelpFile; if Topic = 0 then Application.HelpCommand(HELP_CONTENTS, Topic) else Application.HelpCommand(HELP_CONTEXT, Topic); end; procedure TConfigure.DisplayExternalTools; var sl: TStringList; I, ToolCount: Longint; li: TListItem; Icon: TIcon; SIcon, LIcon: HICON; begin lstTools.Items.Clear; sl := TStringList.Create; try ToolCount := FService.ReadInteger('External Tools', 'Tool Count', 0); for I := 0 to ToolCount do sl.Add(Format('ETool%d', [I])); for I := 0 to sl.Count -1 do begin li := lstTools.Items.Add; li.Caption := FService.ReadString('External Tools', StringToOString(sl[I] + sCaption), sBlank); if li.Caption = sBlank then li.Delete else begin li.SubItems.Add(FService.ReadString('External Tools', StringToOString(sl[I] + sProgram), '')); li.SubItems.Add(FService.ReadString('External Tools', StringToOString(sl[I] + sPath), '')); li.SubItems.Add(FService.ReadString('External Tools', StringToOString(sl[I] + sParams), '')); li.SubItems.Add(sl[i]); Icon := TIcon.Create; try if ExtractIconEx(PChar(OStringToString(FService.ReadString( 'External Tools', StringToOString(sl[I] + sProgram), ''))), 0, LIcon, SIcon, 1) < 2 then begin li.ImageIndex := 0; end else begin Icon.Handle := LIcon; li.ImageIndex := ilLarge.AddIcon(Icon); Icon.Handle := SIcon; ilSmall.AddIcon(Icon); end; finally Icon.Free; end; end; end; finally sl.Free; end; end; procedure TConfigure.FormShow(Sender: TObject); begin DisplayExternalTools; end; procedure TConfigure.mnuPopupLargeIconsClick(Sender: TObject); begin lstTools.ViewStyle := vsIcon; end; procedure TConfigure.mnuPopupSmallIconsClick(Sender: TObject); begin lstTools.ViewStyle := vsSmallIcon; end; procedure TConfigure.mnuPopupListClick(Sender: TObject); begin lstTools.ViewStyle := vsList; end; procedure TConfigure.mnuPopupDetailsClick(Sender: TObject); begin lstTools.ViewStyle := vsReport; end; procedure TConfigure.lstToolsSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); begin btnModify.Enabled := Assigned(lstTools.Selected); btnDelete.Enabled := Assigned(lstTools.Selected); end; procedure TConfigure.btnDeleteClick(Sender: TObject); var li: TListItem; begin li := lstTools.Selected; if Assigned(li) then begin if MessageBox(Handle, PChar(Format(sDelete, [li.Caption])), PChar(sTitle), MB_YESNO or MB_ICONSTOP) = IDYes then begin FService.WriteString('External Tools', StringToOString(li.SubItems[3] + sCaption), StringToOString(sBlank)); FService.WriteString('External Tools', StringToOString(li.SubItems[3] + sProgram), StringToOString(sBlank)); FService.WriteString('External Tools', StringToOString(li.SubItems[3] + sPath), StringToOString(sBlank)); FService.WriteString('External Tools', StringToOString(li.SubItems[3] + sParams), StringToOString(sBlank)); li.Delete; lstTools.AlphaSort; end; end; end; procedure TConfigure.btnAddClick(Sender: TObject); var Prop: TToolProperties; Count: longint; begin if ShowToolProperties(Handle, Prop) then begin Count := FService.ReadInteger('External Tools', 'Tool Count', 0) + 1; FService.WriteInteger('External Tools', 'Tool Count', Count); FService.WriteString('External Tools', StringToOString(Format('ETool%d', [Count]) + sCaption), StringToOString(Prop.DisplayName)); FService.WriteString('External Tools', StringToOString(Format('ETool%d', [Count]) + sProgram), StringToOString(Prop.ProgramName)); FService.WriteString('External Tools', StringToOString(Format('ETool%d', [Count]) + sPath), StringToOString(Prop.Path)); FService.WriteString('External Tools', StringToOString(Format('ETool%d', [Count]) + sParams), StringToOString(Prop.Parameters)); DisplayExternalTools; end; end; procedure TConfigure.btnModifyClick(Sender: TObject); var Prop: TToolProperties; li: TListItem; begin li := lstTools.Selected; if not Assigned(li) then Exit; StrPCopy(Prop.DisplayName, li.Caption); StrLCopy(Prop.ProgramName, PChar(li.SubItems[0]), 500); StrLCopy(Prop.Path, PChar(li.SubItems[1]), 500); StrLCopy(Prop.Parameters, PChar(li.SubItems[2]), 500); if ShowToolProperties(Handle, Prop) then begin FService.WriteString('External Tools', StringToOString(li.SubItems[3] + sCaption), StringToOString(Prop.DisplayName)); FService.WriteString('External Tools', StringToOString(li.SubItems[3] + sProgram), StringToOString(Prop.ProgramName)); FService.WriteString('External Tools', StringToOString(li.SubItems[3] + sPath), StringToOString(Prop.Path)); FService.WriteString('External Tools', StringToOString(li.SubItems[3] + sParams), StringToOString(Prop.Parameters)); DisplayExternalTools; end; end; end. |