AnsweredAssumed Answered

How to underline subset of Note?

Question asked by Mahadev Dharme on Oct 1, 2019
Latest reply on Oct 9, 2019 by Mahadev Dharme

Hi,

   I am trying to underline the particular text from selected Note by using the following code

//======================================================//

CComPtr<IModelDoc2> pSWModel;
m_pSwApp->get_IActiveDoc2(&pSWModel); 

CComPtr<ISelectionMgr> pSWSelectionMgr;
pSWModel->get_ISelectionManager(&pSWSelectionMgr);

CComPtr<IDispatch> pSelectedEntity = NULL;
pSWSelectionMgr->GetSelectedObject6(1, -1, &pSelectedEntity);

 

CComQIPtr<INote, &IID_INote> pNote(pSelectedEntity);
CComBSTR text;
pNote->GetText(&text);

long txtCount;
pNote->GetTextCount(&txtCount);

CComPtr<IAnnotation> pAnnotation;
pNote->IGetAnnotation(&pAnnotation);

long txtFormatCount;
pAnnotation->GetTextFormatCount(&txtFormatCount);

CComPtr<ITextFormat> txtFormat;
pAnnotation->IGetTextFormat(0, &txtFormat);

txtFormat->put_Underline(VARIANT_TRUE);
VARIANT_BOOL retVal;
pAnnotation->ISetTextFormat(0, FALSE, txtFormat, &retVal);

//======================================================//

 

Here, my txtCount is 5 and txtFormatCount is 1. If I use the pAnnotation->ISetTextFormat() method then it underlined all text but I want to underline the first line text only.

I have tried changing the index (i.e. 0 in the above code) but it underlined all the text for each index. Is anyone know How should I underlined that particular text?

 

Thanks and Regards,

Mahadev

Outcomes