A list box can display a hundred proxies while TIdHTTP keeps using the same one. Selecting a row changes the interface; the next request changes route only after the selected endpoint reaches the HTTP client's configuration.

For public HTTP downloads, entries from the HTTP proxy list can supply candidate endpoints. Keep a host and integer port behind each displayed entry. When the selection is accepted, apply both before starting the download:

IdHTTP1.ProxyParams.ProxyServer := ChosenHost;
IdHTTP1.ProxyParams.ProxyPort := ChosenPort;
Page := IdHTTP1.Get(TargetURL);

This fragment assumes an idle client, a validated endpoint and the application's existing variables. The target URL remains the website. The proxy host field takes a host, not the website URL or a display label.

A selection needs three possible outcomes

  • A valid proxy selection supplies a host and a port from 1 through 65535.
  • An explicit Direct choice clears the proxy host for the next request.
  • An invalid or missing selection leaves the current configuration intact and asks the user to correct it.

Keeping those outcomes distinct prevents a deselected row from unexpectedly sending the next request directly. Disable the request button while a new choice is incomplete.

If endpoints arrive as text, parse and validate them before changing either property. TryStrToInt lets the interface report a bad port without an uncaught conversion exception. Splitting at the first colon is suitable only for a deliberately restricted hostname-or-IPv4 format: an IPv6 literal contains colons of its own. A separate host field and port field make the stored representation simpler.

Do not let a UI click modify a client that a worker is already using. Apply the choice between operations, or give each concurrent operation its own configured client. The picker controls future connections; it cannot move an established transfer onto another exit.

Ũhoro ũhĩtĩte