Forum > Graphics

Run-time TPanel move

<< < (2/3) > >>

Handoko:

--- Quote from: wp on November 20, 2023, 04:55:37 pm ---But why should closing the child form close the application? You put a "Halt" into the code. But why?

--- End quote ---

If you download the code, remove the halt and run it then you will know why.


--- Quote from: wp on November 20, 2023, 04:55:37 pm ---When the child from does NOT close the application, but is destroyed and reactivates the main form
--- End quote ---

Closing the child form does not cause it to be freed or destroyed. It simply hides the form. That is the default form behavior (in Lazarus).

luca:
Hi,
I've downloaded the code.

The Button1Click event is never fired.
Every time I click on the button the FormActivate event is triggered and nothing more happen.

If I removed the code from FormActivate procedure, and show the Child form when I click on another button (I've created on main form), then all it's fine and no error appears even if I remove the Halt instruction.
It seems the problem is that every time you click on the MainForm the ChildForm is showed back and the program can't exit.

Best regards
Luca

wp:
Showing the child from in Handoko's code in the OnActivate handler should be protected by some state variable preventing multiple execution:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TMainForm = class(TForm)  ...  private    Activated: Boolean;  end; procedure TMainform.FormActivate(Sender: TObject);begin  if not Activated then  begin    Activated := true;    Childform.Left := Left + Width + 10;    Childform.Top  := Top;    Childform.Show;  end;end; 

luca:
Generally speaking I don't like to use OnActivate event.

Regards
Luca

davor:
Big Thanks Handoko!!!!
This is exactly the solution I was looking for.  :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version