void CNotepadView::OnFormatfont() 
{
//    CNotepadDoc *pDoc=GetDocument(); LOGFONT lf;
CFont *font=this->GetEditCtrl().GetFont(); 
if(font==NULL)
{
font =new CFont;
font->CreatePointFont(120,"Fixedsys");
 font->GetLogFont(&lf);
delete font;
}
else
{
 font->GetLogFont(&lf);
}
 CFontDialog cf(&lf);
  
 if(cf.DoModal()==IDOK)
 {
 this->m_font.DeleteObject();
 this->m_font.CreateFontIndirect(&lf);
 this->SetFont(&this->m_font);
 }
 
}
这是我写的实现改变字体及颜色的代吗
  怎么实现改变颜色的功能,代码怎么写

解决方案 »

  1.   

    typedef struct tagLOGFONT { 
      LONG lfHeight; 
      LONG lfWidth; 
      LONG lfEscapement; 
      LONG lfOrientation; 
      LONG lfWeight; 
      BYTE lfItalic; 
      BYTE lfUnderline; 
      BYTE lfStrikeOut; 
      BYTE lfCharSet; 
      BYTE lfOutPrecision; 
      BYTE lfClipPrecision; 
      BYTE lfQuality; 
      BYTE lfPitchAndFamily; 
      TCHAR lfFaceName[LF_FACESIZE]; 
    } LOGFONT, *PLOGFONT; 没有颜色信息。CFontDialog cf(&lf);
      
     if(cf.DoModal()==IDOK)
     {
     this->m_font.DeleteObject();
     this->m_font.CreateFontIndirect(&lf);
     this->SetFont(&this->m_font);
     }
    COLORREF color = cf.GetColor();
      

  2.   

    可以这样写:
    CFontDialog cf(&lf);
    cf.m_cf.rgbColors = 32768;
      
     if(cf.DoModal()==IDOK)
     {
     this->m_font.DeleteObject();
     this->m_font.CreateFontIndirect(&lf);
     this->SetFont(&this->m_font);
     }
    COLORREF color = cf.GetColor();