Exemplo n.º 1
0
//---------------------------------------------------------------------------
void __fastcall TServerGuiForm::StartButtonClick(TObject *Sender)
{ // This does all the real work.
 // D 1. Check that there are protocols
 // D 2. Check that there is a reply and it can be loaded
 // D 3. Check that there is a server
 // D 4. Load the protocols
 // D 5. Load the server
 // D 6. Enable Stop
 // D 7. Disable Start
 // 8. Update Count
 if (!ProtocolsListBox->Items->Count)
    {
     Application->MessageBox( "Please select protocol and port combination to use", Caption.c_str(), MB_OK );
     return;
    }
 if (ReplyComboBox->ItemIndex==-1)
    {
     Application->MessageBox( "Please select reply type to use", Caption.c_str(), MB_OK );
     return;
    }
 if (ServerComboBox->ItemIndex==-1)
    {
     Application->MessageBox( "Please select server type to use", Caption.c_str(), MB_OK );
     return;
    }
// ServerComboBox->Enabled=False;
// ReplyComboBox->Enabled=False;
// AddButton->Enabled=False;
// RemoveButton->Enabled=False;
// ClearButton->Enabled=False;
 StartButton->Enabled=False;
 StopButton->Enabled=True;
 SettingsPanel->Enabled=False;
 sr=allocate_reply();
 if (!sr) return;
 InitNetwork();
 sp=allocate_protocol();
 if (!sp)
   {
    cleanup( NULL, sr, NULL );
    sr=NULL;
    return;
   }
 ss=allocate_servers( sr, sp );
 if (!ss)
   {
    cleanup( NULL, sr, sp );
    sr=NULL;
    sp=NULL;
    return;
   }
 ActivityTimer->Enabled=True;
 ss->serv->StartServer( ss->handle );
}
//---------------------------------------------------------------------------
void __fastcall TTrafficServerForm::StartButtonClick(TObject *Sender)
{
    if (!ProtocolsListBox->Items->Count)
    {
        Application->MessageBox( "Please select protocol and port combination to use", Caption, TMessageButtons() << smbOK, smsWarning );
        return;
    }
    if (ReplyComboBox->ItemIndex==-1)
    {
        Application->MessageBox( "Please select reply type to use", Caption , TMessageButtons() << smbOK, smsWarning  );
        return;
    }
    if (ServerComboBox->ItemIndex==-1)
    {
        Application->MessageBox( "Please select server type to use", Caption, TMessageButtons() << smbOK, smsWarning );
        return;
    }
    StartButton->Enabled=False;
    StopButton->Enabled=True;
    SettingsPanel->Enabled=False;
    sr=allocate_reply();
    if (!sr)
    {
        StartButton->Enabled=True;
        StopButton->Enabled=False;
        return;
    }
    InitNetwork();
    sp=allocate_protocol();
    if (!sp)
    {
        StartButton->Enabled=True;
        StopButton->Enabled=False;
        cleanup( NULL, sr, NULL );
        sr=NULL;
        return;
    }
    ss=allocate_servers( sr, sp );
    if (!ss)
    {
        StartButton->Enabled=True;
        StopButton->Enabled=False;
        cleanup( NULL, sr, sp );
        sr=NULL;
        sp=NULL;
        return;
    }
    ActivityTimer->Enabled=True;
    ss->serv->StartServer( ss->handle );
}