OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   Corel Photo-Paint VBA (http://forum.oberonplace.com/forumdisplay.php?f=17)
-   -   ThisDocument Events (http://forum.oberonplace.com/showthread.php?t=307)

mapcar 07-12-2003 07:37

ThisDocument Events
 
Hi there,

I have to trace all Docs opened, created and closed. I've seen other applications have a lot of events handled by ThisDocument, but PP11 only has four of them. GlobalDocument_Open(new)Document works fine, but what about CloseDocument? That's the most important, but can't find it...

Is it possible to add events or something like that? What can I do? Please answer 'idiot proof', i'm not really familiar with VBA.

Thanks, Axel

Aquila 16-08-2009 14:23

ThisDocument events - detect document closed
 
Below is a somewhat stupid way to check for closure, but it does work just so long as you opened the events with file / open.

I think there are other ways too, but I have to play with it.

-----------------------------------------------


Private m_tStr As String

Private Sub GlobalDocument_OpenDocument(ByVal Document As IPaintDocument)
Dim ppDoc As PHOTOPAINT.Document
Set ppDoc = Document
CheckClose ppDoc
End Sub

Public Function CheckClose(ppDoc As PHOTOPAINT.Document)
While True
DoEventPause 2
If Not IsDocOpen(ppDoc) Then
GoTo JumpOut
End If
Wend
JumpOut:
MsgBox "closed"
End Function

Public Function IsDocOpen(ppDoc As PHOTOPAINT.Document) As Boolean
IsDocOpen = False
On Error GoTo JumpError
m_tStr = ppDoc.Name
IsDocOpen = True
Exit Function
JumpError:
End Function

Public Function DoEventPause(Seconds As Integer)
Dim tStart As Date
Dim tNow As Date
Dim i As Integer
Dim j As Long
j = 1
tStart = Now
While True
For i = 1 To 6000
DoEvents
Next i
j = j + 1
tNow = Now
If Second(tNow - tStart) >= Seconds Then
Exit Function
End If
Wend
End Function


All times are GMT -5. The time now is 20:21.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com