autoupgrader OnPasswordRequest event
Return to Introduction  Previous page  Next page
Applies to
auAutoUpgrader and auHTTP components.  

Declaration
type  
  TauHTTPPasswordRequestEvent = procedure(Sender: TObject;  
     var TryAgain: Boolean) of object;  
 
property OnPasswordRequest: TauHTTPPasswordRequestEvent;  

Description
The OnPasswordRequest event can be used to implement custom dialog box which asks user for his username and password to get access to the file which stored in the password protected Web area.  
 
tip Usually you don't need to use this event. For example, your files can be open for everyone, or you wish to use standard, built-in password-request dialog (see screenshot) which will displayed if mPasswordRequest flag of ShowMessages property set to True.  
 
However, if you still want to use your own password-request dialog, then set TryAgain parameter to True to retry the HTTP query (attempt to download the file), and specify correct login information to the HTTPUsername and HTTPassword properties.  
 
Example
Delphi:
procedure TauAutoUpgrader.AutoUpgrader1PasswordRequest(Sender: TObject; var TryAgain: Boolean);  
begin  
  { PassForm is any form with two edit boxes used for entering the login information (username and password) }  
  if PassForm.ShowModal = ID_OK then  
  begin  
    auAutoUpgrader1.HTTPUsername := PassForm.UsernameEdit.Text;  
    auAutoUpgrader1.HTTPPassword := PassForm.PasswordEdit.Text;  
    TryAgain := True; // Retry download attempt  
  end;  
end;  



C++ Builder:

void __fastcall TForm1::auAutoUpgrader1PasswordRequest(TObject *Sender, bool &TryAgain)  
{  
  if (PassForm->ShowModal() == ID_OK)  
  {  
    auAutoUpgrader1->HTTPUsername = PassForm->UsernameEdit->Text;  
    auAutoUpgrader1->HTTPPassword = PassForm->PasswordEdit->Text;  
    TryAgain = True; // Retry HTTP query (download attempt)  
  };  
}  

See also

HTTPUsername, HTTPPassword and ShowMessages properties;  
Password request (screenshot).