Recent

Author Topic: How to get event from OLE-automation  (Read 15911 times)

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: How to get event from OLE-automation
« Reply #15 on: March 26, 2015, 09:09:28 pm »
I don't known if you've finally solved your problem. So, just in case...

For PowerPoint, events are obtained via the EApplication Interface ('914934C2-5A91-11CF-8700-00AA0060263B'):
https://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.eapplication%28v=office.14%29.aspx

List of available events:
https://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.application_events.aspx

You'll have to know and use the numeric values (i.e. DispIds) of the concerned events in your Invoke procedure : for instance, SlideShowNextSlide -> 2013


And finally, a few code samples (but none in Delphi/Pascal):
- https://support.microsoft.com/en-us/kb/308330
- http://www.textndata.com/forums/powerpoint-events-com-dll-497099.html
- http://comfyj-support.teamdev.com/samples/ms-office/powerpoint-events-handling
« Last Edit: March 26, 2015, 09:12:58 pm by ChrisF »

kyaoga

  • New Member
  • *
  • Posts: 14
  • -[o_o]-
Re: How to get event from OLE-automation
« Reply #16 on: March 28, 2015, 09:55:11 am »
It's   Work.   

Thank you so much ,everbody.    :D 


Now ,
I found that  Lazarus provide TEvenkSink .
 but It differs from  delphi in some Method.

That Object can Detect  DisIDs

like this
Code: [Select]

...

type

  ...
  { TForm1 }
  TForm1 = class(TForm)
 
  ..
  ListBox1 : TListBox;
  ...
 
  private
    { private declarations }

...
    MsOfficeApp   : Variant; //OLEVariant;
    F_SinkEvent : TEvent_TestSink;//TEventSink;
...


...
    procedure _GetEventMsOffice(Sender: TObject; DispID: Integer;
       const IID: TGUID; LocaleID: Integer; Flags: Word;
       Params: tagDISPPARAMS; VarResult, ExcepInfo, ArgErr: Pointer);
...
  public
    { public declarations }
  end;

var
  Form1: TForm1;

{ TForm1 }


procedure TForm1._GetEventMsOffice(Sender: TObject; DispID: Integer;
 const IID: TGUID; LocaleID: Integer; Flags: Word;
 Params: TDispParams; VarResult, ExcepInfo, ArgErr: Pointer);
begin
  //Collect DISP-Event
  ListBox1.Items.add('DISPID = '+ IntToStr(DispID));
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
  MsOfficeApp := UnAssigned;
 
  ...

  //Open MsOffice
  try
    MsOfficeApp := CreateOleObject('PowerPoint.Application');

    ...

F_SinkEvent    := TEvent_TestSink.Create(Form1);
F_SinkEvent.OnInvoke := @(Form1._GetEventMsOffice);
F_SinkEvent.Connect(MsOfficeApp,IID_MSApplication);

...

  except
    ShowMessage('Error...');
    Exit;
  end;
 
  ...
 
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  if Assigned(F_SinkEvent) then F_SinkEvent.Destroy;
  MsOfficeApp.Quit;
  MsOfficeApp := UnAssigned;
end;

...

 

TinyPortal © 2005-2018