Recent

Author Topic: Controls inside the form disappear in execution.  (Read 9116 times)

Ecsa

  • New Member
  • *
  • Posts: 14
Controls inside the form disappear in execution.
« on: January 25, 2023, 05:36:10 pm »
Hello, I have had a problem for months that I cannot solve and it is the following.

I create a new project in lazarus version 2.2.4 32 bits on my pc with Windows pro 64 bits, in which I have a simple form to which I add a groupbox, two buttons, a combobox, a progress bar and a listview all these inside the groupbox everything is perfect when it comes to displaying when I execute this form, but I have the problem that when I click inside the form in any location and then with the mouse I click on the Windows taskbar, all the elements They disappear from my form, so to be able to see the components again I have to minimize and then restore the application and everything looks normal, but it's something very annoying and I don't know what I should do to prevent this from happening, it happens with any form and I have tried on several computers and always the same error, does anyone know of a possible solution, I am attaching illustrative images to better understand the problem, thank you very much for your answers in advance.

image GIF: https://imgur.com/e1vsfKR

Video MP4: https://www.mediafire.com/file/i69oiaa2fz11ayr/tloQCeRHbE.mp4/file
« Last Edit: January 25, 2023, 06:14:39 pm by Ecsa »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Controls inside the form disappear in execution.
« Reply #1 on: January 25, 2023, 05:47:15 pm »
Can you attach a small demo project please? I just tried (I only got 64bit compiler) and there I do not have this kind of effect showing. Maybe it is something different ...
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Ecsa

  • New Member
  • *
  • Posts: 14
Re: Controls inside the form disappear in execution.
« Reply #2 on: January 25, 2023, 05:55:33 pm »
I already attached the project, and this happens to me with all the projects that I am going to create, sometimes you have to click several times on the form and then outside of it, as in this case on the taskbar or even to check the icons hidden in the Windows system tray. It doesn't always come out the first time it's clicked, I'm going to upload a video to show the error.

image GIF: https://imgur.com/e1vsfKR
« Last Edit: January 25, 2023, 06:06:05 pm by Ecsa »

WooBean

  • Sr. Member
  • ****
  • Posts: 253
Re: Controls inside the form disappear in execution.
« Reply #3 on: January 25, 2023, 06:43:16 pm »
Hi, Ecsa

I tried your test project on win 7/64 pro, Lazarus 2.2.0, FPC 3.2.2 for both targets - win64 and win32 - it seems there is no problem. Nothing strange  (as you described) happened to me.

Your months of an unsuccesful fight sound alarming.
My suggestions - check Lazarus installations, viruses, hardware. May be it is better to use 64 bit installation of Lazarus with support of 32 bit target? (Needed downloading and installing cross-compiller lazarus-2.2.4-fpc-3.2.2-cross-i386-win32-win64.exe). 
« Last Edit: January 25, 2023, 07:01:07 pm by WooBean »
Platforms: Win7/64, Linux Mint Ulyssa/64

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Controls inside the form disappear in execution.
« Reply #4 on: January 25, 2023, 06:55:56 pm »
Lazarus 2.2.4 (rev lazarus_2_2_4) FPC 3.2.2 x86_64-win64-win32/win64

I've run and tested, strange thing is, when I build on my own, all works like it should, importing and running your demo shows me same behaviour.
It seems like, when "TGroupBox" is the only control on form, something shitty happen at repaint/refresh/update.

First thing I've changed was to put a panel inside the GB with alClient and moved all of your controls on it. That reduced the error but not stopped it.
Second, I've put a panel alClient on form on moved GB alClient inside. That reduced the error but not stopped it.
Third, I've put another panel alBottom on form (outside of above panel/GB). That almost reduced the error to zero but not stopped it.

I am clueless what there is going on. I try to investigate that deeper. To me it look like a bug.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

wp

  • Hero Member
  • *****
  • Posts: 12143
Re: Controls inside the form disappear in execution.
« Reply #5 on: January 25, 2023, 07:07:23 pm »
Unlike KodeZwerg I cannot reproduce the issue on Win-11 neither with Laz 2.2.4/FPC 3.2.2/64 bit nor 32-bit nor with Laz main/FPC 3.2.2 32bit.

Yes, anti-virus is always a good candidate to explain something unsual happening. Put your Lazarus installation directory as well as your project directory(directories) on the white-list of the virus scanner. Turn off anti-virus for a test. If this fixes the issue send a report to the provider of the antivirus application.

The next candidates are third-party packages. Since installed packages are linked into the IDE they can cause malfunction of the IDE. Find out the directory in which your user settings are stored: Go to "View" > "IDE Internals" > "About IDE"; in the second paragraph (under "Global IDE Options") read the "primary config directory" items and write down the path. Close Lazarus. In the Windows Explorer, go to this path and rename it. Restart the IDE - this will write default user settings, without installed packages. Go to "Tools" > "Configure Build Lazarus" and check "Clean all" and "Switch after building to automatically", then click "Build". This rebuilds a new ID, without your packages. Repeat your tests with simple projects (which do not require the packages). If the issue is gone install your packages one by one and repeat the tests again so that you find out which packages is causing the trouble. Contact the author of the package and tell him about the issue caused by his package (or drop a note here in the forum).

Do you use the docked user interface (anchor docking)? There are many reports about issues caused by this package.

If you are still unsuccessful the easiest way is to reinstall Lazarus. Choose a "secondary installation" in the installer; this keeps the new installation separate from your old installation. You must specify a directory for your user settings here on some page of the installer. And you should not associate file types with Windows because when you have several Lazarus installations you never know which version opens upon a double-click.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Controls inside the form disappear in execution.
« Reply #6 on: January 25, 2023, 07:25:29 pm »
My current only work-around, quick and dirty:
Code: Pascal  [Select][+][-]
  1.   TForm1 = class(TForm)
  2.     procedure DoFix(Sender: TObject);
  3.     procedure FormCreate(Sender: TObject);
  4.   private
  5.   public
  6.   end;
  7.  
  8. implementation
  9.  
  10. procedure TForm1.FormCreate(Sender: TObject);
  11. begin
  12.   Application.OnActivate := @DoFix;
  13.   Application.OnDeactivate := @DoFix;
  14. end;
  15.  
  16. procedure TForm1.DoFix(Sender: TObject);
  17. var
  18.   i: Integer;
  19. begin
  20.   for i := 0 to Pred(ControlCount) do
  21.     begin
  22.       // one of them fixes the disappearing...
  23.       TControl(Controls[i]).Refresh;
  24.       TControl(Controls[i]).Repaint;
  25.       TControl(Controls[i]).Update;
  26.     end;
  27. end;
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Ecsa

  • New Member
  • *
  • Posts: 14
Re: Controls inside the form disappear in execution.
« Reply #7 on: January 25, 2023, 07:39:45 pm »
Hi, Ecsa

I tried your test project on win 7/64 pro, Lazarus 2.2.0, FPC 3.2.2 for both targets - win64 and win32 - it seems there is no problem. Nothing strange  (as you described) happened to me.

Your months of an unsuccesful fight sound alarming.
My suggestions - check Lazarus installations, viruses, hardware. May be it is better to use 64 bit installation of Lazarus with support of 32 bit target? (Needed downloading and installing cross-compiller lazarus-2.2.4-fpc-3.2.2-cross-i386-win32-win64.exe).

I have tried in a clean installation of windows and also with recently installed lazarus without adding any new package, everything by default when creating the project and this happens in all versions of Windows from 7 to 11 (non-virtualized physical machines) where I have seen the same mistake. And of course it can be an error as mentioned.

Ecsa

  • New Member
  • *
  • Posts: 14
Re: Controls inside the form disappear in execution.
« Reply #8 on: January 25, 2023, 07:40:29 pm »
My current only work-around, quick and dirty:
Code: Pascal  [Select][+][-]
  1.   TForm1 = class(TForm)
  2.     procedure DoFix(Sender: TObject);
  3.     procedure FormCreate(Sender: TObject);
  4.   private
  5.   public
  6.   end;
  7.  
  8. implementation
  9.  
  10. procedure TForm1.FormCreate(Sender: TObject);
  11. begin
  12.   Application.OnActivate := @DoFix;
  13.   Application.OnDeactivate := @DoFix;
  14. end;
  15.  
  16. procedure TForm1.DoFix(Sender: TObject);
  17. var
  18.   i: Integer;
  19. begin
  20.   for i := 0 to Pred(ControlCount) do
  21.     begin
  22.       // one of them fixes the disappearing...
  23.       TControl(Controls[i]).Refresh;
  24.       TControl(Controls[i]).Repaint;
  25.       TControl(Controls[i]).Update;
  26.     end;
  27. end;

Thank you, I will review and apply it to other projects to see if this detail can be avoided in this way.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Controls inside the form disappear in execution.
« Reply #9 on: January 25, 2023, 07:44:09 pm »
Buena suerte y de nada // Good luck and you're welcome
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Controls inside the form disappear in execution.
« Reply #10 on: January 25, 2023, 07:59:51 pm »
After more testing, Refresh <or> Repaint is enough, Update you can delete out. I suggest to stick with Refresh, works best for me.
But as every medal has two sides, on one side it really does fix that disappearing on the other side you will see for a micro second a flicker on form, I am sorry.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DoFix(Sender: TObject);
  2. var
  3.   i: Integer;
  4. begin
  5.   for i := 0 to Pred(ControlCount) do
  6.     TControl(Controls[i]).Refresh;
  7. end;
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

wp

  • Hero Member
  • *****
  • Posts: 12143
Re: Controls inside the form disappear in execution.
« Reply #11 on: January 25, 2023, 08:05:31 pm »
Still, I would like to understand why I am not seeing this. Are you using anchordocking?

dsiders

  • Hero Member
  • *****
  • Posts: 1179
Re: Controls inside the form disappear in execution.
« Reply #12 on: January 25, 2023, 08:13:19 pm »
Still, I would like to understand why I am not seeing this. Are you using anchordocking?

I use AnchorDocking/DockedFormEditor, and I do not see this behavior in 2.2.4 or 2.3.0.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Controls inside the form disappear in execution.
« Reply #13 on: January 25, 2023, 08:13:46 pm »
Still, I would like to understand why I am not seeing this. Are you using anchordocking?
I tried with a full installation of my Lazarus, lots of Components from OPM added also AnchorDocking. How can that have an impact for running an compiled executable?
I am sorry, for myself I can not put another "clean" Lazarus installation on my system to test, I just can try to find out what happen, give me more time please.
All I can say, something shitty happen in Application.On(de)Activate, in both original events the controls random disappear (in demo the only control that is not affected is the progressbar)
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

WooBean

  • Sr. Member
  • ****
  • Posts: 253
Re: Controls inside the form disappear in execution.
« Reply #14 on: January 25, 2023, 08:15:40 pm »
Still, I would like to understand why I am not seeing this. Are you using anchordocking?

Well, my trials were from docked IDE, Lazarus 2.2.0, FPC 3.2.2, Win7pro/64 and no errors occured.
BTW, on Linux 64, gtk2, Lazarus 2.2.0, IDE docked, a form looks a little ugly but works as should (no hidden controls).   
Platforms: Win7/64, Linux Mint Ulyssa/64

 

TinyPortal © 2005-2018