// pText is my custom text object // font is the font information from my custom text object // m_featClass is the annotation feature class // gdbGeo is the point geometry for the annotation HRESULT hr = S_OK; IUnknownPtr ext; hr = m_featClass->get_Extension(&ext); IAnnotationClassExtensionPtr annoExt(ext); ISymbolPtr defaultSymbol; hr = annoExt->get_Symbol(0, &defaultSymbol); ITextElementPtr gdbText(CLSID_TextElement); ISymbolCollectionElementPtr gdbSymColElem(gdbText); hr = gdbSymColElem->put_SharedSymbol(0, defaultSymbol); hr = gdbSymColElem->put_Geometry(gdbGeo); hr = gdbSymColElem->put_Text(CComBSTR(pText->GetText().c_str())); hr = gdbSymColElem->put_Bold(font.IsBold() ? VARIANT_TRUE : VARIANT_FALSE); hr = gdbSymColElem->put_Italic(font.IsItalic() ? VARIANT_TRUE : VARIANT_FALSE); hr = gdbSymColElem->put_Underline(font.IsUnderlined() ? VARIANT_TRUE : VARIANT_FALSE); hr = gdbSymColElem->put_FontName(CComBSTR(font.GetFaceName().c_str())); gdbSymColElem->put_Size(font.GetSize()); IColorPtr gdbColor(CLSID_RgbColor); gdbColor->put_RGB(font.GetFGColor().ToRGB()); gdbColor->put_Transparency(font.GetFGColor().GetOpacity()); gdbSymColElem->put_Color(gdbColor); hr = gdbText->put_Text(CComBSTR(pText->GetText().c_str())); // m_featureBuffer was created for the annotation feature IAnnotationFeature2Ptr annoFeature2(m_featureBuffer); if (annoFeature2 != NULL) { HRESULT hr = annoFeature2->put_Annotation(IElementPtr(gdbText)); if (SUCCEEDED(hr)) { annoFeature2->put_Status(esriAnnoStatusPlaced); annoFeature2->put_AnnotationClassID(0); } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.