Click here to Skip to main content
16,010,268 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: YALCQ Pin
Shog931-Jul-02 20:46
sitebuilderShog931-Jul-02 20:46 
GeneralRe: YALCQ Pin
Roger Allen1-Aug-02 2:52
Roger Allen1-Aug-02 2:52 
GeneralChecks in a list box... Pin
Baatezu31-Jul-02 18:32
Baatezu31-Jul-02 18:32 
GeneralRe: Checks in a list box... Pin
Chris Losinger31-Jul-02 18:46
professionalChris Losinger31-Jul-02 18:46 
GeneralRe: Checks in a list box... Pin
Baatezu1-Aug-02 8:42
Baatezu1-Aug-02 8:42 
GeneralRe: Checks in a list box... Pin
Chris Losinger1-Aug-02 9:01
professionalChris Losinger1-Aug-02 9:01 
QuestionUndo implementation??? Pin
alex.barylski31-Jul-02 17:03
alex.barylski31-Jul-02 17:03 
AnswerRe: Undo implementation??? Pin
Chris Losinger31-Jul-02 17:14
professionalChris Losinger31-Jul-02 17:14 
1. make an object that can encapsulate a single change from one state in your data to the next. the info in this object has to be complete enough so that you can use it to go from state N to state N-1.

ex. if you're writing a text editor, each keystroke could create a "state" object that holds the newly-entered keystroke and the cursor position. that way, to undo that state, remove the character at the cursor pos.

every action that changes the state of the data must be recorded, and you must be able to apply this info to go back to the previous state. this may mean copying the whole data set, if the changes are drastic (ex. resizing an image requires that you store the whole image, since you can't reconstruct from the new image).

2. make an undo stack and a redo stack

3. at each state changing event, create a new state object that records the changes you are making to the data (keystroke, and cursor pos, for example) and push it onto the undo stack. clear the redo stack.

4. for an undo, pop the top object off the stack and use the info therein to undo the action (ex. remove the char at pos X). push the object you just popped onto the redo stack.

5. for a redo, pop an object off the redo stack, apply its changes in a negative way (whereas the undo stack removed char X at pos Y, the redo stack will add char X at pos Y). push tat object onto the undo stack.

this will do unlimited undo/redo.

see my colorizing text editor for a working example.

-c


To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
   /. #3848917

GeneralRe: Undo implementation??? Pin
alex.barylski31-Jul-02 19:24
alex.barylski31-Jul-02 19:24 
AnswerRe: Undo implementation??? Pin
Roger Allen1-Aug-02 2:57
Roger Allen1-Aug-02 2:57 
GeneralRe: Undo implementation??? Pin
alex.barylski1-Aug-02 8:28
alex.barylski1-Aug-02 8:28 
GeneralProblem changing styles in CListView Pin
ijprest31-Jul-02 16:53
ijprest31-Jul-02 16:53 
GeneralRe: Problem changing styles in CListView Pin
Hydralisk31-Jul-02 17:40
Hydralisk31-Jul-02 17:40 
GeneralRe: Problem changing styles in CListView Pin
ijprest1-Aug-02 14:45
ijprest1-Aug-02 14:45 
GeneralRe: Problem changing styles in CListView Pin
ijprest2-Aug-02 20:07
ijprest2-Aug-02 20:07 
GeneralAfxGetMainWnd while creating CMainFrame Pin
Miguel Lopes31-Jul-02 14:07
Miguel Lopes31-Jul-02 14:07 
GeneralRe: AfxGetMainWnd while creating CMainFrame Pin
PJ Arends31-Jul-02 14:48
professionalPJ Arends31-Jul-02 14:48 
GeneralRe: AfxGetMainWnd while creating CMainFrame Pin
Miguel Lopes1-Aug-02 3:28
Miguel Lopes1-Aug-02 3:28 
GeneralRe: AfxGetMainWnd while creating CMainFrame Pin
PJ Arends1-Aug-02 7:07
professionalPJ Arends1-Aug-02 7:07 
GeneralRe: AfxGetMainWnd while creating CMainFrame Pin
Miguel Lopes1-Aug-02 8:48
Miguel Lopes1-Aug-02 8:48 
GeneralRe: AfxGetMainWnd while creating CMainFrame Pin
PJ Arends1-Aug-02 9:14
professionalPJ Arends1-Aug-02 9:14 
GeneralRe: AfxGetMainWnd while creating CMainFrame Pin
Miguel Lopes2-Aug-02 0:57
Miguel Lopes2-Aug-02 0:57 
Question'Notify'-> WS_NOTIFY?!? Pin
Selevercin31-Jul-02 14:03
Selevercin31-Jul-02 14:03 
AnswerRe: 'Notify'-> WS_NOTIFY?!? Pin
Marc Clifton31-Jul-02 14:29
mvaMarc Clifton31-Jul-02 14:29 
GeneralRe: 'Notify'-> WS_NOTIFY?!? Pin
Selevercin31-Jul-02 14:44
Selevercin31-Jul-02 14:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.