The following combination of OC functions should do ...
bool CreateTextLabel(string strLabelName, int FromLeft, int FromTop, string strLabelText, int TypeFace=-1, int FontSize=-1)
{
/*
Create TextLabel
Creates a Text label named "strlabelName" at the coordinates FromLeft and FromTop of the active layer
TypeFace > 0 ... Alters the Typeface to the new value
FontSize > 0 ... Alters the FontSize to the new value
On success: TextLabel created with the text strLabelText ... Returns true
On Failure: returns false
*/
Layer Layr=Project.ActiveLayer();
GraphObject gO;
gO=Layr.GraphObjects(strLabelName);
if(gO.IsValid()==false)
{
gO=Layr.CreateGraphObject(GROT_TEXT);
gO.SetName(strLabelName);
}
else
{
string strObjType=gO.GetObjectType();
strObjType.TrimLeft();
strObjType.TrimRight();
if(strObjType.CompareNoCase("Text")!=0)
{
return (false);
}
}
gO.Text=strLabelText;
SetFontProperties(gO, TypeFace,FontSize);
gO.Left=FromLeft;
gO.Top=FromTop;
return (true);
}
bool GetFontInfo(GraphObject gO, int &TypeFace, int &FontSize)
{
if (gO.IsValid()==true)
{
string strObjType=gO.GetObjectType();
strObjType.TrimLeft();
strObjType.TrimRight();
if(strObjType.CompareNoCase("Text")!=0)
{
return (false);
}
Tree trFormat;
trFormat = gO.GetFormat(FPB_ALL ,FPB_ALL,TRUE,TRUE);
TypeFace=trFormat.Root.Font.Face.dVal;
FontSize=trFormat.Root.Font.Size.dVal;
return (true);
}
return (false);
}
bool SetFontProperties(GraphObject &gO, int TypeFace=-1, int FontSize=-1)
{
if(gO.IsValid()==true)
{
string strObjType=gO.GetObjectType();
strObjType.TrimLeft();
strObjType.TrimRight();
if(strObjType.CompareNoCase("Text")!=0)
{
return (false);
}
Tree trFormat;
trFormat = gO.GetFormat(FPB_ALL ,FPB_ALL,TRUE, TRUE);
if(TypeFace>=0)
{
trFormat.Root.Font.Face.dVal=TypeFace;
}
if(FontSize>0)
{
trFormat.Root.Font.Size.dVal=FontSize;
}
gO.ApplyFormat(trFormat,true,true);
return (true);
}
return (false);
}