MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




C#: How to find out if MapPoint is still running?

This is a discussion on C#: How to find out if MapPoint is still running? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hello, I create a MapPointApplication with the following code: Code: ApplicationClass mapPointApplication = new ApplicationClass(); Then I add pushpins to ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2005
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 32
C#: How to find out if MapPoint is still running?

Hello,
I create a MapPointApplication with the following code:

Code:
ApplicationClass mapPointApplication = new ApplicationClass();
Then I add pushpins to it:

Code:
mapPointApplication.ActiveMap.AddPushpin(location, "1");

How can I check if MapPoint is still running and hasn't been closed by the user?

Bye,

MD
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
Hi,

Something like this:

Code:
using System.Diagnostics;

        private bool IsMPRunning()
        {
            Process[] processes = Process.GetProcessesByName("MapPoint");
            return (processes.Length > 0);
        }
I did not test this, just from the top of my head
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2005
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 32
I thought about this one, too. But the problem could be: The user could have closed MapPoint and restarted it. So with your method, I wouldn't be sure if it is the same MapPoint instance that I created before.

Bye,

MD
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 03-02-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
Hi,

I cannot find ApplicationClass in my help But I'm pretty sure you can retreive his windows handle. Later when you wants to check if this particular instance of Mappoint is still running you can probably do it this way:

Code:
        private bool IsThisOneRunning(IntPtr h)
        {
            Process[] processes = Process.GetProcessesByName("MapPoint");
            foreach (Process proc in processes)
                if (proc.Handle == h)
                    return true;
            return false;
        }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 03-02-2005
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 32
I thought about something like this:

Code:
mapPointApplication.BeforeClose += new MapPoint._ApplicationEvents_BeforeCloseEventHandler(mapPoint_Closing);
But the code is not totally right.
I'm not so familiar with eventhandler. Do you know how add the right event handler for the beforeclose Event?

Bye,

MD
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 03-02-2005
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 32
Here's the Visual Basic code from the MapPoint help:
Code:
  Dim WithEvents objApp As MapPoint.Application

  Private Sub Command1_Click()
    'Refresh the map using NewMap
    objApp.NewMap
  End Sub

  Private Sub Form_Load()
    'Set up the application
    Set objApp = CreateObject("mappoint.application")
    objApp.Visible = True
    objApp.UserControl = True
  End Sub

  Private Sub objApp_BeforeClose(Cancel As Boolean)
    MsgBox "BeforeClose event fired"
  End Sub
How do I add this event handler in C#?

Bye,

MD
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 03-03-2005
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 32
I cannot get it work

The constructor should be:
new MapPoint._ApplicationEvents_BeforeCloseEventHandle r(void (out bool) target)


How should the signature of the mapPoint_Closing methode look like?

Bye,

MD
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 03-03-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
Hi,

I'm not sure:

Code:
public void Map_BeforeClose(ref bool Cancel);
new MapPoint._ApplicationEvents_BeforeCloseEventHandler(Map_BeforeClose)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 03-03-2005
Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 32
It says:

Method 'server.ServerGUI.mapPoint_Closing(ref bool)' doesnt comply with the Delegat 'void MapPoint._ApplicationEvents_BeforeCloseEventHandle r(out bool)'.

Any idea? I'm totally lost with the delegat and out thing.

Bye,

MD
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 03-03-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
Hi,

Try with Ref bool
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Help!! Error running mappoint gag MapPoint 2006/2009 Discussion 1 01-27-2004 10:45 PM
I currently have Mappoint 2000 running on my PC. (.... Anonymous MapPoint 2006/2009 Discussion 1 07-11-2002 12:44 PM
I am currently running Mappoint 2001 and will buy .... Anonymous MapPoint 2006/2009 Discussion 1 09-19-2001 08:49 AM
I am currently running the MapPoint 2002 Trial. I.... Anonymous MapPoint 2006/2009 Discussion 1 09-04-2001 08:45 AM
I am currently running the MapPoint Trial. (I alre.... Anonymous MapPoint 2006/2009 Discussion 1 08-27-2001 08:13 AM


All times are GMT -5. The time now is 01:25 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map

Flights from Birmingham
Here at Holiday Hypermarket you can book fantastic cheap flights from Birmingham Airport. Check out the great range of destinations.

Best Travel Agent
Travel Counsellors has been named the UK's Best Travel Agent at the Guardian Unlimited Travel awards.

Cuba Holiday
A Cuba Holiday has so much to offer with numerous different cultures affecting the sights, sounds and tastes. Visit this fascinating country with dealchecker.co.uk.

Holidays to Dominican Republic
Holidays to Dominican Republic offer a wealth of natural beauty and magnificent views. Come alive in the splendor of the Dominican Republic!

Portugal
As well as providing some great weather Portugal has much to offer culturally. There are numerous museums, monuments and places of historical interest to explore. Despite the rich history there is a buzzing nightlife and great shopping too.

Compare Holidays
Compare holidays online where you can see all the amazing possibilities at Travel.co.uk

Holidays in Sharm el Sheikh
Need booking info on holidays in Sharm el Sheikh? Visit On The Beach for more information!


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