如果你使用的是一個源於CRichEditView的類,那麼你已經支持了三種不同的換行模式。
WrapNone 指明沒有自動換行
WrapToWindow 指明換行基於窗口寬度
WrapToTargetDevice 指明換行基於目標設備的特性
改變換行模式我們可以將上述三種模式賦予m_nWordWrap變量,再調用WrapChanged(),如果不調用此函數將不能實現修改。
// Code to use with CRichEditView
// Turn word wrap on
m_nWordWrap = WrapToWindow;
WrapChanged();
如果你使用源於CRichEditCtrl的類,那麼你將不能獲得m_nWordWrap變量與WrapChanged()函數的支持。你將需要SetTargetDevice()函數。
// Code to use with CRichEditCtrl
// To turn word wrap off
SetTargetDevice(NULL, 1);
// To turn word wrap on - based on window width
SetTargetDevice(NULL, 0);
// To turn word wrap on - based on target
// device (e.g. printer)
// m_dcTarget is the device context, m_lineWidth
// is the line width
SetTargetDevice(m_dcTarget, m_lineWidth);