11.04.2014 Views

Advanced MFC Programming

Advanced MFC Programming

Advanced MFC Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9. Font<br />

……<br />

void CGDIDoc::SetCaret(CPoint point)<br />

{<br />

}<br />

if(m_nSelIndexBgn == -1)m_nSelIndexBgn=m_nCaretIndex;<br />

else<br />

{<br />

m_nSelIndexEndOld=m_nSelIndexEnd;<br />

m_nSelIndexEnd=m_nCaretIndex;<br />

UpdateAllViews(NULL, HINT_SELECTION);<br />

}<br />

GetCGDIView()->RedrawCaret();<br />

In this function, the value of m_nSelIndexEnd is first assigned to m_nSelIndexEndOld before it is<br />

updated. Flag HINT_SELECTION will cause the difference between the newly selected area and the old one to<br />

be updated. The area can be calculated from the four selection indices.<br />

The following shows the modifications made to function CGDIDoc::AddChar(…):<br />

Old Version:<br />

……<br />

void CGDIDoc::AddChar(UINT uChar, UINT uRepCnt)<br />

{<br />

}<br />

UpdateAllViews(NULL);<br />

ForwardCaret();<br />

New Version:<br />

……<br />

void CGDIDoc::AddChar(UINT uChar, UINT uRepCnt)<br />

{<br />

}<br />

UpdateAllViews(NULL, HINT_INPUT);<br />

ForwardCaret();<br />

Flag HINT_INPUT will cause all the characters after the caret to be updated.<br />

The following shows the modifications made to funciton CGDIDoc::DeleteChar(…):<br />

Old Version:<br />

……<br />

……<br />

……<br />

void CGDIDoc::DeleteChar(BOOL bBefore)<br />

{<br />

}<br />

if(bBefore == TRUE)<br />

{<br />

}<br />

}<br />

else<br />

{<br />

}<br />

}<br />

UpdateAllViews(NULL);<br />

BackwardCaret();<br />

m_szText+=szStr;<br />

UpdateAllViews(NULL);<br />

New Version:<br />

void CGDIDoc::DeleteChar(BOOL bBefore)<br />

{<br />

275

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!