Board index » delphi » moving a 2d image across background

moving a 2d image across background

I want to move a 2d image across a background. covering up the background and
restoring it as it moves on.  This is the same kind of thing you would do when
moving the cursor across the screen.

If there a set of logical operatios i.e. that can accomplish this or does one
have to save the background and restore it as the top image moves on.

thanks...

 

Re:moving a 2d image across background


In article <19981207201258.26358.00001...@ng-fc1.aol.com>, elliott...@aol.com

Quote
(Elliott712) writes:
>I want to move a 2d image across a background. covering up the background and
>restoring it as it moves on.  This is the same kind of thing you would do
>when
>moving the cursor across the screen.

>If there a set of logical operatios i.e. that can accomplish this or does one
>have to save the background and restore it as the top image moves on.

>thanks...

Place a TImage on the form, put a picture in it and the following code.

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if ssLeft in shift then begin
//sends a message to the form that the left mouse button is down
//otherwise only the TImage will know about it
sendMessage(handle,WM_LBUTTONDOWN,MK_LBUTTON,0);
//calc the relative co-ordinates (middle of image)
Image1.Top:=  y + Image1.Top - (Image1.Height div 2);
Image1.Left:= x + Image1.Left - (Image1.Height div 2);
end;
end;

It works but no guarantees. <g>

hth

Gordon.

http://members.aol.com/gwhit41980/

Other Threads