構文
BOOL GetString(BSTR * szStr, double *dXPos, double *dYPos,
BSTR * szFontName,
double *dHeight, BYTE * byFontAttr,
BYTE * byAlign, double * dAngle, OLE_COLOR * ocFontColor);
(JavaScript用) string GetStringJS();
カレントのオブジェクトが、文字列の場合、その情報を取得します。
パラメータ
szStr
文字列。
dXPos
配置位置X座標。
dYPos
配置位置Y座標。
szFontName
フォント名。
dHeight
フォントサイズ。
byFontAttr
フォント属性。次のフラグの任意の組み合わせを指定できます。
- 1斜体。
- 2太字。
- 4下線。
byAlign
位置合わせ。次のフラグの組み合わせを指定できます。
- 0水平方向/左寄せ。
- 1水平方向/中央。
- 2水平方向/右寄せ。
- 0垂直方向/上寄せ。
- 16垂直方向/中央。
- 32垂直方向/下寄せ。
dAngle
角度。
crFontColor
色。
戻り値
文字列の情報を取得できた場合 0 以外を返します。できなかった場合は 0 を返します。
使用例
// 間取りオブジェクトへ接続
CMadoriDoc * m_MadoriDoc = new CMadoriDoc();
CLSIDFromProgID (L"MyHomeDesignerMadori.MadoriDoc", &clsid);
GetActiveObject (clsid, NULL, &pUnk);
pUnk->QueryInterface (IID_IDispatch, (void**)(&pDisp));
m_MadoriDoc->AttachDispatch (pDisp);
// 列挙する
long lRet = m_MadoriDoc->GetTopObject();
if(lRet == 0) AfxMessageBox(TEXT("何もない"));
while(lRet){
ULONG uType = m_MadoriDoc->GetCurrentObjectType();
short nLayer = m_MadoriDoc->GetCurrentObjectLayer();
CString strMsg;
strMsg.Format(TEXT("[%X]type[%d]layer[%d]"), lRet, uType,nLayer);
AfxMessageBox(strMsg);
switch(uType){
case 6: // string
{
BSTR szStr = NULL;
double dXPos, dYPos;
BSTR szFontName = NULL;
double dHeight;
unsigned char byFontAttr, byAlign;
double dAngle;
unsigned long ocFontColor;
m_MadoriDoc->GetString(&szStr, &dXPos, &dYPos, &szFontName, &dHeight, &byFontAttr, &byAlign, &dAngle, &ocFontColor);
CString strFontName;
AfxBSTR2CString(&strFontName, szFontName);
CString strStr;
AfxBSTR2CString(&strStr, szStr);
strMsg.Format(TEXT("String str[%s]pos[%lf,%lf]font[%s]h[%lf]attr[%x]align[%x]angle[%lf]col[%x]"),
strStr, dXPos, dYPos,strFontName,dHeight, byFontAttr, byAlign, dAngle, ocFontColor);
AfxMessageBox(strMsg);
if(szStr){
::SysFreeString(szStr);
}
if(szFontName){
::SysFreeString(szFontName);
}
}
break;
}
lRet = m_MadoriDoc->GetNextObject();
}
// JavaScript sample
var doc = new CMadoriDoc();
var lRet = doc.GetTopObject();
while(lRet){
var uType =doc.GetCurrentObjectType();
alert(uType);
switch (uType){
case 6: // string
var data = eval( doc.GetStringJS() );
alert( "Result[" + data.Result + "]" );
var msg = " Str[" + data.Str + "]\r\n";
msg += " XPos[" + data.XPos + "]\r\n";
msg += " YPos[" + data.YPos + "]";
alert(msg);
msg = " FontName[" + data.FontName + "]\r\n";
msg += " Height[" + data.Height + "]\r\n";
msg += " FontAttr[" + data.FontAttr + "]";
alert(msg);
msg = " Align[" + data.Align + "]\r\n";
msg += " Angle[" + data.Angle + "]\r\n";
msg += " FontColor[" + data.FontColor + "]";
alert(msg);
break;
}
lRet = doc.GetNextObject();
}