Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
In questa sezione viene illustrato come utilizzare un duplicato del tipo di carattere per applicare una serie di modifiche a un intervallo di testo, tutte contemporaneamente.
Cosa è necessario sapere
Tecnologie
Prerequisiti
- C/C++
- Programmazione dell'interfaccia utente di Windows
Disposizioni
Usare un duplicato del font
Nell'esempio seguente viene illustrato come usare un duplicato del tipo di carattere per applicare una serie di modifiche a un intervallo contemporaneamente.
void ChangeFontNameSizeBold(ITextSelection *pSel)
{
ITextFont *pFontSel = NULL
ITextFont *FontDuplicate = NULL;
// Get ITextFont version of non-duplicated font.
if (FAILED(pSel->GetFont( &pFontSel))
return;
// Duplicate the font.
pFontSel->GetValue(&pFontDuplicate);
pFontSel->Release();
if(!pFontDuplicate)
return;
// Changes here happen only to the underlying data structure,
// such as a CHARFORMAT, in the duplicate - NOT to the actual story text.
BSTR bstrTemp = UnicodeBstrFromAnsi("Times New Roman"); // Font name
pFontDuplicate->SetName(bstrTemp);
SysFreeString(bstrTemp);
pFontDuplicate->SetBold(tomTrue); // Bold
pFontDuplicate->SetSize(10.5); // 10.5 point font.
pFontDuplicate->SetAnimation(tomBlackMarchingAnts);
// Apply the change to text as one change: one screen update, one undo.
// You can also apply the font object to different ranges before you free it.
pSel->SetFont(pFontDuplicate);
pFontDuplicate->Release();
}
Argomenti correlati