Вниз
Скачать: CL | DM;

А как использовать события в COM?   Найти похожие ветки 

← →
Nick Denry ©   (2005-08-25 00:50) [0]

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

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

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


← →
Polevi ©   (2005-08-25 10:08) [1]

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.


← →
Карелин Артем ©   (2005-08-29 18:18) [2]

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



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.026 c
15-1159959558
Knight
2006-10-04 14:59
2006.10.29
Есть компонент в котором реализуется функциона из статьи Роуза?


1-1158443057
Pavel__
2006-09-17 01:44
2006.10.29
LoadIcon и Windows Vista


1-1158676217
Express
2006-09-19 18:30
2006.10.29
MDI-дочерная форма из библиотеки


15-1160535420
SerJaNT
2006-10-11 06:57
2006.10.29
Настройка aDSL-модема "aDSL-200"


2-1160458972
Alina
2006-10-10 09:42
2006.10.29
Базы в Делфи.




   Наверх