robinsongm
09-04-2006, 02:34 AM
Hi.
I'm searching a way to create an object with mappoint for a service. But no visible object. without components like panels, forms, or whatever thing like those. I need it for delphi 7. In this moment i'm testing with a visual form, and with an OleContainer i can create mappoint on a Panel (The container), but it isn't i need.
somebody know how?
thanks!
Wilfried
09-04-2006, 06:29 AM
Hi,
This little Delphi class opens mappoint in background (invisible). It try to open version 2004 Europe first, if not it checks for 2002 version. You eventally have to change the registry search for version 2006 and of course for the US versions also if nececary.
unit uMP;
interface
uses
Windows, SysUtils, Classes, MapPoint_TLB, Registry, Math;
type
TOnError = procedure(Sender: TObject; E: Exception) of object;
TMapPoint = class
private
FMP: _Application;
FOnError: TOnError;
public
constructor Create(ErrorProc: TOnError);
destructor Destroy; override;
end;
implementation
{ TMapPoint }
constructor TMapPoint.Create(ErrorProc: TOnError);
var
Reg: TRegistry;
FileName: string;
begin
inherited Create;
FOnError := ErrorProc;
try
FMP := CoApplication.Create;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CLASSES_ROOT;
if not Reg.OpenKey('.ptm\MapPoint.Map.EU.11\ShellNew', False) then
if not Reg.OpenKey('.ptm\MapPoint.Map.EU.9\ShellNew', False) then
Exit;
FileName := Reg.ReadString('FileName');
FMP.OpenMap(FileName, False);
finally
Reg.Free;
end;
except
on E: Exception do
if Assigned(FOnError) then
FOnError(Self, E);
end;
end;
destructor TMapPoint.Destroy;
begin
FMP.ActiveMap.Saved := True;
FMP.Quit;
inherited;
end;
robinsongm
09-04-2006, 10:34 AM
Great!.
Very easy.
Thanks!