使用Delphi,顯示ActiveX控制元件的屬性頁方法
阿新 • • 發佈:2019-02-13
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, MSCommLib_TLB, StdCtrls, ActiveX, OLECtl;
type
TForm1 = class(TForm)
MSComm1: TMSComm;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Spec: ISpecifyPropertyPages;
XObj: IMSComm;
auuid: TCAGUID;
begin
XObj := MSComm1.DefaultInterface;
try
if XObj.QueryInterface(System.TGUID(IID_ISpecifyPropertyPages), Spec)=S_OK then
begin
Spec.GetPages(auuid);
try
OleCreatePropertyFrame(Handle, 30, 30, nil, 1, @XObj, auuid.cElems, auuid.pElems, 0, 0, nil);
CoTaskMemFree(auuid.pElems);
finally
Spec:= nil;
end;
end;
finally
XObj:= nil;
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, MSCommLib_TLB, StdCtrls, ActiveX, OLECtl;
type
TForm1 = class(TForm)
MSComm1: TMSComm;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Spec: ISpecifyPropertyPages;
XObj: IMSComm;
auuid: TCAGUID;
begin
XObj := MSComm1.DefaultInterface;
try
if XObj.QueryInterface(System.TGUID(IID_ISpecifyPropertyPages), Spec)=S_OK then
begin
Spec.GetPages(auuid);
try
OleCreatePropertyFrame(Handle, 30, 30, nil, 1, @XObj, auuid.cElems, auuid.pElems, 0, 0, nil);
CoTaskMemFree(auuid.pElems);
finally
Spec:= nil;
end;
end;
finally
XObj:= nil;
end;
end;
end.