A general MouseDown Event

Posted on 1998-11-02
Last Modified: 2010-04-06
In a program I'm working on I fugered out a way to make a personal Drage and Drop from scratch. I know that delphi handles D&D but I need more control. The program needs the pointer to pull around a form. but still offsetted from the pointers current postion by 10 X and Y. once that the mousedown event in the component that the user selects from is used and the pointer is draged around the component the form follows but as soon as the pointer leaves the area of the component the form stops. I could make all MouseDown event of the components point to the same code lines but I need it to cross over to another form. Ex. from Form1 to Form2. is there a way that a single MouseDown Event can handle this with out pointing all the other MouseDown events to the one Event?

willing to give points, so examples will be needed...

Question by:PPaul
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1345499
Do you mean you what to share an event among all the forms?

Author Comment

ID: 1345500
yes I guest... I need the one Procedure to handle forms, the screen, other components.  Just like the Drag & Drop handled by delhpi The pointer dosen't stop when it goes out the the starting component. The reason I need this it so that I can read what is under the pointer and still drage the form...

Example: 3 forms. 2 are shown all the time whill the program is runnung. when the user clicks on an Item in a listbox on form 1 and starts to drage it form 3 is poped up with a copy of the text and/or Icon in it. as the pointer is being drag accross from form 1 to form 2 it has to cross the desktop. The pointer still needs to drage form3 with it accross. Onec in the form 2 area form3 is still showing with the pointer.

I could get every Object MouseDown Event point to the same code but I was wondering if there is a way that this could be cut down to one event that is called with out any of the other objects MouseDown events being used....


Expert Comment

ID: 1345501
But I wonder why you think about mousedown? isn't what you want should be done in OnDragOver?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 1345502
eather way... (I tested it...) I would need to make all the components point to the same code.... I would like a way that would do that in one code without pointing all components to the one spot.  

Expert Comment

ID: 1345503
Well, on method I think is to capture the CM_Drag Message, but it is rather complex, I don't know whether it is valuable.

Expert Comment

ID: 1345504
Forget it.. it's not done this way! ..You should read about Message API handling routines instead.
1. You cannot share code directly between forms, because systems like windows NT runs applications in different memory environments.. (DDE could be a solution?)
2. You will have write specific OLE controls overriding the standard form methods, using drag'n'drop capabilities.. (search for on share-ware sites to see an example of Drag'n'drop from and to a form application)

Drag'n'drop is far more complex than a WM_MOUSE_DOWN event...

Author Comment

ID: 1345505
Ok then, is there a way in the drag and drop of delphi. to use the X,Y of the mouse during D&D. So that I can make a image move with the pointer????

Accepted Solution

endro earned 200 total points
ID: 1345506
This is one of the solutions (if this is what you meant).

Create a new procedure to handle the event

procedure handle_it(x,y : integer; ... other params);

Suppose you put this procedure to different unit (let's call it unit unHandle), call the unit in both forms, and on OnMouseDown event you can call the procedure.


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question