当我第一次运行此代码时,一切都会按预期进行。但是一旦选择Sonitor
然后选择BBraun
,Sonitor
控件(标签和文本框)就不会消失,它们仍在屏幕上。
[Code]
var
VendorPage, VendorHostPage: TWizardPage;
VendorText: TNewStaticText;
VendorEdit: TNewEdit;
ComboBox: TNewComboBox;
procedure ComboBoxChange(Sender: TObject);
begin
case ComboBox.ItemIndex of
0:
begin
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'AssetTracking connects to the BBraun server to recieve the HL7 data';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Top := ScaleY(25);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'BBraun HL7 port:';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorEdit := TNewEdit.Create(VendorHostPage);
VendorEdit.Top := ScaleY(25);
VendorEdit.Left := ScaleX(200);
VendorEdit.Parent := VendorHostPage.Surface;
end;
1:
begin
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'AssetTracking connects to RTLS server to recieve streaming location data';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Top := ScaleY(25);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'Centrak RTLS Server IP address:';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorEdit := TNewEdit.Create(VendorHostPage);
VendorEdit.Top := ScaleY(25);
VendorEdit.Left := ScaleX(200);
VendorEdit.Parent := VendorHostPage.Surface;
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Top := ScaleY(50);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'Centrak RTLS Server port:';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorEdit := TNewEdit.Create(VendorHostPage);
VendorEdit.Top := ScaleY(50);
VendorEdit.Left := ScaleX(200);
VendorEdit.Parent := VendorHostPage.Surface;
end;
2:
begin
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'AssetTracking connects to RTLS server to recieve streaming location data';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Top := ScaleY(25);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'Sonitor RTLS Server IP address:';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorEdit := TNewEdit.Create(VendorHostPage);
VendorEdit.Top := ScaleY(25);
VendorEdit.Left := ScaleX(200);
VendorEdit.Parent := VendorHostPage.Surface;
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Top := ScaleY(50);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'Sonitor RTLS Events port:';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorEdit := TNewEdit.Create(VendorHostPage);
VendorEdit.Top := ScaleY(50);
VendorEdit.Left := ScaleX(200);
VendorEdit.Parent := VendorHostPage.Surface;
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Top := ScaleY(75);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'Sonitor RTLS API port:';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorEdit := TNewEdit.Create(VendorHostPage);
VendorEdit.Top := ScaleY(75);
VendorEdit.Left := ScaleX(200);
VendorEdit.Parent := VendorHostPage.Surface;
end;
end;
end;
procedure InitializeWizard;
var
InstallJava: Boolean;
begin
VendorPage := CreateCustomPage(wpWelcome, 'RTLS HW Data Source Configuration', '');
VendorText := TNewStaticText.Create(VendorPage);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'Please select the RTLS hardware vendor to install:';
VendorText.AutoSize := True;
VendorText.Parent := VendorPage.Surface;
VendorText := TNewStaticText.Create(VendorPage);
VendorText.Top := ScaleY(25);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'RTLS Vendor';
VendorText.AutoSize := True;
VendorText.Parent := VendorPage.Surface;
ComboBox := TNewComboBox.Create(VendorPage);
ComboBox.Top := ScaleY(25);
ComboBox.Left := ScaleX(100);
ComboBox.Anchors := [akLeft, akTop, akRight];
ComboBox.Parent := VendorPage.Surface;
ComboBox.Style := csDropDown;
ComboBox.Items.Add('BBraun');
ComboBox.Items.Add('Centrak');
ComboBox.Items.Add('Sonitor');
ComboBox.ItemIndex := 0;
ComboBox.OnChange := @ComboBoxChange;
VendorHostPage := CreateCustomPage(VendorPage.ID, 'RTLS HW Data Source Configuration', 'Provide Connection details to Teletracking RTLS');
case ComboBox.ItemIndex of
0:
begin
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'AssetTracking connects to the BBraun server to recieve the HL7 data';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorText := TNewStaticText.Create(VendorHostPage);
VendorText.Top := ScaleY(25);
VendorText.Anchors := [akLeft, akRight, akBottom];
VendorText.Caption := 'BBraun HL7 port:';
VendorText.AutoSize := True;
VendorText.Parent := VendorHostPage.Surface;
VendorEdit := TNewEdit.Create(VendorHostPage);
VendorEdit.Top := ScaleY(25);
VendorEdit.Left := ScaleX(200);
VendorEdit.Parent := VendorHostPage.Surface;
end;
end;
end;
选择组合框值后的预期行为:
PS:如果无法在浏览器中看到图像,请下载该图像,该代码已根据选择的前两个屏幕ComboBox
和下一个屏幕编写,而不是其余部分。
答案 0 :(得分:1)
当然不是。在Pascal脚本中分配对象变量不会破坏该变量先前指向的对象。
您必须明确地执行此操作。喜欢:
if Assigned(VendorText) then VendorText.Free;
尽管更常见的实现方式是,您希望的是在开始时一次创建控件,随着组合框选择的更改隐藏/显示和/或更改其标题。这样的解决方案将需要更少的代码。