Recent

Author Topic: Reset a form  (Read 378 times)

MJ12

  • Newbie
  • Posts: 5
Reset a form
« on: December 11, 2022, 04:51:22 pm »
hello!

Im new to programming in general and I wanted to create the fifteen puzzle so copied the code from this link: https://wiki.freepascal.org/15-puzzle

Everything worked fine but I wanted to implement a reset button. What i found online was this:
Form1.free;
Application.CreateForm(TForm1, Form1)

I created the button and at the end i put the code but it was debugging infinitely.

Any ideas on how to make it work?



af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: Reset a form
« Reply #1 on: December 11, 2022, 05:52:19 pm »
I think, you must not free and recreate the form. You have only to change/refresh the puzzle15 (TGameBoard)

a ) init all like in TGameBoard.Create (all old information is lost by this)
b ) Set new positions you can use TGameBoard.RandomArray

regards
Andreas

 

TinyPortal © 2005-2018