I need a way to execute a macro in my main GMS file whenever a PageChange or PageActivate event occurs in any open CDR file. Is this possible?
I see that there are PageChange and PageActivate events in the ThisDocument module of the currently active document, but this limited scope won't be helpful as I need the event to be triggered for any document. Any help is appreciated.
I think you can use GlobalMacroStorage_DocumentOpen event to define someting like new CurDoc as Document when you open any document. And then use CurDoc_PageActivate.
Hi Shark. I didn't get a notification of your post, so I'm glad I checked.
I think I follow what you are describing and I'll test it out. Although, I can't imagine how a macro stored in GlobalMacroStorage could create a variable/object "CurDoc" for every file that is opened, and then have that somehow call a function in my main GMS file. Maybe it will just work when I get into it, but it seems like the pieces won't communicate with each other.
I think that the code to do this can reside in the ThisMacroStorage module of a project. From there, it can be able to "see" subs in other modules of that project.
Here's an example where someone was asking about getting a particular view when they switched to a different page:
Dim WithEvents CurDoc As Document Private Sub GlobalMacroStorage_WindowActivate(ByVal Doc As Document, ByVal Window As Window) Set CurDoc = Doc End Sub Private Sub GlobalMacroStorage_WindowDeactivate(ByVal Doc As Document, ByVal Window As Window) Set CurDoc = Nothing End Sub Private Sub CurDoc_PageActivate(ByVal Page As Page) CurDoc.ActiveWindow.ActiveView.ToFitPage End Sub
Instead of changing the view to fit the page, you would instead be using CurDoc_PageActivate to run a sub in another module in that project.
I didn't figure that out myself. I think I may have first seen this on Oberon Forums, but the link going there is dead now.
Thank you for the tip, Eskimo. Sorry for the delayed response. I'm still not getting reply notifications from this forum.I finally have some time today so I can try out your and Shark's suggested approaches.
That did the trick! It's working exactly the way I needed it to. Thank you so much, Eskimo!