

Kevin60
Members-
Content Count
8 -
Joined
-
Last visited
Everything posted by Kevin60
-
I have managed to write a program which demonstrates the methods outlined in parts 1&2. I created an image component with the ability to move built in. The program appears to work perfectly and gives the end user the impression that they are dragging and dropping the image. As you can see its pretty basic but surprisingly simple. I hope that this solution addresses the problem and could be adapted and improved. The main program is included as an attachment to this post. It also includes the code necessary to create the Angord component. Unit1.pas
-
Dragging and Dropping of Images Part 3 The program
Kevin60 replied to Kevin60's topic in General Help
The file I uploaded is not one program. It contains 2 separate listings which I put together for convenience. This maybe causing the confusion because the program does not create the component at the same time. You create the component separately then use it in the program. As I stated in a previous post the program works as written in Delphi 7. The program is not a fully polished one as it was written to give people a basic idea of the principle of using the PtinRect function. Incidentally I have been programming in Delphi for nearly 30 years. Kevin60 -
A simple Code Editor trick to quickly copy an entire procedure/function to the clipboard
Kevin60 replied to PeterPanettone's topic in General Help
Hi Peter, Thanks for the tip, I wish that Borland/Embarcadero could have included all tips regarding the editor and Delphi in general. Pleas could we have more tips like this. Maybe we could compile enough tips from Delphi praxis members into a pdf. Kevin60 -
Dragging and Dropping of Images Part 3 The program
Kevin60 replied to Kevin60's topic in General Help
Hi Limelect, In order to see an image in the component you have to load an image into the picture property at Design time. When the program is running you should see the picture you inserted. The Angord component is based on a TImage component which contains a picture property as standard. Hopefully this explanation will deal with your enquiry. Thanks Kevin60 -
Dragging and Dropping of Images Part 3 The program
Kevin60 replied to Kevin60's topic in General Help
Hi Limelect If you mean the image whilst moving yes. You are moving a component and so the picture is visible until you change the visible property of the component. Hopefully this is the image you are referring to? Kevin60 -
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.
-
I may be passing on old news, if not then I have found out how to successfully drag and drop images in Delphi. You do not use the existing commands concerned with drag and drop they are only used to move text from one text control to another or drag items from windows explorer. You use the PTinRect command and program a response to the outcome. The command checks if the top left corner of a control falls inside the boundary rectangle of another control. If it does then you can identify the name of the control underneath and perform an appropriate action. You have to create your own methods depending on the outcome but this is very easy basically IF..THEN commands. It works for any control and as I discovered is the standard method used by software companies to drag and drop images. Borland/Embarcadero never told us about this. I hope this has been helpful?
-
Hi Patrick Thank you for your reply I have returned to programming after a long absence. I only have Delphi 7 and perhaps should have stated this in the post. Thanks for the information about Fire monkey. Kevin Jackson