其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
C++ Builder开发点滴

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

2004-10-20 星期三
1、窗体的OldCreateOrder属性。

如果要问你,窗体类的构造函数和OnCreate事件中的代码哪个先执行,你可能会毫不犹豫的回答肯定是构造函数的代码先执行。事实上并非如此,最近在使用窗体继承时就碰到这样一个问题。我首先定义了一个基本窗体TChildBaseForm,然后以该窗体作为基础以继承方式创建窗体TUserInfoForm。在跟踪程序的时候发现,竟然是TUserInfoForm窗体的OnCreate事件处理代码先执行,然后才执行构造函数的代码。

为什么会出现这样的情况呢?后来查找TForm的帮助,发现TForm有这样一个属性OldCreateOrder,看看帮助是如何说明的:

When OldCreateOrder is false (the default) the OnCreate event occurs after all constructors are finished (from the AfterConstruction method) and the OnDestroy event occurs before any destructors are called (from the BeforeDestruction method).

This timing differs from C++Builder 1, where the OnCreate event occurred when the TCustomForm constructor executed and the OnDestroy event occurred when the TCustomForm destructor executed. Applications that require the OnCreate event and OnDestroy events to occur from the constructor and destructor of the form can set OldCreateOrder to true.




相关文章

相关软件