📄 featureinfo.pas
字号:
unit featureInfo;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComObj;
type
TfeatureInfoForm = class(TForm)
CloseButton: TButton;
updateButton: TButton;
columnNameLabel: TLabel;
columnNameCombo: TComboBox;
valueLabel: TLabel;
valueEditBox: TEdit;
procedure CloseButtonClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure columnNameComboChange(Sender: TObject);
procedure updateButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
featureInfoForm: TfeatureInfoForm;
f : Variant; // Used for storing feature chosen
lyr : Variant; // layer that features comes from
implementation
uses MainMapForm, MapXLib_TLB;
{$R *.DFM}
procedure TfeatureInfoForm.CloseButtonClick(Sender: TObject);
begin
VarClear(f);
VarClear(lyr);
Close;
end;
procedure TfeatureInfoForm.FormActivate(Sender: TObject);
var
i : Integer;
flds : Variant;
ds : Variant;
unusedParam : OleVariant;
begin
TVarData(unusedParam).vType := varError;
TVarData(unusedParam).vError := 2147614724; // DISP_E_PARAMNOTFOUND;
lyr := MainMapForm.EditLayer;
f := MainMapForm.infoFeature;
// Add Dataset using layer that feature resides in. This done to get the
// list of fields that are in the table
ds := MainMap.Map1.Datasets.Add(miDatasetLayer, lyr,unusedParam, unusedParam, unusedParam, unusedParam, unusedParam, unusedParam);
flds := ds.fields;
// Add all the fields of the table to a comboBox
columnNameCombo.Clear;
for i := 1 to flds.count do
columnNameCombo.Items.Add(flds.Item[i].name);
columnNameCombo.ItemIndex := 0;
// Set the layers KeyField to be the first field in the table
lyr.KeyField := columnNameCombo.Text;
// fill text box with value for first keyField for selected feature
valueEditBox.Text := f.KeyValue;
VarClear(flds);
VarClear(ds);
end;
procedure TfeatureInfoForm.columnNameComboChange(Sender: TObject);
begin
// Reset the keyField for the layer & Assign new key value to
// the text box
lyr.KeyField := columnNameCombo.Text;
valueEditBox.Text := f.KeyValue;
end;
procedure TfeatureInfoForm.updateButtonClick(Sender: TObject);
begin
// update the features keyValue with data in text box
f.KeyValue := valueEditBox.Text;
f.upDate;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -