AnnSetTextOptions example for Visual C++
// The following example changes some of the text options of
// a text-based annotation. It changes the text color to blue,
// and toggles the ShowBorder option:
void CAnnCOMView::ExampleAnnSetTextOptions()
{
int nRet = 0;
long lOptions = 0;
CString strMsg;
long hObject;
m_pltAnn->AnnCreate(ANN_OBJECT_TEXT, TRUE, TRUE);
hObject = m_pltAnn->GetAnnObject();
m_pltAnn->PutAnnRectLeft(hObject,0);
m_pltAnn->PutAnnRectTop(hObject,0);
m_pltAnn->PutAnnRectWidth(hObject,100);
m_pltAnn->PutAnnRectHeight(hObject,100);
lOptions = m_pltAnn->AnnGetOptions();
nRet = m_pltAnn->AnnSetOptions(lOptions | ANN_OPTIONS_NEW_TEXT_OPTIONS);
if (nRet != 0)
return;
nRet = m_pltAnn->AnnGetTextOptions(hObject, ANN_TEXT_SHOW_TEXT | ANN_TEXT_SHOW_BORDER | ANN_TEXT_TEXTCOLOR);
if (nRet != 0)
return;
strMsg.Format(TEXT("Old Options: ShowText[%d], ShowBorder[%d], TextColor[0x%x]"),
m_pltAnn->AnnShowText,
m_pltAnn->AnnShowBorder,
m_pltAnn->AnnTextColor);
MessageBox(strMsg);
// Change some options
nRet = m_pltAnn->AnnSetTextOptions(hObject, m_pltAnn->AnnShowText, !m_pltAnn->AnnShowBorder, RGB(0, 0, 255), 0, ANN_TEXT_SHOW_BORDER | ANN_TEXT_TEXTCOLOR, FALSE);
if (nRet != 0)
return;
nRet = m_pltAnn->AnnGetTextOptions(hObject, ANN_TEXT_SHOW_TEXT | ANN_TEXT_SHOW_BORDER | ANN_TEXT_TEXTCOLOR);
if (nRet != 0)
return;
strMsg.Format(TEXT("New Options: ShowText[%d], ShowBorder[%d], TextColor[0x%x]"),
m_pltAnn->AnnShowText,
m_pltAnn->AnnShowBorder,
m_pltAnn->AnnTextColor);
MessageBox(strMsg);
}