procedure TForm1.SpeedButton1Click(Sender: TObject);
var
 hostip:string;
begin
if not clientsocket1.Active then
begin
if inputQuery('info','Enter Remote Host Ip:',hostip) then clientsocket1.Host:=hostip else clientsocket1.Host:='127.0.0.1';
clientsocket1.Active:=true;
IsNext:=true;
cmdbuff[2]:=0;
timer1.Enabled:=true;
timer3.Enabled:=true;
panel3.Visible:=true;
end;

解决方案 »

  1.   

    procedure TForm1.SpeedButton1Click(Sender: TObject);
    var
        hostip:string;
    begin
        if not clientsocket1.Active then
    /////////如果ClientSocket1没有连接
        begin
            if inputQuery('info','Enter Remote Host Ip:',hostip) then 
    ////////////显示一个输入框,提示 'Enter remote Host Ip'。如果是点了确认
                clientsocket1.Host:=hostip
    ///////////设置ClientSocket1的连接地址为刚才的输入地址
            else 
                clientsocket1.Host:='127.0.0.1';
    ///////////否则设置连接地址为本机127.0.0.1
            clientsocket1.Active:=true;
    //////////打开连接
            IsNext:=true;
            cmdbuff[2]:=0;
            timer1.Enabled:=true;
            timer3.Enabled:=true;
            panel3.Visible:=true;
    ////////////////设置程序的变量,无法解释。
        end;
    end;