Делаем простую программу, для просмотра картинок из интернета на С++.
Unit1.cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" #include <jpeg.hpp> //хедер для картинок //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { TFileStream* sf = new TFileStream ("temp.jpg", fmCreate); IdHTTP1->Get("http://screensaver-clock.ru/images/screensaver_b2scr.jpg",sf); delete sf; Image1->Picture->LoadFromFile("temp.jpg"); DeleteFile ("temp.jpg"); } //---------------------------------------------------------------------------
Unit1.h
//--------------------------------------------------------------------------- #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <System.Classes.hpp> #include <Vcl.Controls.hpp> #include <Vcl.StdCtrls.hpp> #include <Vcl.Forms.hpp> #include <Vcl.ExtCtrls.hpp> #include <IdBaseComponent.hpp> #include <IdComponent.hpp> #include <IdHTTP.hpp> #include <IdTCPClient.hpp> #include <IdTCPConnection.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TImage *Image1; TIdHTTP *IdHTTP1; private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif