Solved

TScreen.ScreenDragOver ?

Posted on 1997-04-04
8
166 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
Independent Software Vendors: 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

Technology Partners: 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
error 1.1 400 Bad request idhttp delphi 18 277
Printing problem 2 124
Error E2158 compiling with Delphi XE10 Seattle 2 141
Dev express lookupcombo 3 64
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…

739 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