我把源程序贴上来了,邮件我也又发了,我的服务太周到了。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,oleauto, Buttons;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
SpeedButton6: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton11: TSpeedButton;
SpeedButton8: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton11Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
private
function openmap(filename:string):boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
path:string;
oleMapInfo: Variant;
wmainID:string;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
path:=extractfilepath(application.ExeName);
oleMapInfo := CreateOLEObject('MapInfo.Application');
//连接MAPINFO
olemapinfo.do('Set Application Window ' + inttoStr(Form1.Handle));
olemapinfo.do('Set Window Ruler Parent ' + inttoStr(Form1.panel1.Handle));
openmap(path+'map/建筑层1.tab');
olemapinfo.do('set nextdo
cument parent '+intTostr(panel1.handle)+'Style 1');
olemapinfo.do('map from 建筑层1');
//如果为多层,可定义图层的叠放顺序
wmainID:=olemapinfo.eval('frontwindow()');
olemapinfo.do('set map zoom entire layer 1');
//整图显示第一层
olemapinfo.do('set map distance units "m"');
//定义单位
olemapinfo.do('set map layer 1 editable on');
//定义第一层可编辑
end;
function TForm1.openmap(filename: string): boolean;
begin
olemapinfo.do('open table "'+FileName+'"');
end;
procedure TForm1.SpeedButton6Click(Sender: TObject);
begin
olemapinfo.RunMenuCommand(1701);
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
oleMapInfo.RunMenuCommand(1705);
end;
procedure TForm1.SpeedButton5Click(Sender: TObject);
begin
oleMapInfo.RunMenuCommand(1706);
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
oleMapInfo.RunMenuCommand(1702);
end;
procedure TForm1.SpeedButton10Click(Sender: TObject);
begin
oleMapInfo.RunMenuCommand(1709);
end;
procedure TForm1.SpeedButton11Click(Sender: TObject);
begin
oleMapInfo.RunMenuCommand(1710);
end;
procedure TForm1.SpeedButton8Click(Sender: TObject);
begin
oleMapInfo.RunMenuCommand(801);
end;
end.