Quote:
| Originally Posted by majlumbo I haven't tried this but possibly if you put the image component on a panel (set the image align property to alclient) then move the panel via the same logic as you did for the image. |
I tried the Tpanel suggestion and it worked ! Thanks! I will
have to recode parts of my application to reference tpanel
but it should work. I really never thought about this behavior
until after i had wrote code involving the images.
For anyone following this thread the solution for moving of the image object was tweaked on by majlumba(kudos

).
In most code you find for moving controls the process makes
use of a handle to move the object. I knew i could not use a
handle for an image as it has none. So i implemented a procedure
that just moved the object with x and y from the mousemove
(as i stated in question) It did not dawn on me until majlumbos idea about the panel that using a handle was possible if the image is embedded in a control such as a panel. I went back and placed my image on a panel then the "normal" code used to move objects could be used to move the panel with the image.
Summary:
{code in TPanel was derived from this
as a new memeber i can not paste url so here is code
it uses a button and a radio group to toggle drag on and off
in my case the button code was used as the panel code}
private
{ Private declarations }
public
{ Public declarations }
OldPos: TPoint;
end;
//****************
type
TForm1 = class(TForm)
...
private
{ Private declarations }
Dragged: Boolean;
OldPos: TPoint;
...
procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if RadioGroup1.ItemIndex=0 then
begin
Dragged:=True;
GetCursorPos(OldPos);
SetCapture(Button1.Handle);
end;
end;
procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
NewPos: TPoint;
begin
if Dragged then
with Button1 do
begin
GetCursorPos(NewPos);
Left:=Left-OldPos.X+NewPos.X;
Top:=Top-OldPos.Y+NewPos.Y;
OldPos:=NewPos;
end;
end;
procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Dragged then
begin
ReleaseCapture;
Dragged:=False;
end;
end;
//******************
Paste image on panel
set panel properties:
border :none
height := image.height
width := image.width
image properties:
align = none
left = 0
top = 0
assign the MouseDown,MouseMove,MouseUp events
of the TIMAGE to use the corresponding events of
the Tpanel(that actually has the code).
Set Doublebuffering := true in form create to reduce flickering.
Thanks again majlumbo !