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
You have to get the INote variable from the IAnnotation variable using pAnnotation.GetSpecificAnnotation() and cast it to type INote.
Then you have to modify the swNote.PropertyLinkedText string manually.
This text:
has PropertyLinkedText =
"asdfadsfasdf
asdefasdf
asdfasdf
sd<FONT effect=U>afa<FONT effect=RU>s"
Hope that helps, good luck!