pEView->GetRichEditCtrl().SetWindowText(EchoStr);
我用这种方法往view里写东西,我怎么才能设置我现在要写的字符的字体和字号呢?
我一直在线!问题解决,立即给分!

解决方案 »

  1.   

    我想可不可以新建一个cpen
    设一个新的字体
      

  2.   

    void CMyRichEditView::OnInitialUpdate()
    {
    CRichEditView::OnInitialUpdate(); CFontDialog dlg;
    if(dlg.DoModal()==IDOK)
    {
    LOGFONT lf;
    dlg.GetCurrentFont(&lf);
    m_font.CreateFontIndirect(&lf);
    this->SetFont(&font);
    }
             //m_font是视图的成员变量,可以用m_font.CreateFont(...)来创建
    // Set the printing margins (720 twips = 1/2 inch).
    SetMargins(CRect(720, 720, 720, 720));
    }
      

  3.   

    void CHmCompView::OnInitialUpdate()
    {
    CRichEditView::OnInitialUpdate(); // Set the printing margins (720 twips = 1/2 inch).
    SetMargins(CRect(720, 720, 720, 720));
    //////////////////////////////////////////////////////
    CHARFORMAT2 cf;
    memset (&cf, '\0', sizeof (CHARFORMAT2));
    cf.cbSize = sizeof (CHARFORMAT2);
    GetRichEditCtrl().GetDefaultCharFormat (cf);
    cf.dwMask = CFM_FACE | \
    CFM_SIZE | \
    CFM_UNDERLINE | \
    CFM_COLOR | \
    CFM_BOLD;
    cf.yHeight = 12 * 20; // 12 points in twips
    cf.dwEffects &= ~(CFE_AUTOCOLOR | CFE_BOLD);
    cf.crTextColor = RGB(0x00, 0x00, 0x00);
    strcpy (cf.szFaceName, "Times New Roman");
    GetRichEditCtrl().SetDefaultCharFormat (cf);
    long lEventMask = GetRichEditCtrl().GetEventMask();
    lEventMask |= ENM_SELCHANGE;
    GetRichEditCtrl().SetEventMask(lEventMask);}
      

  4.   

    类名写错了,但无妨,只要知道他是从CRichEditView派生来就行了。