Меню сайта
Категории раздела
Простые примеры [34] |
OpenGL [4] |
Фрактал [9] |
Windows API [2] |
Консоль [12] |
ДРУЗЬЯ САЙТА
Вызвать мастера в Красноярске
8 983 207 5474
8 902 918 9334
8 933 332 3164
---------------------------------
Запчасти бытткхники
Радиодетали
Электрика
ЗАКЛАДКИ
Поиск
Статистика
Онлайн всего: 1
Гостей: 1
Пользователей: 0
Главная » Статьи » C++ Builder » Простые примеры |
C++ BUILDER XE2 КАК ОТКРЫТЬ ФАЙЛЫ GIF, PNG, JPG, TIFF, BMP, EMF, WMF.
=========================== =============================== //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include <math.h> //для функц. FloatToStrF #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FileListBox1Click(TObject *Sender) { Image1->Picture->LoadFromFile(FileListBox1->FileName); TSearchRec SR ; float cb; if( FindFirst(FileListBox1->FileName,0, SR)==0 ){ cb = SR.Size ; cb=cb/1024 ;} FindClose(SR); Label1->Caption=" Ширина-"+ IntToStr(Image1->Picture->Width)+"p"+ " Высота-"+ IntToStr(Image1->Picture->Height)+"p"+ " Размер-"+ //FloatToStrF не только преобразует в строку но и соответствующим образом форматирует её здесь после запятой оставляет два знака остальное обрезается FloatToStrF(cb,ffFixed,10,2)+"kb" ; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { if( FileListBox1->Items->Count > 0){ if( FileListBox1->ItemIndex == -1){ FileListBox1->ItemIndex=0; FileListBox1Click(this);return;} FileListBox1->ItemIndex++; FileListBox1Click(this); } } //-----------назад---------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { if( FileListBox1->Items->Count > 0){ if( FileListBox1->ItemIndex == 0){ return;} if(FileListBox1->ItemIndex == -1 ){FileListBox1->ItemIndex=FileListBox1->Items->Count-1; FileListBox1Click(this); return; // this-скрытый указатель на объект Form1здесь можно любой указатель класса TObject можно Sender из Button2Click в FileListBox1Click этот параметр всеравно не используется } FileListBox1->ItemIndex--; FileListBox1Click(this); } } //----Размер под экран или истинный размер----------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) { static a=0; if(a==0){a=1; Image1->Align=alNone; Image1->Stretch=false; Image1->AutoSize = true;Button3->Caption="[]"; return; } a=0; Image1->Align=alClient; Image1->Stretch=true; Image1->AutoSize = false; Button3->Caption="]["; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <System.Classes.hpp> #include <Vcl.Controls.hpp> #include <Vcl.StdCtrls.hpp> #include <Vcl.Forms.hpp> #include <Vcl.Buttons.hpp> #include <Vcl.Dialogs.hpp> #include <Vcl.ExtCtrls.hpp> #include <Vcl.ExtDlgs.hpp> #include <Vcl.FileCtrl.hpp> #include <Vcl.Grids.hpp> #include <Vcl.Outline.hpp> #include <Vcl.Samples.DirOutln.hpp> //---------------------------------------------------------------------------- //--Для работы с соответствующими файлами #include <Vcl.Imaging.jpeg.hpp> #include <Vcl.Imaging.GIFImg.hpp> #include <Vcl.Imaging.pngimage.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TImage *Image1; TScrollBox *ScrollBox1; TDriveComboBox *DriveComboBox1; TDirectoryListBox *DirectoryListBox1; TFileListBox *FileListBox1; TPanel *Panel1; TPanel *Panel2; TSplitter *Splitter1; TPanel *Panel3; TSplitter *Splitter2; TPanel *Panel4; TLabel *Label1; TButton *Button1; TPanel *Panel5; TButton *Button2; TButton *Button3; TPanel *Panel6; void __fastcall FileListBox1Click(TObject *Sender); void __fastcall Button1Click(TObject *Sender); void __fastcall Button2Click(TObject *Sender); void __fastcall Button3Click(TObject *Sender); private: // User declarations public: // User declarations //--указатели на классы для создания объектов будим //--расширять функциональность //TJPEGImage *myjpg; //TGIFImage *mygif; //TPngImage *mypng; __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif | |
Просмотров: 3747 | Рейтинг: 0.0/0 |