-
Notifications
You must be signed in to change notification settings - Fork 2
/
UnRedoStack.h
executable file
·93 lines (72 loc) · 1.88 KB
/
UnRedoStack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// UnRedoStack.h: interface for the CUnRedoStack class.
// 重做/撤消堆栈,鲍捷,1999年3月17日
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_UNREDOSTACK_H__149B1A21_DC4C_11D2_A8BD_44B1F7C00000__INCLUDED_)
#define AFX_UNREDOSTACK_H__149B1A21_DC4C_11D2_A8BD_44B1F7C00000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxtempl.h> //模板类
/*使用范例
假设已有
CUnRedoStack CYourView::m_stkUnRedo;
void CYourView::BeginProcessing()
{
//......
HGLOBAL hData = ..... ;//在此准备Undo数据
m_stkUnRedo.PushUndo(hData);
//......
}
void CYourView::OnEditUndo()
{
HGLOBAL hNew = NULL;
HGLOBAL hData = ..... ;//在此准备Undo数据
if (m_stkUnRedo.HasUndo())
{
BeginWaitCursor();
hNew = m_stkUnRedo.Undo(hData);
if (hNew != NULL)
{
//在此处利用该Undo句柄
}
EndWaitCursor();
}
}
void CImageView::OnEditRedo()
{
HGLOBAL hNew = NULL;
HGLOBAL hData = ..... ;//在此准备Undo数据
if (m_stkUnRedo.HasRedo())
{
BeginWaitCursor();
hNew = m_stkUnRedo.Redo(hData);
if (hNew != NULL)
{
//在此处利用该Redo句柄
}
EndWaitCursor();
}
}
*/
class CUnRedoStack : public CObject
{
public:
HGLOBAL Redo(HGLOBAL hData);
HGLOBAL Undo(HGLOBAL hData);
BOOL HasUndo(){ return !m_listUndo.IsEmpty();}
BOOL HasRedo(){ return !m_listRedo.IsEmpty();}
void PushUndo(HGLOBAL handle);
void PushRedo(HGLOBAL handle);
HGLOBAL CopyHandle (HGLOBAL h);
CUnRedoStack();
virtual ~CUnRedoStack();
void SetStackDeep(UINT nNewDeep);
UINT GetStackDeep(){return m_nDeep;}
BOOL m_bEnableRedo;//是否允许重做
protected:
UINT m_nDeep;//堆栈深度
CTypedPtrList<CPtrList,HGLOBAL> m_listUndo;
CTypedPtrList<CPtrList,HGLOBAL> m_listRedo;
};
#endif // !defined(AFX_UNREDOSTACK_H__149B1A21_DC4C_11D2_A8BD_44B1F7C00000__INCLUDED_)