Недавно добавленные исходники

•  Animation Loaders  807

•  DeLiKaTeS Tetris (Тетрис)  5 773

•  TDictionary Custom Sort  7 729

•  Fast Watermark Sources  7 408

•  3D Designer  10 630

•  Sik Screen Capture  7 944

•  Patch Maker  8 162

•  Айболит (remote control)  8 212

•  ListBox Drag & Drop  7 018

•  Доска для игры Реверси  100 390

•  Графические эффекты  8 286

•  Рисование по маске  7 661

•  Перетаскивание изображений  6 267

•  Canvas Drawing  6 641

•  Рисование Луны  6 564

•  Поворот изображения  5 721

•  Рисование стержней  4 660

•  Paint on Shape  3 362

•  Генератор кроссвордов  4 331

•  Головоломка Paletto  3 489

•  Теорема Монжа об окружностях  4 304

•  Пазл Numbrix  2 783

•  Заборы и коммивояжеры  3 711

•  Игра HIP  2 503

•  Игра Go (Го)  2 495

•  Симулятор лифта  2 890

•  Программа укладки плитки  2 323

•  Генератор лабиринта  3 049

•  Проверка числового ввода  2 554

•  HEX View  2 958

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Рисование картинок в TListBox



Оформил: DeeCo

{ Create a TImage on your Formular and assign a bitmap }
 { Create a TListbox on your Formular }

 type
   TForm1 = class(TForm)
     ListBox1: TListBox;
     Image1: TImage;
     procedure FormCreate(Sender: TObject);
     procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
       Rect: TRect; State: TOwnerDrawState);
     procedure ListBox1MeasureItem(Control: TWinControl; Index: Integer;
       var Height: Integer);
   private
     {...}
   public
     {...}
   end;

 procedure TForm1.FormCreate(Sender: TObject);
 begin
   with ListBox1.Items do
   begin
     Clear;
     ListBox1.Style := lbOwnerDrawVariable;
     AddObject('Bitmap1', Image1.Picture.Bitmap);
     AddObject('Bitmap2', Image2.Picture.Bitmap);
     AddObject('Bitmap3', Image3.Picture.Bitmap);
   end;
 end;

 procedure CenterText(Cnv: TCanvas; Rect: TRect; S: string);
 var
    X, Y: Integer;
 begin
   X := (Rect.Right + Rect.Left - Cnv.TextWidth(S)) div 2;
   Y := (Rect.Bottom + Rect.Top - Cnv.TextHeight(S)) div 2;
   Cnv.TextOut(X, Y, S);
 end;

 procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
   Rect: TRect; State: TOwnerDrawState);
 var
    Bitmap: TBitmap;
 begin
   with ListBox1 do
   begin
     Canvas.FillRect(Rect);
     if Items.Objects[Index] <> nil then
     begin
       Bitmap := Items.Objects[Index] as TBitmap;
       Canvas.BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2,
         Bitmap.Width, Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width,
         Bitmap.Height), Bitmap.Canvas.Pixels[0, Bitmap.Height - 1]);
     end;
     Rect.Left   := Rect.Left + Bitmap.Width + 4;
     Rect.Bottom := Rect.Top + Bitmap.Height + 4;
     CenterText(Canvas, Rect, Items.Strings[Index]);
   end;
 end;

 procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
   var Height: Integer);
 begin
   if Index = 0 then Height := Image1.Height + 4;
 end;




Похожие по теме исходники

Рисование кривой звука

Рисование математических формул

Рисование компаса

Рисование стержней

 

Рисование Луны

Рисование по маске




Copyright © 2004-2026 "Delphi Sources" by «SiteAnalyzer». Delphi World FAQ

Группа ВКонтакте