VCL是这样的,
procedure TControl.SetZOrderPosition(Position: Integer);
var
I, Count: Integer;
ParentForm: TCustomForm;
begin
if FParent <> nil then
begin
I := FParent.FControls.IndexOf(Self);
if I >= 0 then
begin
Count := FParent.FControls.Count;
if Position < 0 then Position := 0;
if Position >= Count then Position := Count - 1;
if Position <> I then
begin
FParent.FControls.Delete(I);
FParent.FControls.Insert(Position, Self);
InvalidateControl(Visible, True);
ParentForm := ValidParentForm(Self);
if csPalette in ParentForm.ControlState then
TControl(ParentForm).PaletteChanged(True);
end;
end;
end;
end;