现在写的进度条运行,必须在窗体显示后,通过按钮点击事件,才运行。
我想显示后,不通过按钮点击,直接运行。
form.onshow用了,窗体就变白程序假死了。
该用哪个事件?

解决方案 »

  1.   

    application.processmessage或者放到线程里去处理进度条
      

  2.   


        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                for (int i = 0; i <= 10; i++)
                {
                    this.progressBar1.Value = 10 * i;
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
      

  3.   

    我已经按照2楼说的,通过线程实现进度条自动运行,
    但是怎么样实现线程内容完成后结束程序。
    我把application.Terminate;写在线程事件里面,
    发现程序窗体没有了,但是内存中还是存在!
    应该在哪个事件中,获取线程执行完毕的参数,然后结束程序???
      

  4.   

    贴点代码看看。
    application.Terminate应该是把整个进程都终止了。有没有可能是其他代码由在启动你的程序
      

  5.   


    procedure RunExe;
    begin
      form1.Hide;
      winexec(pchar(LocalDir + '\' + Entry), sw_show);
      application.Terminate;
    end;
    function MyThreadFun(p: Pointer): Integer; stdcall;
    var
      LName, LTime, RName, RTime, DownloadList: TStrings;
      i, j, k: integer;
      f: TextFile;
      a: TStringList;
    begin
      form1.FTPClient.Connect();
      //省略部分代码
      downloadlist.Free;
      Result := 0;
      RunExe();
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    var
      ID: DWORD;
      ExitCode: DWORD;
      Text:string;
    begin
      //省略部分代码
      hThread := CreateThread(nil, 0, @MyThreadFun, nil, 0, ID);
    end;
      

  6.   

    线程用法有问题,你在线程里访问了Form1上的组件
      

  7.   

    那么在线程事件不变化的情况下,如何实现线程事件完成后,调用RunExe();