Community of MapPoint and Bing Maps Users and Developers
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 ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| mappoint 2k6 and delphi7 OLEcontainer problem 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.
Cheers M.M. Last edited by m.moghisi; 07-30-2007 at 12:42 PM.. |
| |||
| 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) ?
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz www.comfortsoftware.be MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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 |
| |||
| Re: mappoint 2k6 and delphi7 OLEcontainer problem
hi, Do you destroy the mappoint class ? And please show what you put in the destructor code ?
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz www.comfortsoftware.be MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: mappoint 2k6 and delphi7 OLEcontainer problem Quote:
Code: destructor TMP.Destroy; begin OleContainer.DestroyObject; OleContainer.Free; inherited; end; |
| |||
| 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; |
| |||
| 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.
|
| |||
| 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;
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz www.comfortsoftware.be MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| 2k6, delphi7, mappoint, olecontainer, problem |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |