关于vcl的问题 请大侠伸伸手帮帮忙吧 (50分)

  • 主题发起人 主题发起人 hstod
  • 开始时间 开始时间
to 52free
不行呀 编译时提示错误 Method 'CreateWnd' not find in base Class(过程createWnd的基类中找不到)
 
为什么没有回答我 都去吃饭了吗??
 
不明白你要实现什么。
 
我再写一边
unit No;

interface

uses
Windows, Messages, SysUtils, Classes, Dialogs;

type
TEvent= procedure(sender of Tobject) of object
TNo = class(TComponent)
private
FNO: Integer;
FNoIS: String;
FEvent: TEvent;
procedure SetNOis(const Value: String);
procedure setFno(const Value: Integer);
procedure SetEvent;(conset Value: TEvent);
protected
{ Protected declarations }
public
Constructor Create(AOwner: TComponent); Override;

published
property NO: Integer Read Fno Write setFno;
Property ONNOIs: String Read FNOis Write SetNOis;

property OnEvent : TEvent read FEvent write SetEvent;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('HSTDB', [TNo]);
end;

{ TNo }

constructor TNo.Create(AOwner: TComponent);
begin
inherited;
if csDesigning in ComponentState Then
begin
Fno:= 0;
FNois:= 'aa';
End else
if (Fnois='123456') and (fno=123) then
if assigned(FEvent) then FEvent(self);
end;


procedure TNo.setFno(const Value: Integer);
begin
Fno := Value;
end;

procedure TNo.SetNOis(const Value: String);
begin
FNois:= Value;
end;

procedure SetEvent;(conset Value: TEvent);
BEgin
FEvent:= Value;
End;

end.
楼上众多人都说出了毛病 我也知道了 就是不能放在Create事件内
我想问一下 不放的Create事件内放的什么地方 可出作出
让这段代码运行 if assigned(FEvent) then FEvent(self);
 
谁会呀
累死了 一天了 就来了三位大侠回复
 
如果在SetFno和SetFnois中都调用DoSomething
而DoSomeThing又不能根据FNo和FNois的值判断只执行一次
那么能不能把DoSomething公布出来让程序员直接调用呢
 
吐血
如果按siyan大侠所提供的方法 我就直接写到一个过程在pas文件 让用户用算了
 
在窗口或数据模块的OnCreate事件中应该能够读取到正确的数值的
是你读取的时机不对,此时预先设置的数据还没有被控件加载呢
 
我知道时机不对 那么在什么时候读取呢???
 
在TNo中加个
procedure Loaded; override;

然后
procedure TNo.Loaded;
begin
inherited;
if (Fnois='123456') and (fno=123) then
if assigned(FEvent) then FEvent(self);
end;
 
试试先谢谢了
 
请大侠讲讲课吧,把上面的代码将一下!!先谢了
 
to sars1
那串代码??
 
就是你的那串代码啊!留个QQ吧,交个朋友,我的QQ:121505627
 
放在loaded里面
Loaded method (TComponent)

Initializes the component after the form file has been read into memory.

Delphi syntax:

procedure Loaded; virtual;

C++ syntax:

virtual void __fastcall Loaded(void);

Description

Do not call the protected Loaded method. The streaming system calls this method after it loads the component抯 form from a stream.

When the streaming system loads a form or data module from its form file, it first constructs the form component by calling its constructor, then reads its property values from the form file. After reading all the property values for all the components, the streaming system calls the Loaded methods of each component in the order the components were created. This gives the components a chance to initialize any data that depends on the values of other components or other parts of itself.

Note: All references to sibling components are resolved by the time Loaded is called. Loaded is the first place that sibling pointers can be used after being streamed in.

As implemented in TComponent, Loaded clears the csLoading flag in the ComponentState property, indicating that the component is no longer loading.

Warning: Loaded may be called multiple times on inherited forms. It is called every time a level of inheritance is streamed in. Do not allocate memory in an overridden Loaded method without first checking that the memory has not been allocated in a previous call.
 
多人接受答案了。
 
后退
顶部