Does anybody have any idea how Microsoft Paint does their cut/copy, paste, and undo/redo functions. I can't figure out how to apply them to my map editor. I'm using c++ and the Win32 API. No MFC.
How does MS Paint do their functions?
Let's first deal with the undo-redo ... this is something you'll need to define yourself, based on the application you're designing and how it goes about changes.
My suggestion would be to setup a list (data type) of the modifications made ... you'll need to limit it's size to fairly small if the data stored at each step is large. When a change is implemented that would exceed the size of the list (undo limit), you toss the least recent item from the list.
Whether each entry in the list describes what changed in the data ... or simply has a copy of the data prior to change ... is up to you. Obviously a full copy is more of a burden on memory, but often easier to implement ... if the changes are in small increments, storing full copies would likely be incredibly wasteful ... so some sort of inverse change stored as the undo information would be better.
Now, the cut/copy/paste functions ... since you're using the Windows API, you'll want to take advantage of the Windows Clipboard ... this is what MS Paint uses.
There are several functions you can use Google or whatever to find information on. I'll simply list them here for you :
ChangeClipboardChain
CloseClipboard
CountClipboardFormats
EmptyClipboard
EnumClipboardFormats
GetClipboardData
GetClipboardFormatName
GetClipboardOwner
GetClipboardViewer
GetOpenClipboardWindow
GetPriorityClipboardFormat
IsClipboardFormatAvailable
OpenClipboard
RegisterClipboardFormat
SetClipboardData
SetClipboardViewer
Happy hunting!
Reply:I dont think MS paint is written in C++, but im sure there is a way to do it in C++
get a book on it or something
email cards
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment