procedure TLog_Form.SpeedButton1Click(Sender: TObject);
var username ,password :string ;
    Dq,ErrorInfo, Qx, user_num,rpqx: OleVariant ;
begin
  if edit1.Text='' then
  begin
     MessageDlg('请输入用户名称!',mtError,[mbOK],0);
     exit;
  end;
  username:=trim(edit1.text) ;
  if edit2.Text='' then
  begin
     MessageDlg('请输入用户密码!',mtError,[mbOK],0);
     exit;
  end;
  password :=trim(edit2.text) ;
  try
    statusbar1.Panels[1].Text :='正在连接....';
    if Main_form.ConnectionBroker1.Connected=false then
    Main_form.ConnectionBroker1.Connected :=true ;
    statusbar1.Panels[1].Text :='连接成功....';
    main_form.StatusBar1.Panels[1].Text :='目前以连接到中间件';
    main_form.StatusBar1.Panels[9].Text :='用户登录';
    if main_form.ConnectionBroker1.AppServer.CheckUser(username,password,dq,errorinfo,qx,user_num,rpqx) then
    begin
      main_form.Edit1.Text :=username ;
      main_form.StatusBar1.Panels[9].Text :=user_num ;
      main_form.SpeedButton2Click(main_form);
      log_form.Close ;
    end else
    begin
      main_form.Logined :=false ;
      statusbar1.Panels[1].Text :='连接失败,请重试!';
      if main_form.ConnectionBroker1.Connected then main_form.ConnectionBroker1.Close ;
      MessageDlg(ErrorInfo,mtError, [mbYes], 0);
    end;
  except
    on e:exception do
    begin
      if Main_form.ConnectionBroker1.Connected then Main_form.ConnectionBroker1.Close;
      begin
        MessageDlg('登录失败:'+E.Message,mtError, [mbYes], 0);
        main_form.StatusBar1.Panels[1].Text :='';
      end;
    end;
  end;
end;
每次用户登陆时候,登陆界面总是会变成白色,直到登陆成功才好,我想开一个线程来做,怎么做呢?

解决方案 »

  1.   

    如果单单是因为“每次用户登陆时候,登陆界面总是会变成白色,直到登陆成功才好,我想开一个线程来做”
    应该没必要,合理用refresh事件即可!
    //------------------------开线程例子-
    function other_DealDataProg(P:pointer):Longint;stdcall;
    begin//加入你的处理代码即可!
    end;
    procedure TForm_setup.Button1Click(Sender: TObject);
    var hThread:Thandle;//定义一个句柄
        ThreadID:longword;
    begin
      hthread:=CreateThread(nil,0,@other_DealDataProg,nil,0,ThreadID);
      if hThread=0 then
      showmessage('安装操作失败!');
    end;