AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

OnMouseOver bei selbst erzeugtem TPicture

Ein Thema von tobi1701 · begonnen am 27. Okt 2005 · letzter Beitrag vom 10. Nov 2005
 
tobi1701

Registriert seit: 16. Okt 2005
30 Beiträge
 
#11

Re: OnMouseOver bei selbst erzeugtem TPicture

  Alt 27. Okt 2005, 18:42
ok, ich gebe einfach mal alles an:

Delphi-Quellcode:
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, GraphicEx, JPEG, Menus, ImgList, DXDraws,
  ComCtrls,Contnrs;

type
  pGameEntry = ^BasicGameEntry;
  BasicGameEntry = record
   Name,Genre,System,Publisher,Released: string;
   Description: TStrings;
   Rating: integer;
   Picture: Array[1..6] of TPicture;
  end;


TForm1 = class(TForm)
 PaintBox1:TPaintBox;
 PreviewBox:TPaintBox;
//[...]

 private

 public
    GameEntry: pGameEntry;
    GameList: tList;
    MainImageList: TObjectList;
 end;

var
  Form1: TForm1;

implementation

uses NewEntry;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Width:=1024;
  Height:=768;
  Color:=clCream;
  GameList:=TList.Create;
  PaintBox1.Canvas.Pen.Style:=psDot;
  PaintBox1.Left:=2;
  PaintBox1.Top:=100;;
  PaintBox1.Width:=604;
  PaintBox1.Height:=600;

  ScrollBox.Top:=PaintBox1.Top;
  ScrollBox.Left:=PaintBox1.Left+PaintBox1.Width+2;
  ScrollBox.Width:=15;
  ScrollBox.Height:=PaintBox1.Height;

  PreviewBox.Top:=PaintBox1.Top;
  PreviewBox.Left:=PaintBox1.Left+PaintBox1.Width+2+ScrollBox.Width+2;
  PreviewBox.Width:=370;
  PreviewBox.Height:=278;

  DXImageList1.Items.Add;
  DXImageList1.Items[0].Picture:=TPicture.Create;
  DXImageList1.Items[0].Picture.Bitmap.LoadFromFile('template_gp32x.bmp');
  DXImageList1.Items.Add;
  DXImageList1.Items[1].Picture:=TPicture.Create;
  DXImageList1.Items[1].Picture.Bitmap.LoadFromFile('blank120x90.bmp');
  DXImageList1.Items.Add;
  DXImageList1.Items[2].Picture:=TPicture.Create;
  DXImageList1.Items[2].Picture.Bitmap.LoadFromFile('scrollbar_gp32x.bmp');
  DXImageList1.Items.Add;
  DXImageList1.Items[3].Picture:=TPicture.Create;
  DXImageList1.Items[3].Picture.Bitmap.LoadFromFile('scrollup_gp32x.bmp');
  DXImageList1.Items.Add;
  DXImageList1.Items[4].Picture:=TPicture.Create;
  DXImageList1.Items[4].Picture.Bitmap.LoadFromFile('scrolldown_gp32x.bmp');
  DXImageList1.Items.Add;
  DXImageList1.Items[5].Picture:=TPicture.Create;
  DXImageList1.Items[5].Picture.Bitmap.LoadFromFile('scrollCursor_gp32x.bmp');

  new(GameEntry);
  GameEntry^.Name:='Test Name 1';
  GameEntry^.Genre:='Platformer';
  GameEntry^.Released:='1992';
  GameEntry^.Publisher:='Konami';
  GameEntry^.Rating:=80;
  GameEntry^.Picture[1]:=TPicture.Create;
  GameEntry^.Picture[1].Assign(DXImageList1.Items[1].Picture);
  GameEntry^.Picture[2]:=TPicture.Create;
  GameEntry^.Picture[2].Assign(DXImageList1.Items[1].Picture);
  GameList.Add(GameEntry);

end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  UpdateLayout;
  UpdateList;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  MenuBox.Width:=Form1.Width-15;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  UpdateLayout;
end;

procedure TForm1.DrawEntry(y:integer;Entry:pGameEntry);
var
        Rect: TRect;

begin
  PaintBox1.Canvas.Brush.Color:=clWhite;
  PaintBox1.Canvas.Draw(2,y+2,DXImageList1.Items[0].Picture.Bitmap);

  PaintBox1.Canvas.Brush.Style:=bsClear;
  PaintBox1.Canvas.Font.Size:=8;
  PaintBox1.Canvas.Font.Style:=[fsBold];
  // Outline Color
  PaintBox1.Canvas.Font.Color:=clSilver;
  PaintBox1.Canvas.TextOut(6-1,y+6-1,Entry.Name);
  PaintBox1.Canvas.TextOut(6+1,y+6-1,Entry.Name);
  PaintBox1.Canvas.TextOut(6-1,y+6+1,Entry.Name);
  PaintBox1.Canvas.TextOut(6+1,y+6+1,Entry.Name);
  // Inner Color
  PaintBox1.Canvas.Font.Color:=clBlack;
  PaintBox1.Canvas.TextOut(6,y+6,Entry.Name);

  PaintBox1.Canvas.Font.Size:=6;
  PaintBox1.Canvas.Font.Style:=[];
  PaintBox1.Canvas.Font.Color:=clBlack;
  PaintBox1.Canvas.TextOut(6,y+40,'Genre:');
  PaintBox1.Canvas.TextOut(60,y+40,Entry.Genre);
  PaintBox1.Canvas.TextOut(6,y+55,'Released:');
  PaintBox1.Canvas.TextOut(60,y+55,Entry.Released);
  PaintBox1.Canvas.TextOut(6,y+70,'Publisher:');
  PaintBox1.Canvas.TextOut(60,y+70,Entry.Publisher);
  PaintBox1.Canvas.TextOut(6,y+85,'Rating:');
  PaintBox1.Canvas.TextOut(60,y+85,IntToStr(Entry.Rating)+'%');
  Rect.Left:=(50)+220;
  Rect.Top:=(y+10);
  Rect.Right:=Rect.Left+120;
  Rect.Bottom:=Rect.Top+90;
  if (Entry.Picture[1].Graphic<>nil) then PaintBox1.Canvas.StretchDraw(Rect,Entry.Picture[1].Graphic)
  else PaintBox1.Canvas.StretchDraw(Rect,DXImageList1.Items[1].Picture.Bitmap);
  Rect.Left:=(190)+220;
  Rect.Top:=(y+10);
  Rect.Right:=Rect.Left+120;
  Rect.Bottom:=Rect.Top+90;
  if (Entry.Picture[2].Graphic<>nil) then PaintBox1.Canvas.StretchDraw(Rect,Entry.Picture[2].Graphic)
  else PaintBox1.Canvas.StretchDraw(Rect,DXImageList1.Items[1].Picture.Bitmap);
end;

procedure TForm1.UpdateList;
var i: integer;

begin
  if GameList.Count>0 then begin
  for i:=0 to (GameList.Count-1) do begin
    GameEntry:=GameList.Items[i];
    DrawEntry(i*101,GameEntry);
  end;
  end;
end;

procedure TForm1.UpdateLayout;
var
        Rect: TRect;

begin
  Rect.Top:=0;
  Rect.Left:=0;
  Rect.Bottom:=MenuBox.Height;
  Rect.Right:=MenuBox.Width;
  MenuBox.Canvas.Brush.Color:=clWhite;
  MenuBox.Canvas.FillRect(Rect);
  MenuBox.Canvas.Brush.Color:=clBlack;
  MenuBox.Canvas.FrameRect(Rect);

  Rect.Top:=0;
  Rect.Left:=0;
  Rect.Bottom:=ScrollBox.Height;
  Rect.Right:=ScrollBox.Width;
  ScrollBox.Canvas.Brush.Color:=clWhite;
  ScrollBox.Canvas.FillRect(Rect);
  ScrollBox.Canvas.Brush.Color:=clBlack;
  ScrollBox.Canvas.FrameRect(Rect);
  Rect.Top:=Rect.Top+14;
  Rect.Bottom:=Rect.Bottom-14;
  Rect.Left:=Rect.Left+1;
  Rect.Right:=Rect.Right-1;
  ScrollBox.Canvas.StretchDraw(Rect,DXImageList1.Items[2].Picture.Bitmap);
  ScrollBox.Canvas.Draw(1,1,DXImageList1.Items[3].Picture.Bitmap);
  ScrollBox.Canvas.Draw(1,ScrollBox.Height-14,DXImageList1.Items[4].Picture.Bitmap);

  Rect.Top:=0;
  Rect.Left:=0;
  Rect.Bottom:=PreviewBox.Height;
  Rect.Right:=PreviewBox.Width;
  PreviewBox.Canvas.Brush.Color:=clWhite;
  PreviewBox.Canvas.FillRect(Rect);
  PreviewBox.Canvas.Brush.Color:=clBlack;
  PreviewBox.Canvas.FrameRect(Rect);

  Rect.Top:=0;
  Rect.Left:=0;
  Rect.Bottom:=PaintBox1.Height;
  Rect.Right:=PaintBox1.Width;
  PaintBox1.Canvas.Brush.Color:=clWhite;
  PaintBox1.Canvas.FillRect(Rect);
  PaintBox1.Canvas.Brush.Color:=clBlack;
  PaintBox1.Canvas.FrameRect(Rect);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
        i,Code:integer;

begin
  Form2.Image1.Picture:=nil;
  Form2.Image2.Picture:=nil;
  if Form2.ShowModal=mrOK then begin
    new(Form1.GameEntry);
    GameEntry^.Name:=Form2.Edit1.Text;
    GameEntry^.Genre:=Form2.ComboBox1.Text;
    GameEntry^.Publisher:=Form2.Edit2.Text;
    GameEntry^.Released:=Form2.Edit3.Text;
    val(Form2.Edit4.Text,i,Code);
    if Code<>0 then i:=0;
    GameEntry^.Rating:=i;
    //GameEntry^.System:=Form2.ComboBox2.Text;
    GameEntry^.Picture[1]:=TPicture.Create;
    GameEntry^.Picture[1].Assign(Form2.Image1.Picture);
    GameEntry^.Picture[2]:=TPicture.Create;
    GameEntry^.Picture[2].Assign(Form2.Image2.Picture);
    GameList.Add(GameEntry);
    UpdateList;
  end;
end;


end.
so. wie beschrieben werden die einträge der der liste mit DrawEntry in die PaintBox1 gemalt und in einem Eintrag werden 2 Images mit der grösse 120x90 gemalt.
und wenn ich über genau eines dieser 120x90 images mit der maus gehe, soll das glaiche Image (über dem sich der cursor befindet) in die PreviewBox gemalt werden.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:00 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz