Solved

Moving controls on a form at runtime

Posted on 1997-05-28
2
169 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 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

628 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