GetSelectedAnnotationFontColor Example VC++

This example uses the GetSelectedAnnotationFontColor method to determine the font color of a selected annotation.  It then updates the Microsoft common dialog box to indicate the color obtained.

This example also uses the Microsoft common dialog box and the SetSelectedAnnotationFontColor method to change the font color of a selected annotation.

void CImgEdit2Dlg::OnAnnofont() 
{
    // This example uses the Microsoft font dialog box to
    // change a selected text annotation mark's font.
    
    COleFont AnnoFont;
    AnnoFont = ImgEdit1.GetSelectedAnnotationFont();
    CY cy;
    long FontColor;
    
    // Determine the current font used in the selected annotation
    // mark and init the dialog box font property to that font.
    AnnoFont = ImgEdit1.GetSelectedAnnotationFont();
    FontColor = ImgEdit1.GetSelectedAnnotationFontColor();
    
    CommonDialog1.SetFontName(AnnoFont.GetName());
    CommonDialog1.SetFontBold(AnnoFont.GetBold());
    CommonDialog1.SetFontItalic(AnnoFont.GetItalic());
    cy = AnnoFont.GetSize();
    CommonDialog1.SetFontSize((float)cy.Lo / 10000);
    CommonDialog1.SetFontUnderLine(AnnoFont.GetUnderline());
    CommonDialog1.SetFontStrikeThru(AnnoFont.GetStrikethrough());
    CommonDialog1.SetColor(FontColor);
    CommonDialog1.SetFlags(0x101); //cdlCFScreenFonts Or cdlCFEffects
    CommonDialog1.ShowFont();
    
    // Take values set in the font dialog box and set these
    // attributes in the annotation font.
    AnnoFont.SetName(CommonDialog1.GetFontName());
    AnnoFont.SetBold(CommonDialog1.GetFontBold());
    AnnoFont.SetItalic(CommonDialog1.GetFontItalic());
    cy.Lo = (unsigned long)CommonDialog1.GetFontSize() * 10000;
    AnnoFont.SetSize(cy);
    AnnoFont.SetUnderline(CommonDialog1.GetFontUnderLine());
    AnnoFont.SetStrikethrough(CommonDialog1.GetFontStrikeThru());

    // Apply the new font and font color to the selected
    // annotation.
    ImgEdit1.SetSelectedAnnotationFont(AnnoFont);
    ImgEdit1.SetSelectedAnnotationFontColor(CommonDialog1.GetColor());
}