Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My Program Ain't Crashing

Status
Not open for further replies.

BitTrack

Programmer
Nov 21, 2009
1
US
But it sure looks like it. Here's the deal, the user opens
a file and a fair amount of processing has to take place before any interaction can occur. I want to put up a Splash Screen or something so they don't ctrl-alt-delete out of there before all the fun and games begin ;) So I tried a splash screen but it don't paint. The code I'm trying looks like this...

Code:
  if FileExists(fname) then begin
     SplashForm.Show
     Process(fname); 
     SplashForm.Hide
  end;


Thanks






 
Firstly, adding something to a slow process is never a good idea.

I need some information about your code. The code you've shown tells me nothing about your forms. How many forms do you create in the DPR? How many of them have additional code in the OnCreate method? Set a breakpoint on your 1st Application.CreateForm() in the DPR and single step from there. It should become obvious where it's spending the most time. Ofter adding an Application.ProcessMessages in the right place can solve this type of issue.

If you need more help with that, post the code snippet where it's hanging.

Good luck and happy coding.

Roo
Delphi Rules!
 
another option would be to change the cursor to the hourglass...

Code:
var
Save_Cursor : TCursor;
..... 
if FileExists(fname) then 
begin
  Save_Cursor := Screen.Cursor;  //save normal cursor
  Screen.Cursor := crHourGlass;  //change screen cursor
  try   
     Process(fname); 
  finally
    Screen.Cursor := Save_Cursor; //restore to normal
  end;
end;

Leslie
 
And you are ofcourse giving other threads the opportunity to do something by releasing CPU cycles with Application.ProcessMessages during your processing/loading? Because if not, then the splash will never get painted...

HTH
 
You have to call Application.ProcessMessages after you put up the splash screen in order to get the drawing to happen.

Or you could put the call to the slow routine in the splash-form's FormActivate method.
 
I think y'all are missing the point...

Inserting a splash-screen at the beginning of a slow-starting application is NOT a good idea, with or without processing windows messages. The OP's mission should be to identify the bottle-neck and rectify the problem.

It may now be a non-issue since the OP is a one-timer who never replied to any of our replies...

Roo
Delphi Rules!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top