D
dageming
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我的实验,进行不下去了,请帮忙
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, AxCtrls, OleCtrls, esriControls_TLB,esriCore_TLB,ComObj;
type
TTest = class(Tinterfacedobject,IWorkspaceEditEvents)
protected
function OnStartEditing(withUndoRedo: WordBool): HResult;stdcall;
function OnStopEditing(saveEdits: WordBool): HResult;stdcall;
public
constructor Create(AnAppDispatch: IUnknown; const AnAppDispIntfIID: TGUID);
destructor Destroy; override;
end;
TForm1 = class(TForm)
MapControl1: TMapControl;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
ws:IWorkspace;
ptest:TTest;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
pedit:IWorkspaceEdit;
begin
pedit:=ws as IWorkspaceEdit;
pedit.StartEditing(true);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
flyr:IFeatureLayer;
fcls:IFeatureClass;
pDataset:IDataset;
we:IWorkspaceEditEvents;
obj:variant;
begin
flyr:=mapcontrol1.Layer[0] as IFeatureLayer;
flyr.Get_FeatureClass(fcls);
pDataset:=fcls as IDataset;
pDataset.Get_Workspace(ws);
ws.QueryInterface(IWorkspaceEditEvents,obj);
if varisempty(obj) then
begin
//we:=ws as IWorkspaceEditEvents;
ptest:=TTest.create(ws as IUnknown,WorkspaceEditEvents);
end;
end;
{ TTest }
constructor TTest.Create(AnAppDispatch: IUnknown; const AnAppDispIntfIID: TGUID);
var
f:longint;
begin
InterfaceConnect(AnAppDispatch,AnAppDispIntfIID,self,f);
end;
destructor TTest.Destroy;
begin
inherited;
end;
function TTest.OnStartEditing(withUndoRedo: WordBool): HResult;
begin
showmessage('sadf');
end;
function TTest.OnStopEditing(saveEdits: WordBool): HResult;
begin
end;
end.
怎么样在我开始编辑的时候自动会执行开始编辑事件中的代码?
我看了D:/Program Files/Borland/Delphi5/Demos/Activex/Oleauto/Word8的例子,不解之处很多,请大家帮我提高提高
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, AxCtrls, OleCtrls, esriControls_TLB,esriCore_TLB,ComObj;
type
TTest = class(Tinterfacedobject,IWorkspaceEditEvents)
protected
function OnStartEditing(withUndoRedo: WordBool): HResult;stdcall;
function OnStopEditing(saveEdits: WordBool): HResult;stdcall;
public
constructor Create(AnAppDispatch: IUnknown; const AnAppDispIntfIID: TGUID);
destructor Destroy; override;
end;
TForm1 = class(TForm)
MapControl1: TMapControl;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
ws:IWorkspace;
ptest:TTest;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
pedit:IWorkspaceEdit;
begin
pedit:=ws as IWorkspaceEdit;
pedit.StartEditing(true);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
flyr:IFeatureLayer;
fcls:IFeatureClass;
pDataset:IDataset;
we:IWorkspaceEditEvents;
obj:variant;
begin
flyr:=mapcontrol1.Layer[0] as IFeatureLayer;
flyr.Get_FeatureClass(fcls);
pDataset:=fcls as IDataset;
pDataset.Get_Workspace(ws);
ws.QueryInterface(IWorkspaceEditEvents,obj);
if varisempty(obj) then
begin
//we:=ws as IWorkspaceEditEvents;
ptest:=TTest.create(ws as IUnknown,WorkspaceEditEvents);
end;
end;
{ TTest }
constructor TTest.Create(AnAppDispatch: IUnknown; const AnAppDispIntfIID: TGUID);
var
f:longint;
begin
InterfaceConnect(AnAppDispatch,AnAppDispIntfIID,self,f);
end;
destructor TTest.Destroy;
begin
inherited;
end;
function TTest.OnStartEditing(withUndoRedo: WordBool): HResult;
begin
showmessage('sadf');
end;
function TTest.OnStopEditing(saveEdits: WordBool): HResult;
begin
end;
end.
怎么样在我开始编辑的时候自动会执行开始编辑事件中的代码?
我看了D:/Program Files/Borland/Delphi5/Demos/Activex/Oleauto/Word8的例子,不解之处很多,请大家帮我提高提高