Вниз
Скачать: 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.027 c
2-1160992971
vegarulez
2006-10-16 14:02
2006.10.29
Народ, подскажите компоненту для обмена по протоколу HTTPS.


9-1137705526
Аццкий_рыцарь:)
2006-01-20 00:18
2006.10.29
Освещение в DelphiX...


4-1149350507
chizra
2006-06-03 20:01
2006.10.29
надо перехватить окно в модальном режиме


15-1160220729
TUser
2006-10-07 15:32
2006.10.29
Каким был русский язык совсем недавно?


2-1161068983
Silica
2006-10-17 11:09
2006.10.29
Построение графика функции




   Наверх