Search code examples
htmldelphidelphi-xe7

(Delphi) Is it possible to change a label to whats in a .html file?


Is it possible to change a Label caption to what is in a .html file? Lets say the .html file contains 1.0 in it. Can I make the Label retrieve that and change its Caption to that value?

Eg. lbl1.caption := http://www.example.com/example.html;

Is it possible to do this?


Solution

  • TLabel cannot load content for you, whether that is from a file or a remote URL. You have to write your own code to retrieve the content yourself, and then you can assign it to the TLabel. For example:

    // using the Indy TIdHTTP component...
    lbl1.Caption := IdHTTP1.Get('http://www.example.com/example.html');