本文介绍了TControlState.csDesignerHide与TControlStyle.csNoDesignVisible的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 VCL似乎提供了两种从表单设计器隐藏控件的机制: TControlState.csDesignerHide 和 TControlStyle.csNoDesignVisible 。 The VCL seems to offer two mechanisms for hiding controls from form designers : TControlState.csDesignerHide and TControlStyle.csNoDesignVisible. 就IDE而言,它们之间有什么区别? What's the difference between them as far as the IDE is concerned? Which should you use when?推荐答案 摘要 使用 TControlState.csDesignerHide 以防止控件绘制。使用 TControlStyle.csNoDesignVisible 模仿可见属性。很好的问题!它们之间肯定有区别,所以我做了一点调查。Nice question! There simply must be a difference between them, so I did a little investigation.在 Controls 单元中搜索用法,我们发现Searching for usage in the Controls unit, we find that: TControlState.csDesignerHide 用于: TControl.InvalidateControl 、TWinControl.UpdateShowing、TWinControl.PaintHandler、TWinControl.PaintControls , 除了这些方法之外, TControlStyle.csNoDesignVisible 还用于: TControl.Show , TControl.Repaint , TControl.CMVisibleChanged , TWinControl.AlignControls , TWinControl.ControlAtPos , TWinControl.CMVisibleChanged , TWinControl.GetControlExtents , TWinControl.CalcConstraints , TWinControl.CanAutoSize 。 / li> TControlState.csDesignerHide is used in: TControl.InvalidateControl, TWinControl.UpdateShowing, TWinControl.PaintHandler, TWinControl.PaintControls,in addition to those methods, TControlStyle.csNoDesignVisible is also used in: TControl.Show, TControl.Repaint, TControl.CMVisibleChanged, TWinControl.AlignControls, TWinControl.ControlAtPos, TWinControl.CMVisibleChanged, TWinControl.GetControlExtents, TWinControl.CalcConstraints, TWinControl.CanAutoSize.因此, TControlState.csDesignerHide 仅用于绘画操作,而 TControlStyle。 csNoDesignVisib le 也用于位置和对齐操作。Thus TControlState.csDesignerHide is only used in painting operations whereas TControlStyle.csNoDesignVisible is also used in position and alignment operation.换句话说,使用: TControlState.csDesignerHide 如果只想控制可见性, TControlStyle.csNoDesignVisible 如果您还想控制状态。 TControlState.csDesignerHide if you only want control over visibility,TControlStyle.csNoDesignVisible if you also want control over presence.此外, TControlStyle.csNoDesignVisible 仅适用与Visible属性结合使用。当可见设置为真时,它无效。 (通常,Visible属性仅影响运行时行为。)Furthermore, TControlStyle.csNoDesignVisible works only in conjuction with the Visible property. It has no effect when Visible is set True. (Normally, the Visible property only affects runtime behaviour).为说明不同之处,以下是表单设计器的三个屏幕截图。在窗体上从左到右放置: TStyleControl 具有控制 TControlStyle.csNoDesignVisible 的属性,面板,具有控制 TStateControl c> TControlState.csDesignerHide 和另一个面板,它们的Align属性都设置为 alLeft :To illustrate the difference, hereby three screen shots of a form designer. On the form are placed from left to right: a "TStyleControl" with a property controlling TControlStyle.csNoDesignVisible, a Panel, a "TStateControl" with a property controlling TControlState.csDesignerHide and another Panel, all with the Align property set to alLeft: 所有默认设置 StateControl1.DesignerHide = True StyleControl1。 NoDesignVisible =真和 StyleControl1.Visible =假 All with default settingsStateControl1.DesignerHide = TrueStyleControl1.NoDesignVisible = True and StyleControl1.Visible = False 这篇关于TControlState.csDesignerHide与TControlStyle.csNoDesignVisible的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-18 23:43