位图显示地图

 client.ini
[screen]
x=1024
y=768

map.mdb
map_id map_chk_station map_x_min map_x_max map_y_min map_y_max
1 1号监测站 574  613  283  321
2 2号监测站 517  563  127  162
3 4号监测站 854  899  34  74

procedure TFormMain.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  xScreen,yScreen,xMin,xMax,yMin,yMax,xBase,yBase:Integer;
  ini:TIniFile;
  filename,s:string;
begin
  inherited;
  filename:=ExtractFilePath(Application.ExeName)+'client.ini';
  ini:=TIniFile.Create(filename);
  try
    xBase:=ini.ReadInteger('screen','x',0);
    yBase:=ini.ReadInteger('screen','y',0);
  finally
    ini.Free;
  end;
  xScreen:=Screen.Width;
  yScreen:=Screen.Height;
  paneXY.Caption:=Format('横坐标:%s 纵坐标:%s',[IntToStr(X),IntToStr(Y)]);
  lock;
  try
    dm.cdsTemp.Data:=dm.sc.AppServer.opensql('select * from map');
    with dm.cdsTemp do
    begin
      First;
      while not Eof do
      begin
        xMin:=Round(xScreen/xbase*FieldValues['map_x_min']);
        xMax:=Round(xScreen/xbase*FieldValues['map_x_max']);
        yMin:=Round(yScreen/ybase*FieldValues['map_y_min']);
        yMax:=Round(yScreen/ybase*FieldValues['map_y_max']);
        if (X>=xMin) and (X<=xMax) then
        if (Y>=yMin) and (Y<=yMax) then
        begin
          s:=Format('%s [压强:%s] [水位:%s] [PH:%s] [余氯:%s] [浊度:%s]',
            [FieldValues['map_chk_station'],'','','',
            '','']);
          paneData.Caption:=s;
        end else
          paneData.Caption:='';
        Next;
      end; 
    end; 
  finally
    unlock;
  end;
end;

posted @ 2008-11-07 10:05  delphi中间件  阅读(388)  评论(0编辑  收藏  举报