Jump to content
Sign in to follow this  
Kevin60

Dragging and Dropping of Images part 2

Recommended Posts

In order to move an image in Delphi 7  you do the following.

1. Program movement of image relative to the mouse.

2. Within a loop check if the image being moved overlaps an image on screen.  You check each control in the componentlist and by using the PtinRect function determine if it returns a true value.  If it is true then you can retrieve the name of the component underneath and thus interact with it.

3. If the function returns a true value then within the code that checks for this you write code to check if particular criteria is met.  You simply use the mouse events in conjunction with the PtinRect value to determine what to do with the image/images if the criteria is met.  For instance you could check if the values of a shared property in both images when added together come to a certain value i.e scoring a hand of cards.  You could then write simple code to either overwrite an image or swap the images over.  If the criteria is not met you write code to return the moved image back to its original starting position.

 

The terms Drag and Drop are misleading in this case.  Think of it as Move and Release.  Remember you do not use any Drag and Drop functions, procedures and commands.

 

I hope this explains the procedure/s required.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×