Go Delphi form release and hide: Free,hide,close

Source: Internet
Author: User

Form. Free-Releases all resources that the form occupies.   After free, the form pointer can no longer be used unless the form is re-assigned. Form. Hide-hides the form. You can call the form.   Show once again. Form.close-Close the form, the actual result depends on Onclosequery and OnClose, if Onclosequery's canclose is false, no action is taken, if true, Further investigation of the value of the action of OnClose: Canone: Do nothing cahide: hide the window, the same form. Hide Cafree: Releases the resource that the form occupies, same as form.  Free Caminimize:form minimized. Cafree is most largely applied to MDI (multiple forms) because the default action when the subform closes is hide, which is hidden, so if you want to release the resource you are using, set the close action, which is to add a sentence to the OnClose event Action:=cafree  While Application.terminate is shutting down the entire application.     Create is inherited from the method, the role is to allocate memory to the object instance, the syntax is: formname:=tformname.create (application);   The parameter application indicates that the owner of this form is application. Show is a window that has been created.   The syntax is: formname.show; Also: Show is a modeless display form, ShowModal is a modal display form. The order in which the form is created: 1.formcreate 2.formactive 3.formshow Implementation The scope of the split code. Implementation prevents an external reference unit from being involved, any cell that accesses the cell can only refer to the interface section of the cell, for functions or procedures declared within implementation but not declared in interface. Other cells that refer to the cell cannot be called, and similarly, variables declared within implementation can only be used within that cell. Formdestroy and Formclose Differences and Contact: (1). Call Formdestroy when all the resources of the window are really released. When you close the window, VCL will call Formclose if you are in the formClose writes action = Cafree, then the VCL will continue to call Formdestroy; If you assign the action value to any other value, VCL will not really release the window resource (if Action=canone does nothing and the window remains intact), Formdestroy is not called at this time. (2). Look at this program: Change Form2 to available, then write action in tform2.formclose: = Cafree;    Write Form2 in Tform2.formdestroy: = nil; then use Form2 if not Assigned (FORM2) then Form2: = Tform2.create (self); form2.show;//Form2.showmodal; The first case: Call Form1.close in Formclose, then call to Tform.onclose, which is called to Formclose, so the death recursion.      A dead recursion, of course, stacks overflow (stack Overflow). The second case: Call Form1.free in Formclose, which will call Tform.destroy,tform.destroy to determine if it is the same as application.mainform, and if so, Application.mainform will be set to Nil,tform.destroy then triggers Formdestroy, and Form1 is set to nil in Formdestroy. Formclose is called by Tform.close, originally after Formclose, compare whether it is application.mainform, if it is, call Application.terminate end application. But while self is still non-nil, it's just a hidden variable in the Close method, and Application.mainform is nil, so even if mainform doesn't exist, the application still exists, but it's not visible. The application itself is also a window, but its size is 0.    So there's only another way to close the application (Ctrl+alt+del or press CTRL+F2 in the Delphi IDE). Tip: Try not to close the form with the free method, especially the main form, and you should use the Close method. In Formcreate, Formshow, FormActivate, Formclosequery, Formclose, Formdestroy do not invoke methods to close, release, or destroy forms in each event.        Do not directly reference FORM1 such global instance variables in a method or event, if someone else creates the form in the following way, the FORM1 variable will not work: Var Myformvar:tform1;         Begin Myformvar: = tform1.create (application);         Myformvar.show;     Use Myformvar to myformvar.close with some things;      End     Because this time tform1.formclose run in fact is Myformvar instead of Form1.     This can be changed in Formdestroy: If Self=form1 then Form1: = nil; Use this method to prevent unintended error references to Form1 by other programs

[Turn]delphi release and hide of form: Free,hide,close

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.