如何将自定义控件的子级限制在某个区域? [英] How do I restrict my custom control's children to a certain area?

查看:85
本文介绍了如何将自定义控件的子级限制在某个区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于 TPanel 的自定义控件,它具有一个内部面板,该面板定义了我的组件的工作区域,而外部区域则带有一个最小化/还原按钮以隐藏和显示(内部)面板。

I have a custom control based on TPanel, and it has an inner panel that defines the working region for my components and a outer area with a "minimize/restore" button to hide and show the (inner) panel.

如果我在设计时将组件放到控件上并设置其 Align alClient 的c $ c>属性,将使用外部面板的大小,并且最小化按钮不再可见。

If I drop a component at design time on my control and set its Align property to alClient, the size of the outer panel is used and the minimize button is no longer visible.

如何在面板上对齐或放下组件以使其(停留在)内部面板区域内?

How can I align or drop components on my panel to force them (to stay) within the area of the inner panel?

推荐答案

将按钮放置在自己的面板上,该面板不会接受其他控件并将其放在前面,但缺点是可以覆盖其他控件。

Place the button on an own panel which will not accept other controls and keep it in front, but would have the disadvantage that other controls could be covered.

procedure THidePanel.AdjustClientRect(var Rect: TRect);
begin
  inherited;
  FPanel.BringToFront;
end;

constructor THidePanel.create(AOwner: TComponent);
begin
  inherited;
  FPanel := TPanel.Create(self);
  FPanel.Align := alright;
  FPanel.Parent := self;
  FPanel.BevelOuter := bvNone;
  FPanel.Width := 30;
  FButton:=TSpeedButton.Create(self);
  FButton.Parent := FPanel;
  FPanel.ControlStyle := FPanel.ControlStyle - [csAcceptsControls];
end;

这篇关于如何将自定义控件的子级限制在某个区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆