Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

А как использовать события в COM?


Nick Denry ©   (2005-08-25 00:50:00) 

И интерфейсы типа IDispatch?

Откуда копать?

С уважением, Nick Denry.


Карелин Артем   (2005-08-29 18:18:00) [1]

мне нравится статья "Обратные вызовы в MIDAS через TSocketConnection" на rsdn.ru


Polevi   (2005-08-25 10:08:00) [2]

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TT = class(TInterfacedObject, IDispatch)
 private
   FMethodName:string;
 protected
   { IDispatch }
   function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
   function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
   function GetIDsOfNames(const IID: TGUID; Names: Pointer;
     NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
   function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
     Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
 end;

 TForm1 = class(TForm)
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

uses ActiveX, ComObj;

{$R *.dfm}

{ TT }

function TT.GetIDsOfNames(const IID: TGUID; Names: Pointer; NameCount,
 LocaleID: Integer; DispIDs: Pointer): HResult;
begin
 if NameCount <> 1 then
   Result := E_NOTIMPL else
 begin
   FMethodName:=WideString(POleStrList(Names)^[0]);
   PDispIdList(DispIDs)^[0] := 0;
   Result:=S_OK;
 end;
end;

function TT.GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult;
begin
 Result := E_NOTIMPL;
end;

function TT.GetTypeInfoCount(out Count: Integer): HResult;
begin
 Count := 0;
 Result := S_OK;
end;

function TT.Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
 Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult;
begin
 ShowMessage(FMethodName);
 Result:=S_OK;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
 x:OleVariant;
begin
 x:=TT.Create as IDispatch;
 x.Test;
end;

end.


Наверх

Титульная страница Поиск, карта сайта Написать письмо