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 />

……<br />

……<br />

}<br />

if(bBefore == TRUE)<br />

{<br />

}<br />

}<br />

else<br />

{<br />

}<br />

}<br />

UpdateAllViews(NULL, HINT_DELCHAR_BEFORE);<br />

BackwardCaret();<br />

m_szText+=szStr;<br />

UpdateAllViews(NULL, HINT_DELCHAR_AFTER);<br />

Flag HINT_DELCHAR_AFTER will cause all the characters after the caret to be updated, and<br />

HINT_DELCHAR_BEFORE will cause the character before the caret along with all the characters after the caret<br />

to be updated.<br />

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

Old Version:<br />

……<br />

BOOL CGDIDoc::DeleteSelection()<br />

{<br />

m_nCaretIndex=nSel;<br />

UpdateAllViews(NULL);<br />

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

m_nSelIndexBgn=m_nSelIndexEnd=-1;<br />

}<br />

return TRUE;<br />

New Version:<br />

……<br />

BOOL CGDIDoc::DeleteSelection()<br />

{<br />

m_nCaretIndex=nSel;<br />

UpdateAllViews(NULL, HINT_DELETE_SELECTION);<br />

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

m_nSelIndexBgn=m_nSelIndexEnd=-1;<br />

m_nSelIndexBgnOld=m_nSelIndexEndOld=-1;<br />

}<br />

return TRUE;<br />

Flag HINT_DELETE_SELECTON will cause the selected text and the characters after the selection to be<br />

updated.<br />

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

Old Version:<br />

……<br />

void CGDIDoc::OnEditPaste()<br />

{<br />

}<br />

UpdateAllViews(NULL);<br />

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

New Version:<br />

void CGDIDoc::OnEditPaste()<br />

276

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

Saved successfully!

Ooh no, something went wrong!