彩票走势图

如何使用Wrapper组件的新对象和功能?

原创|其它|编辑:郝浩|2012-08-20 02:13:21.000|阅读 452 次

概述:Wrapper组件是一个可以在vd6和C++6环境中使用的COM控件。我们可将实现文件.tlb添加至项目引用使应用程序获得新的组件功能。要想了解更多的信息和实现方式,你可以联系我们获得更多的细节。导出的tlb文件:

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

Wrapper组件是一个可以在vd6和C++6环境中使用的COM控件。我们可将实现文件.tlb添加至项目引用使应用程序获得新的组件功能。要想了解更多的信息和实现方式,你可以联系我们获得更多的细节。导出的tlb文件: VectorDraw.Serialize.tlbVectorDraw.Render.tlbVectorDraw.
Professional.tlbVectorDraw.Geometry.tlbVectorDraw.Actions.
tlbVdrawPro5.tlbvdrawi5.tlbvdPropertyGrid.tlbVdProControl.tlb

解决方案

下面的示例代码实现了wrapper组件,代码中使用一个按钮添加了一个vdMtext对象,它完全是一个新的对象,在新库中被实现而在版本5中并不存在。为实现该组件,我们导入了 VectorDraw.Geometry.tlb ,VectorDraw.Professional.tlb以及 vdrawi5.tlb

VB6示例代码:

Private Sub Command1_Click()
'Get the document interface of VectorDraw FrameWork
Dim doc As VectorDraw_Professional.vdDocument
Set doc = VDraw1.ActiveDocument.WrapperObject
'Create a new Mtext object with VDF Interfaces
Dim mtext As VectorDraw_Professional.vdMText
Set mtext = New VectorDraw_Professional.vdMText
'typecast the Mtext as vdbaseObject
Dim baseobj As VectorDraw_Professional.vdBaseObject
Set baseobj = mtext
baseobj.SetUnRegisterDocument doc

'typecast the Mtext as vdPrimary
Dim primary As VectorDraw_Professional.vdPrimary
Set primary = mtext
primary.setDocumentDefaults
'Create a gPoint object
Dim pt As VectorDraw_Geometry.gPoint
Set pt = New VectorDraw_Geometry.gPoint
pt.SetValue 2, 3, 0

'set values in some properties of mtext
mtext.TextString = "VectorDraw Mtext using VDF Interfaces"
Set mtext.InsertionPoint = pt
mtext.BoxWidth = 12
mtext.Height = 1#
'typecast the Mtext as vdFigure
Dim fig As VectorDraw_Professional.vdFigure
Set fig = mtext

'add mtext in the collection entities table
doc.ActiveLayOut.entities.AddItem fig
primary.Update
fig.Invalidate

VDraw1.CommandAction.Zoom "e", 0, 0
End Sub

C++示例代码:

void Cvd6WrapperDlg::OnBnClickedMtext()
{
//Get the document interface of VectorDraw FrameWork
VectorDraw_Professional::IvdDocumentPtr doc = m_vdraw.GetActiveDocument().GetWrapperObject();

//Create a new Mtext object with VectorDraw FrameWork Interfaces
VectorDraw_Professional::IvdMTextPtr mtext(__uuidof(VectorDraw_Professional::vdMText));

//typecast the Mtext as vdbaseObject
VectorDraw_Professional::IvdBaseObjectPtr baseobj = (VectorDraw_Professional::IvdBaseObjectPtr)mtext;
baseobj->SetUnRegisterDocument(doc);

//typecast the Mtext as vdPrimary
VectorDraw_Professional::IvdPrimaryPtr primary = (VectorDraw_Professional::IvdPrimaryPtr)mtext;
primary->setDocumentDefaults();

//Create a gPoint object;
VectorDraw_Geometry::IgPointPtr pt(__uuidof(VectorDraw_Geometry::gPoint));
pt->SetValue(2,3,0);

//set values in some properties of mtext
mtext->PutRefInsertionPoint(pt);
mtext->PutTextString("Vectordraw Mtext using VectorDrawFramework Interfaces");
mtext->PutBoxWidth(12);
mtext->PutHeight(1.0);

//typecast the Mtext as vdFigure
VectorDraw_Professional::IvdFigurePtr figure = (VectorDraw_Professional::IvdFigurePtr)mtext;

//add mtext in the collection entities table
doc->ActiveLayOut->Entities->AddItem(figure);
primary->Update();
figure->Invalidate();
m_vdraw.GetCommandAction().Zoom(COleVariant(_T("e")),COleVariant(),COleVariant());
}

Delphi 7示例代码:

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, SHDocVw, AxCtrls, OleCtrls,
VDrawLib5_TLB, VDrawI5_TLB, VectorDraw_Professional_TLB, VectorDraw_Geometry_TLB;

procedure TForm1.Button1Click(Sender: TObject);
var
mtext : VectorDraw_Professional_TLB.IvdMText;
pt : VectorDraw_Geometry_TLB.Igpoint;
doc : VectorDraw_Professional_TLB.IvdDocument;
primary : VectorDraw_Professional_TLB.IvdPrimary;
baseobject : VectorDraw_Professional_TLB.IvdBaseObject;

begin
doc := vdrawpro.ActiveDocument.WrapperObject as VectorDraw_Professional_TLB.IvdDocument;
pt := VectorDraw_Geometry_TLB.CogPoint.Create();
pt.SetValue(2,3,0);
mtext := VectorDraw_Professional_TLB.CovdMText.Create();
baseobject := mtext as VectorDraw_Professional_TLB.IvdBaseObject;
baseobject.SetUnRegisterDocument(doc);
primary:=mtext as VectorDraw_Professional_TLB.IvdPrimary;
primary.setDocumentDefaults();
mtext.TextString := 'VectorDraw Mtext using VDF Interfaces';
mtext.InsertionPoint := pt;
mtext.BoxWidth := 12;
mtext.Height := 1;
doc.ActiveLayOut.entities.AddItem(mtext as VectorDraw_Professional_TLB.IvdFigure);
vdrawpro.CommandAction.Zoom('E',0,0);
end;

procedure TForm1.Button2Click(Sender: TObject);
var vdGPts : VectorDraw_Geometry_TLB.Igpoints;
doc : VectorDraw_Professional_TLB.IvdDocument;
primary : VectorDraw_Professional_TLB.IvdPrimary;
baseobject : VectorDraw_Professional_TLB.IvdBaseObject;
vdGPt : VectorDraw_Geometry_TLB.Igpoint;
GS : VectorDraw_Professional_TLB.IvdGroundSurface;
I : integer;

begin
vdraw1.DisplayFrames:=63;
vdraw1.StatusBar:=true;
vdraw1.StatusBarMenu:=true;
vdraw1.EnableAutoGripOn:=true;

doc := vdraw1.ActiveDocument.WrapperObject as VectorDraw_Professional_TLB.IvdDocument;

vdGPts := VectorDraw_Geometry_TLB.CogPoints.Create();
for I:=1 to 8 do // create a ground sourface from 8 points
begin
vdGPt := VectorDraw_Geometry_TLB.CogPoint.Create();
vdGPts.Add(vdGpt);
end;

vdGPTs.Item[0].SetValue(2,3,0);
vdGPTs.Item[1].SetValue(2,5,1);
vdGPTs.Item[2].SetValue(4,5,1.5);
vdGPTs.Item[3].SetValue(4,3,1);
vdGPTs.Item[4].SetValue(7,3,2);
vdGPTs.Item[5].SetValue(7,5,0.5);
vdGPTs.Item[6].SetValue(9,3,0.3);
vdGPTs.Item[7].SetValue(9,5,0.5);

GS := VectorDraw_Professional_TLB.CovdGroundSurface.Create();
baseobject := GS as VectorDraw_Professional_TLB.IvdBaseObject;
baseobject.SetUnRegisterDocument(doc);
primary:=GS as VectorDraw_Professional_TLB.IvdPrimary;
primary.setDocumentDefaults();
GS.Points := vdGPts;
GS.MeshSize := 0.1;
GS.DispMode := DisplayMode_Mesh;//DisplayMode_Triangle;
doc.ActiveLayOut.entities.AddItem(GS as VectorDraw_Professional_TLB.IvdFigure);
vdraw1.CommandAction.View3D('VISE');
vdraw1.CommandAction.Zoom('E',0,0);
end;


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP