Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Moving controls on a form at runtime

Posted on 1997-05-28
2
Medium Priority
?
170 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
[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
2 Comments
 

Author Comment

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

Accepted Solution

by:
sleach earned 150 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

661 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