읽기 : 어떻게 든 디자이너가 너무 작되는 것을 구성 요소를 방지 할 수 있습니다. 디자이너가이 최소 크기 (10 x 10)를 설정하지는 않지만 이상하게 임의로 크기를 임의로 설정하는 것으로 보입니다. OP에서 설명한 D6에서는 140 x 41이고 D7에서는 100 x 41입니다. 더를
type
TSSPacer = class(TBevel)
protected
procedure SetParent(AParent: TWinControl); override;
public
constructor Create(AOwner: TComponent); override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
published
property Shape default bsSpacer;
end;
constructor TSSPacer.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Shape := bsSpacer;
end;
procedure TSSPacer.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
if AutoSize then
inherited SetBounds(ALeft, ATop, 8, 8)
else
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
end;
procedure TSSPacer.SetParent(AParent: TWinControl);
begin
AutoSize := (csDesigning in ComponentState) and (Parent = nil) and
(AParent <> nil);
inherited SetParent(AParent);
end;
이 D7 여기에 작동하지만 : TBevel 사용이나 AutoSize
속성을 게시하고 해당 속성의 이름을 가지 바란 행동에 관한 않기 때문에
글쎄, 나는 그것의 사용을 스트레칭하기로 결정했습니다
private
FFixDesignSize: Boolean;
procedure TSSPacer.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
if FFixDesignSize then
begin
inherited SetBounds(ALeft, ATop, 8, 8);
FFixDesignSize := False;
end
else
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
end;
procedure TSSPacer.SetParent(AParent: TWinControl);
begin
FFixDesignSize := (csDesigning in ComponentState) and (Parent = nil) and
(AParent <> nil);
inherited SetParent(AParent);
end;
그리고 양식 디자이너에서이 컨트롤을 삭제의 호출 스택이 답변을 완료 : 신뢰성 구현 될 수
- Before SetBounds
- After SetBounds
- Before SetBounds
- After SetBounds
- Before SetParent
- Before SetBounds
- After SetBounds
- After SetParent
- Before SetBounds
- After SetBounds
- Before SetParent
- After SetParent
그러나이 특정 주문이나 전화 번호에 의존해서는 안됩니다. 델파이 버전간에 차이가있을 수 있습니다.
IMHO 이런 종류의 디자인 타임 제한 (어쩌면 그리드 치수와 관련이 있고 모름)이 있습니다. 예를 들어 10x10 디자인 타임에 올바르게 생성됩니다. 나는 가치를 다시 변화시킴으로써 그것을 해치울 것이지만 어떻게 알 수는 없다. 'SetBounds'에서 컴포넌트가 디자인 타임에 있고 그것의 생성이 완료되었음을 결정합니다 ('Loaded' 프로시 저는 단지 런타임을위한 것입니다). 빠른 (시간이 없어 :) 디버그 시도하고 속성 필러에서 뭔가 이러한 값을 수정하는 것으로 보인다. 어쨌든 +1, 흥미로운 질문! – TLama
10x10으로 설정하면 작동하지만 8x8로 설정하면 실패합니다. 왜 그것이 차이를 만들까요, @ 라마? –
@Rob, 정확하게; D2007 및 D2009에서 확인되었습니다. 나는 디자인 타임 차원에 대한 몇 가지 내부 한계를 의심 할 것이다. 1x10 작품, 1x9 작품; 10x1 작품, 9x1 작품. 10보다 작은 두 치수에 한계가있는 것 같고, 실제로 이상합니다 (그리드 크기가 아니라 8x8로 설정했습니다). 런타임에는 원하는대로 할 수 있지만 디자인 타임 생성자 다음에 차원을 수정하는 요소가 있습니다. 예 : SetBounds하지만 어떻게 구성 요소가 완전히 생성되었는지 확인합니다 (생성자가 완료된 후 SetBounds가 몇 번 발생 함). – TLama