Solved

TScreen.ScreenDragOver ?

Posted on 1997-04-04
8
167 Views
Last Modified: 2010-04-06
Want to do something during draging but don't want to put the code into the OnDragOver events of all the controls (too many) in a form and the form itself.

Can you find or make an event or similar:
  TScreen.ScreenDragOver (....X, Y: Integer..)
so that one may
1. do something based on the coordinates of the cursor in anywhere of the form during the draging;
2. stop doing that when this draging finished.
0
Comment
Question by:zhuhail
[X]
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
  • 5
  • 3
8 Comments
 

Author Comment

by:zhuhail
ID: 1335156
Edited text of question
0
 

Author Comment

by:zhuhail
ID: 1335157
Edited text of question
0
 

Accepted Solution

by:
zodik earned 80 total points
ID: 1335158
You can create one OnDragOver proc, assign it to all the components of the form, and make the processing based
on source component, or call  GetCursorPos and use X,Y coordinates.

General idea is that you can assign ONE event proc to multiple events.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:zhuhail
ID: 1335160
Hi again,

I just think what you suggested was sharing one event by all
the controls in the form. That will be fine.

However, in my case there are many controls ....I don't want
to connect all the controls to the event by hand in design
time: I may miss one or two controls and, especially, when
add a new control later I may forget to do this:-)

Is this possible to put the OnDragOver event into a new
component and all the controls in the form and the form
itself can be automatically connected with it as long as
the new component is put to the form in design time?  

Cheers.
0
 

Author Comment

by:zhuhail
ID: 1335161
sure, no problem. just do something like this :


  for I:= 0 to Form1.ControlCount -1 do
     Form1.Controls[I].OnDragOver := TForm1.FormDragOver;

0
 

Expert Comment

by:zodik
ID: 1335162
Hi,

That is great.

I have tried put your code into the OnCreate event of the
form, but got error message:
   Undeclared identifier: 'OnDragOver'
Anything wrong I did?

Cheers.
0
 

Author Comment

by:zhuhail
ID: 1335163
sorry, my mistake. OnDragOver is declared protected in TControl,
so you can not change it.
if you know the type of components in advance, you can do something like this:
for I:= 0 to Form1.ControlCount -1 do
   if (Controls[I] is TEdit) then
      (Controls[I] as TEdit).OnDragOver := FormDragOver;

if not, you can select "view as text" and paste 'OnDragOver  = FormDragOver' in each component (easier the selecting in object inspector).
0
 

Expert Comment

by:zodik
ID: 1335164
Create a component

TControlHack = class(TControl)
public
  property OnDragOver;
end;


Then use zodiks solution, but change it to

TControlHack(Form1.Controls[I]).OnDragOver := TForm1.FormDragOver

This should work.

Regards,

Erik.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month6 days, 9 hours left to enroll

634 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