Solved

Program not responding

Posted on 2009-05-05
4
554 Views
Last Modified: 2012-05-06
I have an application that copies files from the origional directory to a backup/copy directory with a tProgress bar and 2 tLabels to show the progress of the copy
If the user clicks on the program or the windows screen NOT RESPONDING show on the top of the application and the tprogress bar and tlabels stop showing the progress - the program is still running but the user thinks its stopped and exits it. causing the copy not to be completed

How do I stop the the not responding and keep the tProgress bar and tlabels working

attached is a part of the code I am using
for i := 0 to filelistbox.Items.Count - 1 do begin             // Listbox with the files to bg copied
      pbBuild.stepit;                                                          // tProgress Bar
      f := 'c:\backupfiles\' + filelistbox.Items.Strings[i];    
      f1 := 'c:\origionalfiles\' + filelistbox.Items.Strings[i];         
      Label1.caption := 'From  ' + f;
      Label2.caption := 'To  ' + f1;
      Label1.refresh;
      Label2.refresh;
      form1.Refresh;
      CopyFile(PChar(f), PChar(f1), False);
      appscount := appscount + 1;
      form1.bringtofront;
      lCopied.Caption := 'Files Copied - ' + inttostr(AppsCount);
      lCopied.repaint;
      form1.Repaint;
      form1.refresh;
  end;

Open in new window

0
Comment
Question by:Kevinfeening
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 500 total points
ID: 24310012
Try throwing in Application.ProcessMessages - just a guess :p
0
 

Expert Comment

by:davizinx
ID: 24310075
you can use this

Procedure CopyFiles;
var
i : integer;
begin
for i := 0 to filelistbox.Items.Count - 1 do begin             // Listbox with the files to bg copied
      pbBuild.stepit;                                                          // tProgress Bar
      f := 'c:\backupfiles\' + form1.filelistbox.Items.Strings[i];    
      f1 := 'c:\origionalfiles\' + form1.filelistbox.Items.Strings[i];         
      form1.Label1.caption := 'From  ' + f;
      form1.Label2.caption := 'To  ' + f1;
      form1.Label1.refresh;
      form1.Label2.refresh;
      form1.Refresh;
      CopyFile(PChar(f), PChar(f1), False);
      appscount := appscount + 1;
      form1.bringtofront;
      form1.lCopied.Caption := 'Files Copied - ' + inttostr(AppsCount);
      form1.lCopied.repaint;
      form1.Repaint;
      form1.refresh;
  end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
id : cardinal;
begin
 BeginThread(nil,0,@CopyFiles,nil,0,ID);
end;

Open in new window

0
 

Expert Comment

by:davizinx
ID: 24310087
ps: specify in all components used in the procedure "CopyFile"  Form1.  before.(ex: like i forget fist[Form1.filelistbox.Items.Count...])
0
 

Author Closing Comment

by:Kevinfeening
ID: 31578282
Simple solutions are the best
Thanks
Kevin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question