【发布时间】:2015-11-02 17:13:01
【问题描述】:
我的程序必须通过#import 指令与另一个程序进行通信。它创建一个新文档并使用默认参数将 TextFrame 放置在其上
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
TextFramePtr myTextFrame_2 = myPage->TextFrames->Item[2L]; // Get second frame on Page;
TextFrame 对象具有改变帧大小的 GeometricBounds 方法。这是我设置帧大小的代码:
double mySize[4] = {12.7, 12.7, 66.7, 83.2};
SAFEARRAY * Bound;
VARIANT Array;
Array.vt = VT_ARRAY | VT_R8;
Bound = SafeArrayCreateVector(VT_R8, 1, 4);
for (int i = 0; i < 4; i++)
{
long index = i + 1;
SafeArrayPutElement(Bound, &index, &mySize[i]);
}
Array.parray = Bound;
myTextFrame->GeometricBounds = Array;
这是我创建的框架,但如何获取另一个框架的大小,已经存在于文档中?
Property GeometricBounds As Variant TextFrame 的边界(不包括笔划宽度),格式为 [y1, x1, y2, x2],给出边界框左上角和右下角的坐标。作为 4 个单元的数组(双精度或字符串)
TLB文件中方法的描述:
Frame : IDispatch
{
// Property data
__declspec(property(get=GetGeometricBounds,put=PutGeometricBounds))
_variant_t GeometricBounds;
...
// Methods:
void PutGeometricBounds (
const _variant_t & _arg1 );
_variant_t GetGeometricBounds ( );
....
}
【问题讨论】:
-
什么是
myTextFrame? -
myTextFrame - 集合 TextFrames(Interface TextFrames)的元素。我更新了问题