|
发表于 2010-9-5 12:00:08
|
显示全部楼层
要求得越细致,代码就会越复杂,呵呵- - }5 K8 @. ^- g5 e/ D
- '声明一个全局变量,用来记录是否发生修改
# Q( W6 u/ b0 W, z8 N - Dim B As Boolean
; O% S* j: ~& l. A8 c - '在响应文档对象的BeginDocClose事件的代码中检查B变量记录的修改
& @# o3 d; W O! k6 e8 ~* E3 B - Private Sub AcadDocument_BeginDocClose(Cancel As Boolean)
3 S1 m1 w3 @! p/ S8 o: c - If B Then
- y/ @4 o; f- Z+ O: p - '当文档被修改时用消息框通知用户"已改变",当用户按下"取消"按钮时不关闭文档* ~* f/ {; e6 r+ S! f7 ^
- If MsgBox("已改变", vbOKCancel) = vbCancel Then Cancel = True7 U- s( x) _: R( w
- '清空记录- g5 f+ V! L) ?# o7 D1 {
- B = False
" e H4 Q4 H7 x& {# t7 k, V: f - Else+ `2 c4 h2 r1 E
- MsgBox "未改变"
0 l$ w' r# ^# J9 j/ m6 F - End If
1 R* C. p7 y! F - End Sub; C6 @( I5 W& M! ?
- '在响应文档保存事件的代码中清空记录* P, T7 W' ?. W
- Private Sub AcadDocument_EndSave(ByVal FileName As String)0 C( M; \# Z0 ]+ m$ ~
- B = False
8 t+ o) |5 }6 } - End Sub
0 W$ w$ `. N, n1 A! W4 z' G. s, c- | - '在响应文档对象的ObjectAdded事件(对象被添加到图形中时触发)的代码中记录文档修改
& H, t2 p& e6 U1 Q& u2 G - '可以在代码中检查Object参数的对象类型,以了解是哪一类对象被添加.) M3 X! l% c3 P
- 'ObjectModified事件代码也一样" p. w% B( V' p- i* S% T
- Private Sub AcadDocument_ObjectAdded(ByVal Object As Object)9 U K+ p$ o4 [% H% J+ v! G/ i
- B = True
: g: D% `" ?0 l) E+ X - End Sub6 P* v( o4 }0 J( d
- '在响应文档对象的ObjectErased事件(对象从图形中删除时触发)的代码中记录文档修改
% b6 X6 J& a3 g6 z0 j6 r - Private Sub AcadDocument_ObjectErased(ByVal ObjectID As Long)
3 r. p2 @! X* p0 B' N - B = True
% F9 n* z3 m: r6 b - End Sub
& h. [- Z! j8 s2 g u. Q2 Y+ i- y - '在响应文档对象的ObjectModified事件(图形中的对象被修改时触发)的代码中记录文档修改" {( w0 N. ?, h. C' `& ]# y b
- Private Sub AcadDocument_ObjectModified(ByVal Object As Object)
9 H v/ v( S* F3 ]3 n0 [ - B = True8 ~( b) P5 d/ ^- D/ i( _- R) V6 k
- End Sub4 A2 ]( E+ @5 H& I- ?% l, \
复制代码 |
|