Recent

Author Topic: Show progress dialog before showing main form  (Read 1495 times)

kinu

  • New Member
  • *
  • Posts: 12
Show progress dialog before showing main form
« on: October 18, 2021, 02:40:45 pm »
Hello!

In my main form OnShow I execute a long query, so I want to show a dialog with a progress bar or maybe only a label "Loading...." while executing the query.

So I put in my FormShow procedure something like this:

Code: Pascal  [Select][+][-]
  1.   FormProgress.Show;
  2.   MyQuery;
  3.   FormProgress.Hide;

And it shows an empty form. No label, nothing, just white background. FormProgress is created in application initialization. If I don't hide the form, it shows the 'Loading...' label when query is completed and main form is showed. Why?
« Last Edit: October 18, 2021, 02:43:26 pm by kinu »

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 733
Re: Show progress dialog before showing main form
« Reply #1 on: October 18, 2021, 02:50:17 pm »
Messages aren't processed. If query doesn't allow some sort of progress event, that would allow you to execute Application.ProcessMessages, then only option - is to execute query in another thread.
24.11.2021 - DynamicData 4.0 runtime is overhauled to improve scalability.
My project still requires full Delphi 2009 support to be ported to Lazarus.
It's time to finally do it, because Delphi 2009 is 12 years old.

jamie

  • Hero Member
  • *****
  • Posts: 5014
Re: Show progress dialog before showing main form
« Reply #2 on: October 18, 2021, 03:55:28 pm »
YEs, that is correct, you need to call the Application.ProcessMessages in your loop so that GDI/GUI gets updated.
The only true wisdom is knowing you know nothing

kinu

  • New Member
  • *
  • Posts: 12
Re: Show progress dialog before showing main form
« Reply #3 on: October 19, 2021, 08:54:30 am »
Messages aren't processed. If query doesn't allow some sort of progress event, that would allow you to execute Application.ProcessMessages, then only option - is to execute query in another thread.

Ok, I will try. If it doesn't work, I'll learn the thread thing to get it working. Thank you very much!

EDIT: Well, Application.ProcessMessages in AfterScroll event worked fine!!!!!
« Last Edit: October 19, 2021, 09:09:04 am by kinu »

 

TinyPortal © 2005-2018