Click here to Skip to main content
15,893,588 members
Articles / Programming Languages / C++

Undo and Redo the "Easy" Way

Rate me:
Please Sign up or sign in to vote.
4.95/5 (42 votes)
20 Jun 2004CPOL22 min read 290.4K   8.6K   114  
This article introduces a simple approach to in-memory transactions that can be used to implement Undo and Redo. The technique uses SEH and Virtual Memory and requires only STL and Win32.
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="7.10"
	Name="DrawIt"
	SccProjectName="&quot;$/DrawIt&quot;, QIBAAAAA"
	SccAuxPath=""
	SccLocalPath="."
	SccProvider="MSSCCI:Microsoft Visual SourceSafe"
	Keyword="MFCProj">
	<Platforms>
		<Platform
			Name="Win32"/>
	</Platforms>
	<Configurations>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory=".\Debug"
			IntermediateDirectory=".\Debug"
			ConfigurationType="1"
			UseOfMFC="2"
			ATLMinimizesCRunTimeLibraryUsage="FALSE"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="..\Common"
				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_NO_EXCEPTIONS "
				BasicRuntimeChecks="3"
				RuntimeLibrary="3"
				UsePrecompiledHeader="0"
				PrecompiledHeaderThrough=""
				PrecompiledHeaderFile=".\Debug/DrawIt.pch"
				AssemblerListingLocation=".\Debug/"
				ObjectFile=".\Debug/"
				ProgramDataBaseFileName=".\Debug/"
				WarningLevel="3"
				SuppressStartupBanner="TRUE"
				DebugInformationFormat="4"
				CompileAs="0"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLinkerTool"
				AdditionalOptions="/MACHINE:I386"
				OutputFile="..\Bin\Debug\DrawIt.exe"
				LinkIncremental="2"
				SuppressStartupBanner="TRUE"
				AdditionalLibraryDirectories=""
				GenerateDebugInformation="TRUE"
				ProgramDatabaseFile=".\Debug/DrawIt.pdb"
				SubSystem="2"/>
			<Tool
				Name="VCMIDLTool"
				PreprocessorDefinitions="_DEBUG"
				MkTypLibCompatible="TRUE"
				SuppressStartupBanner="TRUE"
				TargetEnvironment="1"
				TypeLibraryName=".\Debug/DrawIt.tlb"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_AFXDLL;_DEBUG"
				Culture="1033"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
			<Tool
				Name="VCXMLDataGeneratorTool"/>
			<Tool
				Name="VCWebDeploymentTool"/>
			<Tool
				Name="VCManagedWrapperGeneratorTool"/>
			<Tool
				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
		</Configuration>
		<Configuration
			Name="Release|Win32"
			OutputDirectory=".\Release"
			IntermediateDirectory=".\Release"
			ConfigurationType="1"
			UseOfMFC="1"
			ATLMinimizesCRunTimeLibraryUsage="FALSE"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				InlineFunctionExpansion="1"
				AdditionalIncludeDirectories="..\Common"
				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_STLP_NO_EXCEPTIONS "
				StringPooling="TRUE"
				RuntimeLibrary="0"
				EnableFunctionLevelLinking="TRUE"
				UsePrecompiledHeader="0"
				PrecompiledHeaderThrough=""
				PrecompiledHeaderFile=".\Release/DrawIt.pch"
				AssemblerListingLocation=".\Release/"
				ObjectFile=".\Release/"
				ProgramDataBaseFileName=".\Release/"
				WarningLevel="3"
				SuppressStartupBanner="TRUE"
				CompileAs="0"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLinkerTool"
				AdditionalOptions="/MACHINE:I386"
				OutputFile="..\Bin\Release\DrawIt.exe"
				LinkIncremental="1"
				SuppressStartupBanner="TRUE"
				AdditionalLibraryDirectories=""
				ProgramDatabaseFile=".\Release/DrawIt.pdb"
				SubSystem="2"/>
			<Tool
				Name="VCMIDLTool"
				PreprocessorDefinitions="NDEBUG"
				MkTypLibCompatible="TRUE"
				SuppressStartupBanner="TRUE"
				TargetEnvironment="1"
				TypeLibraryName=".\Release/DrawIt.tlb"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_AFXDLL;NDEBUG"
				Culture="1033"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
			<Tool
				Name="VCXMLDataGeneratorTool"/>
			<Tool
				Name="VCWebDeploymentTool"/>
			<Tool
				Name="VCManagedWrapperGeneratorTool"/>
			<Tool
				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
		</Configuration>
	</Configurations>
	<References>
	</References>
	<Files>
		<Filter
			Name="Source Files"
			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
			<File
				RelativePath=".\DrawIt.cpp">
			</File>
			<File
				RelativePath=".\DrawIt.rc">
			</File>
			<File
				RelativePath=".\DrawItDoc.cpp">
			</File>
			<File
				RelativePath=".\DrawItView.cpp">
			</File>
			<File
				RelativePath=".\MainFrm.cpp">
			</File>
		</Filter>
		<Filter
			Name="Header Files"
			Filter="h;hpp;hxx;hm;inl">
			<File
				RelativePath=".\DrawIt.h">
			</File>
			<File
				RelativePath=".\DrawItAPI.h">
			</File>
			<File
				RelativePath=".\DrawItDoc.h">
			</File>
			<File
				RelativePath=".\DrawItView.h">
			</File>
			<File
				RelativePath=".\MainFrm.h">
			</File>
			<File
				RelativePath=".\Resource.h">
			</File>
		</Filter>
		<Filter
			Name="Resource Files"
			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
			<File
				RelativePath=".\res\DrawIt.ico">
			</File>
			<File
				RelativePath=".\res\DrawIt.rc2">
			</File>
			<File
				RelativePath=".\res\DrawItDoc.ico">
			</File>
			<File
				RelativePath=".\res\html1.htm"
				DeploymentContent="TRUE">
			</File>
			<File
				RelativePath=".\res\Toolbar.bmp">
			</File>
		</Filter>
		<File
			RelativePath="..\Common\Transactions\Allocator.h">
		</File>
		<File
			RelativePath="..\Common\Transactions\Allocator7.h">
		</File>
		<File
			RelativePath="..\Common\Transactions\Compress.cpp">
			<FileConfiguration
				Name="Debug|Win32">
				<Tool
					Name="VCCLCompilerTool"
					UsePrecompiledHeader="0"/>
			</FileConfiguration>
			<FileConfiguration
				Name="Release|Win32">
				<Tool
					Name="VCCLCompilerTool"
					UsePrecompiledHeader="0"/>
			</FileConfiguration>
		</File>
		<File
			RelativePath="..\Common\Transactions\Compress.h">
		</File>
		<File
			RelativePath="..\Common\Transactions\MemManager7.cpp">
		</File>
		<File
			RelativePath="..\Common\Transactions\MemManager7.h">
		</File>
		<File
			RelativePath=".\ReadMe.txt">
		</File>
	</Files>
	<Globals>
		<Global
			Name="RESOURCE_FILE"
			Value="DrawIt.rc"/>
	</Globals>
</VisualStudioProject>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
A compiler warns of bogasity, ignore it at your peril. Unless you've done the compiler's job yourself, don't criticize it.

Comments and Discussions