我想在我的mfc應用程序中創建重做/撤消功能,但是當我試圖撤消CLine對象時 - 它無法正常工作。我做錯了什麼?對不起我的英語不好!「重做/撤消」功能的問題(mfc,C++)
void CKonokhovDoc::OnEditUndo()
{
// TODO: Add your command handler code here
int Index = (int)m_LineArray.GetUpperBound();
int Index2 = (int)m_LineArray_redo.GetUpperBound();
if (Index>-1){
redoLine = m_LineArray.GetAt(Index);
m_LineArray_redo.SetAt(Index2+1,redoLine);
m_LineArray.RemoveAt(Index);
}
UpdateAllViews(0);
SetModifiedFlag();
}
void CKonokhovDoc::OnUpdateEditUndo(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable((int)m_LineArray.GetSize());
}
void CKonokhovDoc::OnEditRedo()
{
// TODO: Add your command handler code here
int Index = (int)m_LineArray.GetUpperBound();
int Index2 = (int)m_LineArray_redo.GetUpperBound();
m_LineArray.SetAt(Index+1, m_LineArray_redo.GetAt(Index2));
m_LineArray_redo.RemoveAt(Index2);
//redoLine = NULL;
UpdateAllViews(0);
SetModifiedFlag();
}
能否請您發佈的代碼作爲文本? – Rakete1111
@ Rakete1111是的,已經..! –
謝謝!特別是它在哪裏崩潰?當你撤消?或重做? – Rakete1111