怎么实现像word一样控制行间距?

解决方案 »

  1.   

    可以让用户自己设置行间距大小,参考photoshop~当然你得自己实现这个字处理软件,实现SetCaretPos ,换行 ,按键退格等等一系列的处理
      

  2.   

    使用 Word 的 Application、Paragraph 对象进行操作
    可能需要通过 Paragraph 对象的方法来设置
      

  3.   

    老刘同志不在,我来抢分:)
    首先,对你的视图做如下修改,保证用richedit2.0
    CRichviewView::CRichviewView()
    {
    // TODO: add construction code here

    m_strClass = _T("RichEdit20A");
    }void CRichviewView::OnDestroy()
    {
    // Deactivate the item on destruction; this is important
    // when a splitter view is being used. 
       COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
       if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
       {
          pActiveItem->Deactivate();
          ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
       }
       CRichEditView::OnDestroy();
    }
    这两个地方很重要,切记,然后
    void CRichviewView::OnInitialUpdate()
    {
    CRichEditView::OnInitialUpdate();
    // Set the printing margins (720 twips = 1/2 inch).

    PARAFORMAT2 pf2;
    pf2.cbSize = sizeof(PARAFORMAT2);
    pf2.dwMask = PFM_LINESPACING;
    pf2.bLineSpacingRule = 1; //1.5倍行距
    pf2.dyLineSpacing = 0; //bLineSpacingRule 设为3、4、5,dyLineSpacing才有效
    SendMessage(EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
    SetMargins(CRect(720, 720, 720, 720));
    }
    最后为了保险起见,在App类里加
    BOOL CRichviewApp::InitInstance()
    {
             .....
             //m_hModule是CRichviewApp的成员变量
    m_hModule = ::LoadLibrary("richedit20.dll");
    AfxEnableControlContainer();
             .....}
    int CRichviewApp::ExitInstance() 
    {
    // TODO: Add your specialized code here and/or call the base class
    FreeLibrary(m_hModule);
    return CWinApp::ExitInstance();
    }
      

  4.   

    bLineSpacingRule 
    Type of line spacing. To use this member, set the PFM_SPACEAFTER flag in the dwMask member. This member can be one of the following values. Value Meaning 
    0 Single spacing. The dyLineSpacing member is ignored. 
    1 One-and-a-half spacing. The dyLineSpacing member is ignored. 
    2 Double spacing. The dyLineSpacing member is ignored. 
    3 The dyLineSpacing member specifies the spacingfrom one line to the next, in twips. However, if dyLineSpacing specifies a value that is less than single spacing, the control displays single-spaced text. 
    4 The dyLineSpacing member specifies the spacing from one line to the next, in twips. The control uses the exact spacing specified, even if dyLineSpacing specifies a value that is less than single spacing. 
    5 The value of dyLineSpacing / 20 is the spacing, in lines, from one line to the next. Thus, setting dyLineSpacing to 20 produces single-spaced text, 40 is double spaced, 60 is triple spaced, and so on. 
    这是Msdn相关说明
      

  5.   

    更正一下
    CRichviewView::CRichviewView()
    {
    // TODO: add construction code here
    //这句去掉,否则会有意想不到的后果,我也不知道为什么
    //m_strClass = _T("RichEdit20A");
    }
      

  6.   

    hoho,goodboyws(深夜不眠者) 你太强了,俺爱死你了。