★★★发现delphi6有一个毛病!大家都来看一下,我给100分。谢谢(100分)

B

bcfans

Unregistered / Unconfirmed
GUEST, unregistred user!
★★★发现delphi6有一个毛病!大家都来看一下,我给100分。谢谢
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure button1click(sender:tobject); //自己写上的
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
procedure button(sender:tobject);
begin
case (sender as tbutton).Tag of
0:form1.button2.enabled:=false;
1:form1.button1.enabled:=false;
2:begin
form1.button1.enabled:=true;
form1.button2.enabled:=true;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject); //自己写上的
begin
button(sender);
end;
end.


如果
procedure TForm1.Button1Click(Sender: TObject);
begin
button(sender);
end;
这个过程是自己写的而没有在object inspector中选择button1的onclick事件的话,程序运行时点击button1就没有反应,只有再点击object inspector中button1的onclick事件后才能运行,不知道是怎么回事?我的电邮是:onlydelphi@hotmail.com MSN是:onlydelphi@hotmail.com
 
因为消息影射是被存放到 *.dfm 文件中的,没有消息影射定义,Delphi 不予理睬。
你自己写个一摸一样的过程,还不能在 TForm1 = class(TForm) 中加这个过程说明,
一加 Delphi 就发脾气,要加只能加到全局或 TForm1 = class(TForm) 的 private 等
段中,不信你试试。
 
这不是Bug,从控件面板上放到Form上的控件,由IDE自己管理。IDE生成的代码,也不能随便删除。
 
不是Bug,是规则
 
看看dfm文件的源代码,就能发现OnClick = button1click这样的事件句柄关联,
手工加入的代码没有关联,自然无效了。
 
你必须使Button1Click时间激活才行
你自己写代码也行,但必许在Button1Click事件中双机一下,激活这个事件
 
我认为,只要你自己处理好,应该不会有这些问题
因为Delphi自动生成的和手工加入的没有什么差别的
都是ASCII文件,区分不开的,只要你加入的是正确的,Delphi都认得
最多可能是要把工程关掉,重新打开
否则Delphi怎么混呀
 
非BUG也,没有进行消息的关联,在窗体的DFM文件中加入发、即可,或者动态创建控件也行
如下:
ServerSocket1:=ServerSocket.create(nil);
with ServerSocket1 do
begin
Active:=False;
Port:=AddContent.iPort;
ServerType:=stNonBlocking;
OnClientRead:=ServerSocketClientRead; //在这里关联了事件和对应函数
OnError:=ServerSocketClientSocketError; //在这里关联了事件和对应函数
end;
 
还是动态在程序中指定的好,灵活
[:)]
 
你在OnClick事件中选中你编写的过程就能正常使用。
 
这绝对不能叫Delphi的Bug,只要清楚D是怎么工作的,你就自己知道错在哪了!

A汽车也在,A司机也在开,只是,A司机开的不是A汽车,所以,A车不走,结论:这是对的!
 
多人接受答案了。
 

Similar threads

顶部