Autor Beitrag
comes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: Sa 07.12.02 22:28 
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    Bild: array of TImage;
    mouseStart : TPoint;
    mouseDown : Boolean;
    procedure erstellebild(bildname:string;mainimage : Timage; posx, posy : integer; hoehe,breite : integer);
    public
    { Public declarations }
  end;

var
  Form1: TForm1;
  bildmenge : integer = 1;
  image : Timage;
implementation

{$R *.DFM}

// OnClick handler
procedure TForm1.erstellebild(bildname:String;mainimage : TImage; posx, posy : integer; hoehe,breite : integer);
begin
  image := mainimage;
  image := Timage.Create(Self);
  image.Parent := Self;   // Set its parent (Form1)
  image.Name := bildname;
  image.Picture.Bitmap.LoadFromFile('comes.bmp');
  image.SetBounds(posx, posy, hoehe, breite);
  bildmenge := bildmenge + 1;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  DoubleBuffered:=True;
  setlength(bild, bildmenge);
  erstellebild('a'+inttostr(bildmenge),bild[bildmenge],10+(bildmenge*10),10+(bildmenge*10),100,100);
end;

end.





---------
wie man dem code entnehmen wird hier ein image aus einer array erstellt. also beliebig viele image. ich möchte nun noch einbauen, dass ich jedes bild anklicken kann und mir dann gesagt wird, welches bild das ist bzw. möchte ich die bilder noch verschieben können.

bitte ne antwort
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: So 08.12.02 00:23 
//Edit

Upss. Das ist TImage. Meine Beschreibung bezog sich auf TBitmap.

Sorry.
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: So 08.12.02 02:16 
Such nach Tipps wie man Objekte verschieben kann.
comes Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: So 08.12.02 20:21 
Titel: TImage
Naja, objekte erstellen ganz gut und schön, aber 1. müssen die objekte zur laufzeit erstellt werden, was ja nicht das prob ist, aber die objecte entsprechen in ihrer bezeichnung einem array und dazu möchte ich ne procedure onklick oder onmove machen. für jedes object dieser Array einzeln. ABER WIE?
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: So 08.12.02 21:25 
Was ist jetzt das spezielle Problem? Verabschiede dich von der Vorstellung, daß eine Objektvariable nur eine Variable ist. Es ist eine Menge von Variablen. Dashalb muß du alles für jede Variable wiederholen.

Und die andere Sache kann man so machen:

Image1.OnClick := Image1Click;
comes Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: So 08.12.02 22:10 
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    Bild: array of TImage;
    mouseStart : TPoint;
    mouseDown : Boolean;
    procedure erstellebild(bildname:string;mainimage : Timage; posx, posy : integer; hoehe,breite : integer);

    procedure MoveControl(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure clickControl(Sender: TObject);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  bildmenge : integer = 1;
  image : Timage;
implementation

{$R *.DFM}
procedure TForm1.MoveControl(Sender:TObject; Button:TMouseButton;
          Shift:TShiftState; X,Y:Integer);
var
  TempPanel: TPanel;
  Control: TControl;
begin
  // Releases the mouse capture from a window
  ReleaseCapture;
  // If the component is a TWinControl, move it directly
  if Sender is TWinControl then
    TWinControl(Sender).Perform(WM_SYSCOMMAND,$F012,0)
  else
  try
    Control := TControl(Sender);
    TempPanel := TPanel.Create(Self);
    with TempPanel do
    begin
      //Replace the component with TempPanel
      Caption := '';
      BevelOuter := bvNone;
      color := clFuchsia;
      SetBounds(Control.Left, Control.Top, Control.Width, Control.Height);
      Parent := Control.Parent;
      //Put our control in TempPanel
      Control.Parent := TempPanel;
      //Move TempPanel with control inside it
      Perform(WM_SYSCOMMAND, $F012, 0);
      //Put the component where the panel was dropped
      Control.Parent := Parent;
      Control.Left := Left;
      Control.Top := Top;
    end;
  finally
    TempPanel.Free;
  end;
end;


procedure TForm1.clickControl(Sender: TObject);
begin
  ShowMessage(TImage(Sender).Name);
end;
// OnClick handler
procedure TForm1.erstellebild(bildname:String;mainimage : TImage; posx, posy : integer; hoehe,breite : integer);
begin
  image := mainimage;
  image := Timage.Create(Self);
  image.Parent := Self;   // Set its parent (Form1)
  image.Name := bildname;
  image.Picture.Bitmap.LoadFromFile('comes.bmp');
  image.SetBounds(posx, posy, hoehe, breite);
  image.OnDblClick := clickcontrol;
  image.OnMouseDown := MoveControl;
  bildmenge := bildmenge + 1;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  //DoubleBuffered:=True;
  setlength(bild, bildmenge);
  erstellebild('a'+inttostr(bildmenge),bild[bildmenge],10+(bildmenge*10),10+(bildmenge*10),100,100);
end;

end.


habs selber gelöst. guckts euch an, dann wißt ihr, was ich meinte