View Single Post

  #4 (permalink)  
Old 05-15-2007
Wilfried Wilfried is offline
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,105
Re: How to close MapPoint applications correctly?

I did a small test (Delphi7) and it works. This is the mappoint unit:

Code:
unit uMP;

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 := geoKm;
end;

destructor TMP.Destroy;
begin
   OleContainer.DestroyObject;
   OleContainer.Free;
   inherited;
end;
This is the form:

Code:
procedure TMain.FormActivate(Sender: TObject);
begin
   MP := TMP.Create(Self, MPPanel);
end;

procedure TMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
   MP.Free;
end;
So there must be some other difference somewhere.
Reply With Quote