home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
cb
/
setup
/
cbuilder
/
data.z
/
OLEREG.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-02-28
|
3KB
|
111 lines
unit OLEReg;
interface
procedure Register;
implementation
uses SysUtils, Classes, DsgnIntf, LibConst, OleCtnrs;
{ TOleContainerEditor }
type
TOleContainerEditor = class(TDefaultEditor)
private
FEditVerbs: TStringList;
public
constructor Create(AComponent: TComponent; ADesigner: TFormDesigner); override;
destructor Destroy; override;
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
constructor TOleContainerEditor.Create(AComponent: TComponent;
ADesigner: TFormDesigner);
begin
inherited Create(AComponent, ADesigner);
FEditVerbs := TStringList.Create;
end;
destructor TOleContainerEditor.Destroy;
begin
FEditVerbs.Free;
inherited Destroy;
end;
procedure TOleContainerEditor.Edit;
begin
with TOleContainer(Component) do
if State <> osEmpty then DoVerb(ovPrimary) else InsertObjectDialog;
end;
procedure TOleContainerEditor.ExecuteVerb(Index: Integer);
var
Action: Integer;
begin
Action := Integer(FEditVerbs.Objects[Index]);
with TOleContainer(Component) do
if Action >= 0 then
DoVerb(Action)
else
case Action of
-1: if InsertObjectDialog and NewInserted then DoVerb(ovOpen);
-2: PasteSpecialDialog;
-3: Copy;
-4: DestroyObject;
-5: ObjectPropertiesDialog;
end;
end;
function TOleContainerEditor.GetVerb(Index: Integer): string;
begin
Result := FEditVerbs[Index];
end;
function TOleContainerEditor.GetVerbCount: Integer;
var
I, P: Integer;
S: string;
begin
with TOleContainer(Component) do
begin
FEditVerbs.Clear;
if State <> osEmpty then
begin
UpdateVerbs;
if ObjectVerbs.Count > 0 then
begin
for I := 0 to ObjectVerbs.Count - 1 do
begin
S := ObjectVerbs[I];
for P := Length(S) downto 1 do
if S[P] = '&' then Delete(S, P, 1);
FEditVerbs.AddObject(S, TObject(I));
end;
FEditVerbs.Add('-');
end;
end;
FEditVerbs.AddObject(LoadStr(SInsertObjectVerb), TObject(-1));
if CanPaste then
FEditVerbs.AddObject(LoadStr(SPasteSpecialVerb), TObject(-2));
if State <> osEmpty then
begin
FEditVerbs.AddObject(LoadStr(SCopyObjectVerb), TObject(-3));
FEditVerbs.AddObject(LoadStr(SDeleteObjectVerb), TObject(-4));
FEditVerbs.AddObject(LoadStr(SObjectPropertiesVerb), TObject(-5));
end;
end;
Result := FEditVerbs.Count;
end;
procedure Register;
begin
RegisterComponents(LoadStr(srSystem), [TOleContainer]);
RegisterComponentEditor(TOleContainer, TOleContainerEditor);
end;
end.