Board index » delphi » strange behavior when clicking on controls at design time

strange behavior when clicking on controls at design time

Hello
I have a form with a ListBox or ComboBox set just the way I like it. I click
it to hilight it, under edit, I select Copy.
I go to another form in my app, where i want the same control with the same
settings, so I simply Paste my control to the different form. I di this
several times, with each control individually copied from the source form
and pasted to the destination form, which needs several controls of the same
type with the aame settings.
I name each of the copied controls on my destination form differently and I
do not copy one control to another this way on the same form to avoid
creating pointers to controls like would happen in Visual Basic (I would
create an array of controls there).
Afterwards, when I double click on each of the placed controls in the
destination form, I am taken to the VERY SAME click event no matter what
control I click on, even though they all have different names. Delphi never
even 'generates' code for click events for the other controls, just takes me
to the same procedure for all of them.
What is going on here?
I looked in the property page and didn't see anything like an Index to an
array of controls like what would happen in Visual Basic.
And how do I fix this besides deleting all my controls and making each one
from scratch each time, having to repeat all the same settings?

Gino

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 

Re:strange behavior when clicking on controls at design time


Hello
I have more info on this behavior.
For example, if I copy a listbox or combobox from Form1 and paste it to
Form2 (making an indipendent copy with the same settings as the original is
what I want to do) where the control original on Form1 was named ListBox1,
so I have Form1.ListBox1...

I rename the control on Form2 to some conpletely different than the original
on Form1, NewList, for example, and double click on it. I get a procedure:

TForm2.ListBox1Click
...

even though there is NO control on Form2 with that name.
And this is AFTER I renamed all the controls. No matter how I rename it or
change things on them this always happens.

What the hell?

Thanks,

Gino

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Re:strange behavior when clicking on controls at design time


Quote
"Gino Costa" <gco...@beld.net> wrote in message

news:3bbbe308_2@corp.newsgroups.com...
-snip-
Quote
> Afterwards, when I double click on each of the placed controls in the
> destination form, I am taken to the VERY SAME click event no matter what
> control I click on, even though they all have different names. Delphi

never

Well - you copied all your controls from the same original control which
already had this event handler. Just go into the event property page, delete
the handler, and doubleclick the control again, this should give you a new
handler.

As for the array of controls (which normally gets thrown in your face when
you use vb - delphi has something similar, check out the Form.Controls
property or Application.Components property).

Finally - all when using delphi you are free to write your own code and
create real objects at runtime, the form designer is just a nice add-on it's
which auto-generates some code for you.

In other words - if you experience problems while using the form designer,
nine times out of ten these can easily be resolved by checking the source
code.

best of luck
Svein

Re:strange behavior when clicking on controls at design time


Well Gino,
this is not STRANGE BEHAVIOR, this is normal.
Why?
When you copy control (to keep all the settings), you also keep the events
associated with the control.
So, if the original control you are copying has the even OnClick pointing to
a procedure, all other controls will also have that event and will also
point to the same procedure.
To avoid this, DON'T make an event to the original control, copy it and
paste it as much times as you want, wherever you want, rename it or whatever
you want  to do. After that make events to controls.
Or, if you already copied controls, select control, goto Object Inspector,
tab Events, select Event you want and delete it (simply press DEL + ENTER).
That event will not point to any procedure anymore. Now doubleclick the
event and NEW procedure will be created.

Quote
"Gino Costa" <gco...@beld.net> wrote in message

news:3bbbe4e1$1_2@corp.newsgroups.com...
Quote
> Hello
> I have more info on this behavior.
> For example, if I copy a listbox or combobox from Form1 and paste it to
> Form2 (making an indipendent copy with the same settings as the original
is
> what I want to do) where the control original on Form1 was named ListBox1,
> so I have Form1.ListBox1...

> I rename the control on Form2 to some conpletely different than the
original
> on Form1, NewList, for example, and double click on it. I get a procedure:

> TForm2.ListBox1Click
> ...

> even though there is NO control on Form2 with that name.
> And this is AFTER I renamed all the controls. No matter how I rename it or
> change things on them this always happens.

> What the hell?

> Thanks,

> Gino

> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Re:strange behavior when clicking on controls at design time


You don't have to doubleclick in your propery editor to let Delphi generate
a name for you.
Just make shure that there is no procedure assigned with the event. (click
delete when the event is selected)
Then you could just write your procedure name and hit enter to open the
newly named procedure.

sorry, for not including original post..

Sven Tore

Other Threads