unit1.pas

来自「107215805Delphi中MapX连接SQLServer」· PAS 代码 · 共 71 行

PAS
71
字号
//MapInfo China
//James Liu
//20030/4/1

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, MapXLib_TLB, StdCtrls, DB, DBTables;

type
  TForm1 = class(TForm)
    Map1: TMap;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Database1: TDatabase;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
        //application.Destroy ;
        application.Terminate;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
 LayerInfoObject: CMapXLayerInfo;
begin
 LayerInfoObject := CoLayerInfo.Create;
 LayerInfoObject.Type_ := miLayerInfoTypeServer;

 // LayerInfoObject.AddParameter('FileSpec', 'c:\Program Files\MapInfo\MapX 5.0\Maps\worldcap.tab');

 LayerInfoObject.AddParameter('Name', 'SpatialLayer');
 LayerInfoObject.AddParameter('ConnectString','DSN=spatialsqlserver');   //必须参数
 //LayerInfoObject.AddParameter('ConnectString','DSN=spatialsqlserver;UID=James;WSID=LIUYI;DATABASE=sqlserver2000;Trusted_Connection=Yes');
 LayerInfoObject.AddParameter('Query','SELECT * FROM ASIACAPS');
 LayerInfoObject.AddParameter('ToolKit','ODBC');
 Map1.Layers.Add(LayerInfoObject, EmptyParam);
 
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
        Map1.CurrentTool := miZoomInTool ;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
        Map1.CurrentTool := miZoomOutTool; 
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?