Robie edytor grafiki (kazdy element na rysunku to jeden obiekt w tablicy). Nie moge zrobic zmieniania pozycji obiektu - nie wiem co jest grane niby dziala ale czesto obiekt przyjmuje X=0 i Y=0.
(pomine tu procedure do przerysowania tablicy)
type
TImageEl = record
Bmp: Tbitmap;
left, top, width, height: integer;
Focus: boolean;
end;
var
ImageEl : array of TImageEl;
md : boolean;
dxy : tpoint;
procedure TForm1.SpaceMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
i, j, k : integer;
r : trect;
begin
for i := length(imageel) - 1 downto 0 do
begin
r := rect(imageel[i].left, imageel[i].top, imageel[i].left +
imageel[i].width, imageel[i].height + imageel[i].top);
if (r.left <= x) and (r.top <= y) and (r.Right >= x) and (r.Bottom >= y)
then
begin
if (md) and (imageel[i].focus) then
begin
imageel[i].left := x-dxy.x; //tu jest problem Mysza X - Start X :)
imageel[i].top := y - dxy.y; //tu jest problem
end;
break;
end;
end;
paint; //odrysuj
end;
procedure TForm1.SpaceMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i, k : integer;
r : trect;
begin
for i := length(imageel) - 1 downto 0 do
begin
r := rect(imageel[i].left, imageel[i].top, imageel[i].left +
imageel[i].width, imageel[i].height + imageel[i].top);
if (r.left <= x) and (r.top <= y) and (r.Right >= x) and (r.Bottom >= y)
then
begin
imageel[i].focus := true; //ustaw focusa
if imageel[i].focus then
begin
md := true;
dxy := point(x, y);
break;
end;
end
else
begin
for k := 0 to length(imageel) - 1 do
imageel[k].focus := false; //klikniecie nie w obiekty
md := false;
end;
end;
end;
procedure TForm1.SpaceMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
md := false;
end;
Moze ktos mial podobny problem i jest w stanie pomoc ?:)</delphi>