Solved

TScreen.ScreenDragOver ?

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

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now