MapPoint Forums

MapForums

Community of MapPoint and Bing Maps Users and Developers




mappoint 2k6 and delphi7 OLEcontainer problem

This is a discussion on mappoint 2k6 and delphi7 OLEcontainer problem within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi What is the solution for loading mappoint 2k6 into an olecontainer in Delphi7. Although it is possible to right ...


Go Back   MapPoint Forums > Map Forums > MapPoint Desktop Discussion

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-26-2007
Junior Member
White Belt
 
Join Date: Jul 2007
Posts: 4
mappoint 2k6 and delphi7 OLEcontainer problem

Hi

What is the solution for loading mappoint 2k6 into an olecontainer in Delphi7. Although it is possible to right click and open mappoint, however, on save or after edit if one tries to close mappoint generates error

"Microsoft MapPoint has encountered a problem and needs to close. etc"

I have tried loading the mappoint in code as shown bellow with no success.

Code:
unit mapPoint;

interface

uses
  Controls, Classes, OleCtnrs, MapPoint_TLB;

type
  TMP = class
  private
    FMap: _Map;
    OleContainer: TOleContainer;
  public
    constructor Create(AOwner: TComponent; ParentControl: TWinControl);
    destructor Destroy; override;
    property Map: _Map read FMap;
  end;


implementation

{ TMP }

constructor TMP.Create(AOwner: TComponent; ParentControl: TWinControl);
var
   Guid: TGuid;
begin
   OleContainer := TOleContainer.create(nil);
   OleContainer.Parent := ParentControl;
   OleContainer.Align := alClient;
   OleContainer.CreateObject('MapPoint.Map.EU.13', False);
   OleContainer.DoVerb(1);
   OleContainer.OleObjectInterface.GetUserClassID(Guid);
   FMap:= IDispatch(OleContainer.OleObject) as _Map;
   FMap.Application.Units := geoMiles;
end;

destructor TMP.Destroy;
begin
   OleContainer.DestroyObject;
   OleContainer.Free;
   inherited;
end;

end.
Any suggestions are much appreciated.

Cheers
M.M.

Last edited by m.moghisi; 07-30-2007 at 12:42 PM..
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 07-26-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,389
Re: mappoint 2k6 and delphi7 OLEcontainer problem

Hi,

Code looks good, but can you please next time put your code into [ code ] tags so that it is readable with proper indent ?

So if I understeand right you dont have an AV or an exception error, but you have that windows error 'application needs to close etc..' ?

Can you check howmany instances of mappoint you have in memory (task manager) ?
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 07-27-2007
Junior Member
White Belt
 
Join Date: Jul 2007
Posts: 4
Re: mappoint 2k6 and delphi7 OLEcontainer problem

Hi

Thanks for your reply.

I do not get an AV error, etc

I only get one instance of MapPoint running, but when you try to 'close the form' or 'closing edit form of OLEcontainer', MapPoint crashes and stays in memory (in task manager)

Any ideas?

Thanks
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 07-28-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,389
Re: mappoint 2k6 and delphi7 OLEcontainer problem

hi,

Do you destroy the mappoint class ? And please show what you put in the destructor code ?
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 07-30-2007
Junior Member
White Belt
 
Join Date: Jul 2007
Posts: 4
Re: mappoint 2k6 and delphi7 OLEcontainer problem

Quote:
Originally Posted by Wilfried View Post
hi,

Do you destroy the mappoint class ? And please show what you put in the destructor code ?


Code:
destructor TMP.Destroy;
begin
   OleContainer.DestroyObject;
   OleContainer.Free;
   inherited;
end;
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 07-30-2007
Junior Member
White Belt
 
Join Date: May 2007
Posts: 3
Re: mappoint 2k6 and delphi7 OLEcontainer problem

Try this code - I had the same problem. Put this in the FormClose event.procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction);begin if (Assigned(FMap.MPMap))then begin FMap.MPMap.Application.Quit; FMap.MPMap:=nil; FMap.OleContainer.Close; FMap.OleContainer.DestroyObject; FMap.OleContainer.UpdateObject; FMap.OleContainer.Update; FMap.OleContainer.UpdateControlState; end;end;
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 08-12-2007
Junior Member
White Belt
 
Join Date: Jul 2007
Posts: 4
Re: mappoint 2k6 and delphi7 OLEcontainer problem

Hi

I have tried your suggestion but the problem still presents.

The error is: 'Microsoft MapPoint has encountered a problem and needs to close. We are sorry for the inconvenience ... etc etc'. The error is generated when OLE Container destroyObject is called.

"OleContainer.DestroyObject;"

The destroyObject calls the following where the error is generated.

OleCheck(OleSave(PersistStorage, FStorage, True));

I am sure the problem is with MapPoint since, if I remove any reference to MapPoint, OLE container is created and destroyed without any problems.

Code:
unit mapPoint;

interface

uses
  Controls, Classes, OleCtnrs, MapPoint_TLB;

type
  TMP = class
  private
    FMap: _Map;
    OleContainer: TOleContainer;
  public
    constructor Create(AOwner: TComponent; ParentControl: TWinControl);
    destructor Destroy; override;
    property Map: _Map read FMap;
  end;


implementation

{ TMP }

constructor TMP.Create(AOwner: TComponent; ParentControl: TWinControl);
var
   Guid: TGuid;
begin
   OleContainer := TOleContainer.create(nil);
   OleContainer.Parent := ParentControl;
   OleContainer.Align := alClient;
   OleContainer.CreateObject('MapPoint.Map.EU.13', False);
   OleContainer.DoVerb(1);
   OleContainer.OleObjectInterface.GetUserClassID(Guid);
   FMap:= IDispatch(OleContainer.OleObject) as _Map;
   FMap.Application.Units := geoMiles;
end;

destructor TMP.Destroy;
begin
  if Assigned(FMap) then FMap.Application.Quit;
  FMap._Release;
  FMap := nil;
  OleContainer.Close;
  OleContainer.DestroyObject;
  OleContainer.UpdateObject;
  OleContainer.Update;
  OleContainer.UpdateControlState;
  OleContainer.UpdateControlState;
  OleContainer.Free;
  inherited;
end;


end.
Thanking you in advance
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 08-12-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,389
Re: mappoint 2k6 and delphi7 OLEcontainer problem

Hi,

This is how I destroy it:

Code:
destructor TTSMapPoint.Destroy;
begin;
   FMap.Application.Quit;
   FMap:=nil;
   OleContainer1.DestroyObject;
   OleContainer1.Free;
   inherited;
end;
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

Tags
2k6, delphi7, mappoint, olecontainer, problem


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
MapPoint in OleContainer problem //BCB tomek_tomek MapPoint Desktop Discussion 3 08-16-2005 02:54 PM
Borland C++ Builder : Using Mappoint over olecontainer Anonymous MapPoint Desktop Discussion 2 02-14-2005 04:04 AM
Mappoint in OleContainer problem //Delphi Anonymous MapPoint Desktop Discussion 6 01-08-2005 01:03 PM
Delphi OleContainer Resize Problem. Sheridan MapPoint Desktop Discussion 5 12-19-2003 05:50 AM
Delphi OleContainer problems pafreshney MapPoint Desktop Discussion 6 09-15-2003 01:50 PM


All times are GMT -5. The time now is 04:55 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.0 RC3
MP2K Magazine
Visitor Map



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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69