Solved

Moving controls on a form at runtime

Posted on 1997-05-28
2
150 Views
Last Modified: 2010-04-06
I want to write a program where the user can put any ordinary control on a form and move it. The problem is that any mouse / keyboard messages goes to the control and not to the form. I consulted the Lischner "Undocumented Delphi" but found no answer. Anybody any ideas ?
0
Comment
Question by:arnoldu
2 Comments
 

Author Comment

by:arnoldu
ID: 1336635
Edited text of question
0
 
LVL 1

Accepted Solution

by:
sleach earned 50 total points
ID: 1336636
Make a universal event handler/procedure that is common to all controls.  Then at the time you add the component, assing the handler to the event.  Example:
 
NewControl.OnMouseMove := MouseMove;

The Universal event handler can get/set top & left properties so as to move them to wherever you want on the form.  You could also use the OnMouseDown event if you rather.
Hope this helps.

{Example Procedure}
procedure TForm1.MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
Top, Left:  Integer;
begin
{Get top & Left positions of the control}
Top := (sender as TControl.top);
Left := (sender as TControl.left);

{Set Top & Left postions of the control}
(sender as TControl.top) := 10;
(sender as TControl.Left) := 5;
end;

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

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

743 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

14 Experts available now in Live!

Get 1:1 Help Now