如题
解决方案 »
- 对话框的style是child时如何制作异形窗体
- vc中,有什么控件可以存储一张表格啊?
- 用鼠标在直线上选中一点后拖动该直线, 请问怎样实现?
- 合同到期了,准备新的简历了,哈哈,祝自己好运
- 插入控件带入大量的源文件,有办法把他们放于一个单独的目录吗?
- 大系统多模块,需要多人开发时,VC中怎么分模块呀?
- 用VC写程序时,文件忽然消失,请问是怎么回事?
- 如何将10进制化成16进制?
- 各位大哥,小弟有个问题,我在VC中用的是CDaoDatabase类,这个类为是么在没有装VC的机器上打不开数据源
- 求救,请问各位大虾,在一个软件如何实现不同的语言版本?并且在安装向导中加入中文版和英文版的选择?
- 请问怎样在工具栏里面添加组合框,编辑框等控件
- 急!急!急!我的工程在debug版本下运行正常,但在release下却宕掉
Aggregation
There are times when an object's implementor would like to take advantage of the services offered by another, pre-built object. Furthermore, it would like this second object to appear as a natural part of the first. COM achieves both of these goals through containment and aggregation. Aggregation means that the containing (outer) object creates the contained (inner) object as part of its creation process and the interfaces of the inner object are exposed by the outer. An object allows itself to be aggregatable or not. If it is, then it must follow certain rules for aggregation to work properly. Primarily, all IUnknown method calls on the contained object must delegate to the containing object.怎么实现?
Sample: ADODB.Recordset.Clone() or MSXML.IXMLDomNode.Clone() ...
This method creates a new stream object with its own seek pointer that references the same bytes as the original stream. IXMLDOMNode::cloneNode
The cloned node has the same property values as this nodefor the following properties: nodeName property, nodeValue property, nodeType property, parentNode property, ownerDocument property, and, if it is an element, attributes property. The value of the clone's childNodes property depends on the setting of the deep flag parameter.
...你到底要可龙成什么呀
STDMETHODIMP CComC::Clone(IDispatch **ppDisp)
{
// TODO: Add your implementation code here
CComPtr<IComC> p;
HRESULT hr=p.CoCreateInstance(L"MyCOM.ComC");
if(FAILED(hr))
{
return hr;
}
*ppDisp=(IDispatch*) p.Detach ();
return S_OK;
}客户端测试:
void test()
{
IComCPtr p=NULL;
IComCPtr p2=NULL;
p.CreateInstance (L"MyCom.ComC");
... //可以使用p做一些工作
p2=p->Clone();//可龙了一个p2
p.Release (); //关闭了p
... //还使用p2仍然可以做一些工作
p2.Release ();//关闭p2
}
另外,用你的方法,clone出副本后如何让副本的数据成员与母本的一样?通过属性的读写吗?那要有只读属性呢?
在有你用ATL做过集合吗?