为什么集合元素只有第一个? [英] Why the collection element is available only the first?

查看:109
本文介绍了为什么集合元素只有第一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,通过它指令#import。在其中我创建了新文档,在第一页中我放置了默认使用参数创建的TextFrame。

I have a program with which I work through the directive #import. In it I create the new document and for the first page I place TextFrame which is created with parameters by default.

HRESULT hr = CoInitialize(NULL);
_ApplicationPtr myApp("InDesign.Application");
 
DocumentPtr myDoc = myApp->ActiveDocument;
PagePtr myPage = myDoc->Pages->Item[1L];
TextFramePtr myTextFrame = myPage->TextFrames->Add(); // create frame on Page



现在我想用一个预定义的样本绘制框架。我必须通过FillColor将Swatch的实例赋予帧,即


Now I want to paint frame with one of predefined swatches. I have to give instance of Swatch to frame by FillColor, i.e.

myTextFrame->FillColor = SomeSwatch->Name;



得到了收集:


Got the collection:

SwatchesPtr mySwatches = myApp->Swatches;



获得Swatch实例和Swatch名称:


Got Swatch instance and Swatch Name:

double SwatchCount = mySwatches->Count; //get quantity of elements
std::cout << SwatchCount << std::endl; // SwatchCount = 10
SwatchPtr mySwatch_1 = mySwatches->Item[1L];
_variant_t mySwatchName_1 = mySwatch->Name;



但这里第二个元素不可用:


but here the second element isn't available:

SwatchPtr mySwatch_1 = mySwatches->Item[2L]; // m_pInterface = 0x00000000



如何获得所有元素?


How get all elements?

推荐答案

docs [< a href =http://jongware.mit.edu/idcs6js/pc_Swatches.htmltarget =_ blanktitle =New Window> ^ ]令人困惑



count似乎是指swatch中的元素,length似乎是指数组中的样本数
the docs[^] are perplexing

count would appear to refer to elements in the swatch, length would appear to refer to number of swatches in the array


,因为第一个COM不是c ++! COM没有重载运算符。唯一的功能是ptr-> Item(索引)。通常对于模板智能指针,元素调用返回接口指针,即itemptr = ptr-> Item和你的ptr-> Item [1]将传递itemptr + 1指针增量而不是itemptr-> Item(1)显式调用返回对象。

问候。
for the first COM is not c++! There are no overloaded operators for COM. The only function to that is the ptr->Item(index). Usually for template smart pointers the element calls return Interface pointers i.e. itemptr = ptr->Item and your ptr->Item[1] will deliver itemptr+1 pointer increment not itemptr->Item(1) explicit call on the returned object.
regards.


这篇关于为什么集合元素只有第一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆