Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MULTIPLE UNDO

MULTIPLE UNDO

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++helptutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Ventsislav
    wrote on last edited by
    #1

    I have to make a program like NotePad on Visiual Studio .NET 2003 using C++,but the problem i have is how to make Multiple UNDO. Live isn't ForEver - LIVE IT

    M M 2 Replies Last reply
    0
    • V Ventsislav

      I have to make a program like NotePad on Visiual Studio .NET 2003 using C++,but the problem i have is how to make Multiple UNDO. Live isn't ForEver - LIVE IT

      M Offline
      M Offline
      Maxwell Chen
      wrote on last edited by
      #2

      To make undoes, two steps: 1) define the scope about what's been done and to undo / redo. For example: struct StepX { long PosFrom; long PosTo; ColorRef Col; long Stroke; }; 2) use any of 'container' approach to store the steps. For example: std::stack or something similar. Maxwell Chen

      1 Reply Last reply
      0
      • V Ventsislav

        I have to make a program like NotePad on Visiual Studio .NET 2003 using C++,but the problem i have is how to make Multiple UNDO. Live isn't ForEver - LIVE IT

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        Think about "commands" for example, when typing text, you can make each character or word an "Insert Command", undoing this, will trigger another command, "Delete Text Command" and its undo command is the "Insert Text" ... you see the pattern ... Each command must know the context and must be "self sufficiant" as much as possible, for example, "Insert Command" will have the text, and the position of insertion. You need to implement a stack of commands ( written in the other answer ), on which you push and pop the commands. From There, you can easilly implement the redo .


        Maximilien Lincourt Your Head A Splode - Strong Bad

        M 1 Reply Last reply
        0
        • M Maximilien

          Think about "commands" for example, when typing text, you can make each character or word an "Insert Command", undoing this, will trigger another command, "Delete Text Command" and its undo command is the "Insert Text" ... you see the pattern ... Each command must know the context and must be "self sufficiant" as much as possible, for example, "Insert Command" will have the text, and the position of insertion. You need to implement a stack of commands ( written in the other answer ), on which you push and pop the commands. From There, you can easilly implement the redo .


          Maximilien Lincourt Your Head A Splode - Strong Bad

          M Offline
          M Offline
          Miguel Lopes
          wrote on last edited by
          #4

          In some cases, multiple undo's are too complicated to make like the 2 previous messages said, expecially, when deleting part of some complex structure. If you're dealing with text, which doesnt grow enormously, you could also keep a copy in memory of previous operations. If you specify a, lets say, 10 maximum number of undo's and the text doesnt exceed 50k, that wouldnt be such a bad approach, although its pretty ugly :-D:-D The method exposed before is much more neat and works for very large structure operations, but can also be difficult to implement.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups