Recent

Author Topic: application stays in 'Processes' after closing  (Read 4123 times)

ensimek

  • Jr. Member
  • **
  • Posts: 55
application stays in 'Processes' after closing
« on: March 13, 2011, 07:12:30 am »
Hi,
I've simple apllications made on two Forms (Form1, Form2). Form1 is loginbox where user puts username/password and if they're correct Form1 is hiding Form1.hide, and Form2 is showing Form2.show;

Application is closing but I have no idea why it stays in MS Windows Processes. (ctrl+alt+del) is nescessary to rebuild or even open the same application for the next time.

ik

  • Jr. Member
  • **
  • Posts: 88
  • ik
    • LINESIP
Re: application stays in 'Processes' after closing
« Reply #1 on: March 13, 2011, 09:10:56 am »
When you close the program, what exactly are the commands you are using for that ? Is that "hide" or is that "close" or  "application.Terminate" ?

eny

  • Hero Member
  • *****
  • Posts: 1658
Re: application stays in 'Processes' after closing
« Reply #2 on: March 13, 2011, 12:38:36 pm »
Application is closing
How?

The application will only close if Form1 is freed as well because that is the application's main form.
The application will not close if you just hide the main form.
You cannot simply free form1 because that will end the application.

A crude hack that seems to work:
Code: Pascal  [Select][+][-]
  1. var frm2: TfrmTwo;
  2.     P:Pointer;
  3. begin
  4.   // Create new form 2
  5.   Application.CreateForm(TfrmTwo, frm2);
  6.   frm2.Show;
  7.  
  8.   // Change application's main form to this new form
  9.   P := @Application.Mainform;
  10.   Pointer(P^) := frm2;
  11.  
  12.   // Close the main form; it will be freed as soon as the second, now main, form closes
  13.   Close
  14. end;
A better solution would be to change your logic i.e. make your 2nd form the main form and pop up a login form.
All posts based on: Win11; Lazarus 4_4  (x64) 12-02-2026 (unless specified otherwise...)

 

TinyPortal © 2005-2018