Select to view content in your preferred language

Implement Map Object OnClose Event - Example

3583
5
Jump to solution
05-14-2013 11:25 PM
ValentinWittich
Occasional Contributor
Hi guys,

I try to understand how I can program a custom function when I close ArcPad. I found in the documentation the OnClose Event which seams to be what I need, but I don't get the implementation of it.

I thing, I would need a practical example to understand it. I got already a start function implemented which is loaded over an login applet (Login.apa). But how do I do activate the OnClose Event?

Hope you guys can help me to understand this issue,

regards
Valentin
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
ThaiTruong
Deactivated User
Valentin,

OnStartup and OnShutdown are belong to Application object.  That OnLoad event belongs to Applet object.  It occurs when the applet is loaded into ArcPad.

So to add the OnShutdown event to your *.APA file, open your APA file with ArcPad Studio.  Click on System Object tool, and select "APPLICATION" object from the left panel.
Under "OnShutdown" event call your function or you can just write your code in the bottom panel, Ex:
Application.MessageBox "ArcPad is closed!", apOKOnly, "App Close"

Save your APA file, start ArcPad, you will get your welcome message.  And when you close the application, you'll get the message above (ArcPad is closed).

and your xml looks similar to this:
<?xml version="1.0" encoding="UTF-8"?> <ArcPad>  <APPLET>   <SYSTEMOBJECTS>    <APPLICATION onshutdown="Application.MessageBox &quot;Hello world!&quot;, apOKOnly, &quot;Logged Out&quot;"/>   </SYSTEMOBJECTS>  </APPLET> </ArcPad>   <?xml version="1.0" encoding="UTF-8"?> <ArcPad>  <APPLET onload="Call Login()" name="">   [...]   <SYSTEMOBJECTS>    <APPLICATION onshutdown="Application.MessageBox &quot;ArcPad is closed!&quot;, apOKOnly, &quot;App Close&quot;"/>   </SYSTEMOBJECTS>  </APPLET>  <SCRIPT src="Login.vbs" language="vbscript"/> </ArcPad>

View solution in original post

0 Kudos
5 Replies
ThaiTruong
Deactivated User
If you want to do something in the end of ArcPad session, you might want to use OnShutdown Event.  OnShutdown will be called when ArcPad is closed.  So, use this event to write code that performs any of your functions when the ArcPad is shutdown.

The OnClose Event you are trying to use, which is called when a map is closed.

The question is how to implement this?  It is implemented the same way that you had for your login code working.  I guess you had your login code under OnStartup Event?!

Hope this helps!
0 Kudos
ValentinWittich
Occasional Contributor
Thank you ttruong for your answer, I think it helps me to understand already a little more.

The question is how to implement this?  It is implemented the same way that you had for your login code working.  I guess you had your login code under OnStartup Event?!


I start my login code over an applet, that's why I don't understand the implementation of the OnShutdown event.

My applet (Login.apa) looks like that:
<?xml version="1.0" encoding="UTF-8"?>
<ArcPad>
 <APPLET onload="Call Login()" name="">
  [...]
 </APPLET>
 <SCRIPT src="Login.vbs" language="vbscript"/>
</ArcPad>


So gets loaded when I start ArcPad and it calls for the Login() sub in the Login.vbs:
Sub Login()
 Application.MessageBox "Hello world!", apOKOnly, "Logged In"
End Sub


Am I guessing right, that these is not the way to call a OnStartup or OnShutdown Event?

Regard Valentin
0 Kudos
ThaiTruong
Deactivated User
Valentin,

OnStartup and OnShutdown are belong to Application object.  That OnLoad event belongs to Applet object.  It occurs when the applet is loaded into ArcPad.

So to add the OnShutdown event to your *.APA file, open your APA file with ArcPad Studio.  Click on System Object tool, and select "APPLICATION" object from the left panel.
Under "OnShutdown" event call your function or you can just write your code in the bottom panel, Ex:
Application.MessageBox "ArcPad is closed!", apOKOnly, "App Close"

Save your APA file, start ArcPad, you will get your welcome message.  And when you close the application, you'll get the message above (ArcPad is closed).

and your xml looks similar to this:
<?xml version="1.0" encoding="UTF-8"?> <ArcPad>  <APPLET>   <SYSTEMOBJECTS>    <APPLICATION onshutdown="Application.MessageBox &quot;Hello world!&quot;, apOKOnly, &quot;Logged Out&quot;"/>   </SYSTEMOBJECTS>  </APPLET> </ArcPad>   <?xml version="1.0" encoding="UTF-8"?> <ArcPad>  <APPLET onload="Call Login()" name="">   [...]   <SYSTEMOBJECTS>    <APPLICATION onshutdown="Application.MessageBox &quot;ArcPad is closed!&quot;, apOKOnly, &quot;App Close&quot;"/>   </SYSTEMOBJECTS>  </APPLET>  <SCRIPT src="Login.vbs" language="vbscript"/> </ArcPad>
0 Kudos
ValentinWittich
Occasional Contributor
Thanks a lot, that is the example I was looking for!
0 Kudos
ThaiTruong
Deactivated User
Thanks a lot, that is the example I was looking for!


I'm glad that this helps you getting started.  Happy coding! 🙂
0 Kudos