zoukankan      html  css  js  c++  java
  • FormDestroy和Destroy中选其一个使用.

    FormDestroy和Destroy都是执行Free时执行的两个函数

    FormDestroy是事件, Destroy是析构函数.FormDestroy是在Destroy中执行的事件,是为了方便程序员写释放资源的代码.

    在程序中要么用直接用Destroy释放,要么用FormDestroy事件,不要混合使用.

    都知道写Destroy的一般都是

    destructor Destroy()

    begin

       CdsMain.Free;

       inherited destroy;//保证基类的资源释放, FormDestroy是在TCustomForm中的事件

    end;

    所以FormDestroy是发生在Destroy的最后一部份,如果你在Destroy中使用了CdsMain.Free

    而你再想在FormDestroy中写上CdsMain.Cancel,必然就会发生AV错误.

    写给初学者.....

    D10.Mofen

  • 相关阅读:
    Kattis
    Kattis
    Kattis
    Kattis -Backspace
    Kattis
    Kattis
    Kattis
    Hihocoder1061-Beautiful String
    Hihocoder1350-Binary Watch
    Hihocoder1458-Parentheses Matching(stack,vector)
  • 原文地址:https://www.cnblogs.com/DKSoft/p/1238017.html
Copyright © 2011-2022 走看看