Recent

Author Topic: Creating forms dynamically  (Read 17876 times)

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: Creating forms dynamically
« Reply #15 on: July 15, 2017, 01:45:41 am »
I guess it's better to use RELEASE than CLOSE...
If I use SHOW and after that CLOSE then the form goes to HIDE ??? Is that true ??? OK then RELEASE is better:

Code: Pascal  [Select][+][-]
  1. Procedure TForm1.FormActivate(Sender: TObject);
  2.  Begin
  3.   If booKillSplash
  4.   Then
  5.    Begin
  6.     If Assigned(wndSplash)
  7.     Then wndSplash.Release;
  8.    End;
  9.  End;
  10.  
  11.  
  12. Procedure TForm1.FormPaint(Sender: TObject);
  13.  Begin
  14.   wndSplash.BringToFront;
  15.   booKillSplash:= True;
  16.  End;
  17.  
  18.  
  19. Procedure TForm1.wndSplashClick(Sender: TObject);
  20.  Begin
  21.   wndSplash.Release;
  22.  End;
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: Creating forms dynamically
« Reply #16 on: July 15, 2017, 07:25:55 am »
If you like to draw yourself, then you can download BGRABitmap from here https://github.com/bgrabitmap/bgrabitmap, extract it into the main program directory and use the attached program...  :)

// interesting, if I use DRAW then the edge of the PNG looks darker and not like the original one...   maybe I can figure it out tomorrow...
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: Creating forms dynamically
« Reply #17 on: July 15, 2017, 07:29:03 am »
 The edge is definitely darker...  %)
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Creating forms dynamically
« Reply #18 on: July 15, 2017, 07:14:43 pm »
ThanksALot to all of you for your help which is really appreciated!

Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: Creating forms dynamically
« Reply #19 on: July 15, 2017, 07:21:28 pm »
RAW's fluid splashing splash screen really is splash screen.
+1

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: Creating forms dynamically
« Reply #20 on: July 16, 2017, 11:12:29 pm »
Dietmar found a bug...
I haven't noticed that: OnPaint should be executed only once.  :)

Code: Pascal  [Select][+][-]
  1. PRIVATE
  2.  booOnce: Boolean;
  3.      
  4. Procedure TForm1.FormPaint(Sender: TObject);
  5.  Begin
  6.   If Not booOnce
  7.   Then
  8.    Begin
  9.     wndSplash.BringToFront;
  10.     booKillSplash:= True;
  11.     booOnce      := True;
  12.    End;
  13.  End;

OR

Code: Pascal  [Select][+][-]
  1. Procedure TForm1.FormActivate(Sender: TObject);
  2.  Begin
  3.   If booKillSplash
  4.   Then
  5.    Begin
  6.     If Assigned(wndSplash)
  7.     Then
  8.      Begin
  9.       wndSplash.Release;
  10.       wndSplash:= Nil;
  11.      End;
  12.    End;
  13.  End;
  14.    
  15.      
  16. Procedure TForm1.FormPaint(Sender: TObject);
  17.  Begin
  18.   If Assigned(wndSplash)
  19.   Then
  20.    Begin
  21.     wndSplash.BringToFront;
  22.     booKillSplash:= True;
  23.    End;
  24.  End;
  25.  
  26.  
  27. Procedure TForm1.wndSplashClick(Sender: TObject);
  28.  Begin
  29.   wndSplash.Release;
  30.   wndSplash:= Nil;
  31.  End;
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Creating forms dynamically
« Reply #21 on: July 18, 2017, 11:06:19 pm »
Why form.release instead form.free ?
Be mindful and excellent with each other.
https://github.com/cpicanco/

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: Creating forms dynamically
« Reply #22 on: July 18, 2017, 11:47:01 pm »
I guess it's my habit...
(In this case probably overkill)  ... you don't have to copy it...   :)
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Creating forms dynamically
« Reply #23 on: July 19, 2017, 12:57:33 am »
Release : mark for destruction -> I am guessing it is not destroyed immediately
Free : destroy -> Immediately?

Just trying to learn something new  :)
Be mindful and excellent with each other.
https://github.com/cpicanco/

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: Creating forms dynamically
« Reply #24 on: July 19, 2017, 02:13:39 am »
I guess RELEASE let the form handle all messages before the form will be destroyed.
Maybe it's more safe...  :)

Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

 

TinyPortal © 2005-2018