Solved

TScreen.ScreenDragOver ?

Posted on 1997-04-04
8
163 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
  • 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
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

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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dev Express grid collapse 2 47
Press three keys together and trigger a function 3 67
Error E2158 compiling with Delphi XE10 Seattle 2 123
MS Access from Delphi 31 77
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

679 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