Recent

Author Topic: Splash form "in pieces"  (Read 6554 times)

dietmar

  • Full Member
  • ***
  • Posts: 170
Splash form "in pieces"
« on: September 09, 2021, 06:41:38 pm »
Hi!

I designed a splash form with an image on it and a progress bar. Tested that on 2 different Notebooks. On the first one (where I designed it), I set Position to "poScreenCenter" and it just looks fine (resolution: 1600x900).

On the second one (resolution: 1920x1080) I get 2 problems:
1. The Splash form is not in the center, but out of it.
2. The progress bar isn't on the form any more, but somewhere in the middle of the desktop!?!

Does anyone have an explanation or even a solution for this behaviour?

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

MarkMLl

  • Hero Member
  • *****
  • Posts: 6647
Re: Splash form "in pieces"
« Reply #1 on: September 09, 2021, 07:05:36 pm »
No, but a good place to start would probably be in the Screen and ScreenInfo objects which allow you to get at the screen/monitor dimensions (with the caveat that I've not looked at this on Windows, only Linux/Solaris).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Splash form "in pieces"
« Reply #2 on: September 09, 2021, 08:11:59 pm »
Hi!

Not an explanation but a solution to center the SplashForm in the center:

Code: Pascal  [Select][+][-]
  1. procedure TSplashForm1.FormCreate(Sender: TObject);
  2. begin
  3.   left := (Screen.Width - self.Width) div 2;
  4.   Top :=  (Screen.Height - self.height) div 2;
  5. end;
  6.  


And the progressbar:
Make shure, that the parent of the progressbar is the SplashForm:

Right click on the progressbar  --> Change Parent


Winni

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Splash form "in pieces"
« Reply #3 on: September 09, 2021, 10:25:22 pm »
Thx, the centering now works...

But unfortunately, the progress bar already has the form as parent.
One crazy solution could be to calculate the position of the progress bar relatively to the form position...

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

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Splash form "in pieces"
« Reply #4 on: September 09, 2021, 10:32:52 pm »
No, doesn't work this way. If I change the Left and Top values of the progress bar, it is completely hidden and no longer visible on the screen :/

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

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Splash form "in pieces"
« Reply #5 on: September 09, 2021, 10:40:01 pm »
Hi!

Whatever you compute with the progressbar ...

Place the ProgressBar to your  needs.

Use the poroperty anchor in the OI:
Anchor it to all 4 sides.

If that does not help we need some code.

Winni

wp

  • Hero Member
  • *****
  • Posts: 11831
Re: Splash form "in pieces"
« Reply #6 on: September 09, 2021, 11:16:53 pm »
When it's only a splash form then it should not be too difficult for you to extract it and demonstrate the issue in a simple compilable project. Too much guessing otherwise.

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Splash form "in pieces"
« Reply #7 on: September 13, 2021, 05:08:30 pm »
Ok, here it is...

Please notice:
Since I left the SQLite Init Routines in the form (because perhaps they are the reason for the problem?), you have to copy sqlite.dll into the folder to get it working.

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

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Splash form "in pieces"
« Reply #8 on: September 20, 2021, 03:45:24 pm »
The strange thing I just noticed is that even calculating the screen center for the splash form like

Code: Pascal  [Select][+][-]
  1. procedure TSplashForm1.FormCreate(Sender: TObject);
  2. begin
  3.   left := (Screen.Width - self.Width) div 2;
  4.   Top :=  (Screen.Height - self.height) div 2;
  5. end;
  6.  

does not work :(

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

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Splash form "in pieces"
« Reply #9 on: September 20, 2021, 04:53:24 pm »
The strange thing I just noticed is that even calculating the screen center for the splash form like

Code: Pascal  [Select][+][-]
  1. procedure TSplashForm1.FormCreate(Sender: TObject);
  2. begin
  3.   left := (Screen.Width - self.Width) div 2;
  4.   Top :=  (Screen.Height - self.height) div 2;
  5. end;
  6.  

does not work :(

--Dietmar

Hi!

Set the property position in the OI to poDesigned.

Otherwise the code does not work.

Winni

robert rozee

  • Full Member
  • ***
  • Posts: 153
Re: Splash form "in pieces"
« Reply #10 on: September 20, 2021, 05:56:28 pm »
the method i use (with a regular form) is:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   Form1.Left:=(Form1.Monitor.WorkAreaRect.Width-Form1.Width) div 2;    // approximate centre of screen, ignores title bar height
  4.   Form1.Top:=(Form1.Monitor.WorkAreaRect.Height-Form1.Height) div 2;   // and side border widths, but is the best we can do.
  5.   AlphaBlendValue:=0;                                                  // start up invisible, Timer1 handler
  6.   AlphaBlend:=true                                                     // fades in over approximately 225ms (comment out for testing)
  7. end;
  8.  
  9.  
  10. procedure TForm1.Timer1Timer(Sender: TObject);                         // (15ms timer event)
  11. const startup:boolean=true;
  12.       holdoff:integer=-90;
  13. begin
  14.   if startup then                                                      // startup with AlphaBlend=true, slow fade in after holdoff
  15.   begin
  16.     if holdoff<0 then inc(holdoff, Timer1.Interval)
  17.                  else AlphaBlendValue:=min(AlphaBlendValue+17, 255);
  18.     if AlphaBlendValue=255 then
  19.     begin
  20.       AlphaBlend:=false;                                               // at 100% visibility turn off AlphaBlend
  21.       startup:=false                                                   // set end of startup flag, never end up here again
  22.     end
  23.   end
  24. end;


as winni said, set the property position in the object inspector to poDesigned.

the 90ms holdoff is to allow the form to 'snap' into position before it starts to become visible. without any holdoff, the form can be visibly seen moving on the screen. the above works in linux, as well as under winXP running in a VM.


cheers,
rob   :-)


dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Splash form "in pieces"
« Reply #11 on: September 21, 2021, 05:12:28 pm »
Hm,

unfortunately, "poDesigned" didn't help either :(

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

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Splash form "in pieces"
« Reply #12 on: September 21, 2021, 10:29:02 pm »
Hm, I think I just encountered a bug:

When I set Position to poDesigned, all seems ok. But when I restart Lazarus afterwards, it is set back to poScreenCenter! And I assume that when compiling the project, it is already "poScreenCenter" again and therefore the code doesn't work!

I searched the whole code whether there is any sign of setting it back, but I didn't found a line...

Can anyone confirm this behaviour?

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

MarkMLl

  • Hero Member
  • *****
  • Posts: 6647
Re: Splash form "in pieces"
« Reply #13 on: September 21, 2021, 10:38:25 pm »
Hm, I think I just encountered a bug:

When I set Position to poDesigned, all seems ok. But when I restart Lazarus afterwards, it is set back to poScreenCenter! And I assume that when compiling the project, it is already "poScreenCenter" again and therefore the code doesn't work!

I searched the whole code whether there is any sign of setting it back, but I didn't found a line...

Can anyone confirm this behaviour?

Not as such, but I've been considering mentioning that my experience on Linux is that that setting is- at best- widget-set specific. It's like the old joke about social scientists' most robust prediction being "Some do, some don't".

So I'm afraid that I stick by my (much) earlier comment

Quote
No, but a good place to start would probably be in the Screen and ScreenInfo objects which allow you to get at the screen/monitor dimensions (with the caveat that I've not looked at this on Windows, only Linux/Solaris).

i.e. you need to dump what the various properties report in a way that doesn't itself mess up your user interface rather than trying to use them blindly.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Splash form "in pieces"
« Reply #14 on: September 22, 2021, 12:34:18 am »
Hm, I think I just encountered a bug:

When I set Position to poDesigned, all seems ok. But when I restart Lazarus afterwards, it is set back to poScreenCenter! And I assume that when compiling the project, it is already "poScreenCenter" again and therefore the code doesn't work!

I searched the whole code whether there is any sign of setting it back, but I didn't found a line...

Can anyone confirm this behaviour?

--Dietmar

Hi!

I cant confirm this. Everything works a exspected.
Lin64, gtk2, fpc 3.2, Laz 2.0.12

But you can enhance you code to:

Code: Pascal  [Select][+][-]
  1.     procedure TSplashForm1.FormCreate(Sender: TObject);
  2.     begin
  3.      self.position := poDesigned; // <-- !!!!!
  4.       left := (Screen.Width - self.Width) div 2;
  5.       Top :=  (Screen.Height - self.height) div 2;
  6.     end;
  7.  
     

Winni


 

TinyPortal © 2005-2018