Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.10.29;
Скачать: 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 вся ветка

Текущий архив: 2006.10.29;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.087 c
15-1159902923
EkZot
2006-10-03 23:15
2006.10.29
ПОмогите плз. операции с матрицами.


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


15-1160132726
Layner
2006-10-06 15:05
2006.10.29
Знает ли кто нибудь, почему в Win2003 с последними патчами


3-1157440210
ttt_111
2006-09-05 11:10
2006.10.29
Некорректный вывод числа при работе с БД.


4-1147534057
Sicilla
2006-05-13 19:27
2006.10.29
Строка в системном меню