English 中文(简体)
我如何根据儿童组成部分的财产确定一个框架的特性?
原标题:How do I set properties of a frame based on properties of its child components?

我提出这个问题的第一个版本可能是具体的,因此,我将设法以更一般性的方式:

我有一个框架,其中有一个部分,我要说它是一个TButton。 在将框架放在表一更改构成部分的财产之后,我要说,我把 but子tag到100。

在构造者中,我想做的是:

constructor TMyFrame.Create(AOwner: TComponent);
begin
  inherited;

  if Button1.Tag = 100
    then DoSomething
    else DoSomethingElse;
end;

我发现,目前(在建立期间)纽托邦的主角仍然存在。 页: 1 是否有人建议采取另一种方式这样做?

In our application there are several places where the users can enter SQL statements. To facilitate this we use the SynEdit component. We have created a frame for this purpose, with some extended functionality.

有时我们需要数据版本(TDBSYnEdit),有时我们需要“常规”版本(TSynEdit)。 我们已经解决了这一问题,对框架进行了控制,并在设计时间转向正确的网页。 表格是 h的,因此用户对此没有想法。

问题是,有时我们的开发商忘记在控制页上设置正确的网页,或意外地选择错误的网页。

我想通过在设定框架的活动中增加以下代码来确定这一点。

if DBSQLMemo.DataField >   
  then pcMemos.ActivePage := tsDataAware
  else pcMemos.ActivePage := tsNonDataAware;

我的理论是,如果开发商确定编辑的数据来源/数据领域特性,则框架应当用于“数据信息模式”,而数据信息编辑应当有目共.。 由此可见,在创建时,这些财产就被定了。

Does anyone have a good suggestion to how I should solve this problem?

最佳回答

如何推翻“过时”程序? 那么,当所有儿童部件装满时,就为你们所需要的一个部件扫描吗?

e.g.

interface

...
protected
  procedure Loaded; override;
...

implementation

procedure Loaded;
var
  i: Integer;
begin
  inherited;

  for i := 0 to pred(Self.ComponentCount) do
    if Self.Components[i] is TSynEdit then
    begin
      // do something
    end;
end;

如果你所需要的部分是直接的后代,那么你就需要扫描儿童等。

问题回答

我将把嵌入的SynEdit从这个框架中删除,而是将一个财产( /strong>)交给一个SynEdit的例子。 这样,你就不会总是有一个无用的协同效应,用户甚至可能决定使用一种衍生工具,而你甚至想不到。

另一种想法: 如何在法典中而不是在视觉上建立SynEdit? (取决于你想通过形式设计者改变这种设计的程度。) 然后,你可以放弃“Control”,每个框架只有一名编辑。





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...