Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 8 of 8

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 ...

  1. #1
    m.moghisi is offline 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 01:42 PM.

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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) ?

  3. #3
    m.moghisi is offline 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

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: mappoint 2k6 and delphi7 OLEcontainer problem

    hi,

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

  5. #5
    m.moghisi is offline 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;

  6. #6
    johnrboren is offline 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;

  7. #7
    m.moghisi is offline 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

  8. #8
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. MapPoint in OleContainer problem //BCB
    By tomek_tomek in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 08-16-2005, 03:54 PM
  2. Borland C++ Builder : Using Mappoint over olecontainer
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 02-14-2005, 05:04 AM
  3. Mappoint in OleContainer problem //Delphi
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 01-08-2005, 02:03 PM
  4. Delphi OleContainer Resize Problem.
    By Sheridan in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 12-19-2003, 06:50 AM
  5. Delphi OleContainer problems
    By pafreshney in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 09-15-2003, 02:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96