Board index » delphi » Run-Time created controls...

Run-Time created controls...

Hi,

I've created some TEdit and TLabel controls on my mainform at run-time, then I
want to assign specific values to specific properties, for instance:
I've made a control call Control1 which is a TEdit object, then I want to put
some text in the text property, and then I want to make whatever happen on the
event OnMouseMove. How do I do this? I know I can assign the text when I
create the Control but I want to do this much later.

I know there are a lot of good programmers out there, so I think there's a lot
of you who know how to do this, so please, drop me a line or two...

Regards,

Timmy Lind, LM Ericsson Data AB

 

Re:Run-Time created controls...


Tjenna Timmy!

Quote
>I've created some TEdit and TLabel controls on my mainform at run-time, then I
>want to assign specific values to specific properties, for instance:
>I've made a control call Control1 which is a TEdit object, then I want to put
>some text in the text property, and then I want to make whatever happen on the
>event OnMouseMove. How do I do this? I know I can assign the text when I
>create the Control but I want to do this much later.

I'm not sure I understand your question.  Once you have created the control, you
can manipulate it in the same way you would manipulate one created at design
time.  You need to be sure to set the Parent property, but other than that it is
all very straight forward.

--
Clayton Neff
Software Project Leader
The Personal Marketing Company, Inc.
11843 West 83rd Terrace
Lenexa, KS  66214
(913)492-0322
clay...@tpmco.com

Re:Run-Time created controls...


I think you are asking :-

How do I allocate an OnMouseMove event to my created TEdit

If this is so then
Write a procedure (which has the same parameters as the normal OnMouseMove
event procedure) which does what you wnat.
Then when you want to couple it to the created TEdit, put

MyEditBox.OnMouseMove := MyEventProcedure;

When you want to Un-couple your event procedure put

MyEdit.OnMouseMove := '';

Delphi is simpler than you think <g>

AlanGLl...@aol.com

Re:Run-Time created controls...


On 20 Aug 1997 06:19:57 GMT, alangll...@aol.com (AlanGLLoyd) wrote:

Quote
>I think you are asking :-

>How do I allocate an OnMouseMove event to my created TEdit

>If this is so then
>Write a procedure (which has the same parameters as the normal OnMouseMove
>event procedure) which does what you wnat.
>Then when you want to couple it to the created TEdit, put

>MyEditBox.OnMouseMove := MyEventProcedure;

>When you want to Un-couple your event procedure put

>MyEdit.OnMouseMove := '';

>Delphi is simpler than you think <g>

>AlanGLl...@aol.com

Actually, the OnMouseMove or most of the handlers are of type
TNotifyEvent and setting it to an empty string just won't compile; you
must set it to nil.

Re:Run-Time created controls...


The following should show you how to do that:

// Add the following procedure to handle the OnMouseMove event
// Note that the params are correct for an OnMouseMove event
// and be sure to add this procedure to your form's class definition
procedure TMainForm.MyMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
begin
  MyLabel.Caption := 'You have moved the mouse over me';
end;

procedure TMainForm.Button1Click(Sender: TObject);
begin
  // create the label
  MyLabel := TLabel.Create(MainForm);
  // set some properties
  MyLabel.Parent := SDIappForm;
  MyLabel.Autosize := true;
  MyLabel.Caption := 'I am a dynamic label';
  MyLabel.Top := 150;
  MyLabel.Left := 150;
  // and set the procedure that is to handle the OnMouseMove event
  MyLabel.OnMouseMove := MyMouseMove;
end;

On Tue, 19 Aug 97 08:57:16 GMT, timmy.l...@edt.ericsson.se (Timmy

Quote
Lind) wrote:
>Hi,

>I've created some TEdit and TLabel controls on my mainform at run-time, then I
>want to assign specific values to specific properties, for instance:
>I've made a control call Control1 which is a TEdit object, then I want to put
>some text in the text property, and then I want to make whatever happen on the
>event OnMouseMove. How do I do this? I know I can assign the text when I
>create the Control but I want to do this much later.

>I know there are a lot of good programmers out there, so I think there's a lot
>of you who know how to do this, so please, drop me a line or two...

>Regards,

>Timmy Lind, LM Ericsson Data AB

__________________________________________________
?????????????????????????

Nick Roux
Johannesburg, South Africa

HTTP://www.geocities.com/SiliconValley/Lakes/9011/

mailto:Roux_N...@Lilly.Com
spamto postmaster@[127.0.0.1]
__________________________________________________
?????????????????????????

Other Threads