List Info

Thread: Re: Lost Name property of custom component #2




Re: Lost Name property of custom component #2
country flaguser name
Czech Republic
2007-08-17 16:14:21


Having dropped the control on a form (Unit1,Project1, just the control)
I let the IDE name it.

I get the following output:

ODS: Active is TImsCustomMaskEdit
ODS: Active Control Name:
ODS: Explicitly coded Name: ImsTestCtl1

I would hope to get:

ODS: Active is TImsTestCtl1
ODS: Active Control Name: ImsTestCtl1

(same as for say a TEdit control just dropped on the form)

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ActiveControl = ImsTestCtl1 then
OutputDebugString(PCHAR('Active is ImsTestCtl1'))
else
OutputDebugString(PCHAR('Active is '+ActiveControl.ClassName));

OutputDebugString(PCHAR('Active Control Name: '+ActiveControl.Name));
OutputDebugString(PCHAR('Explicitly coded Name: '+ImsTestCtl1.Name));

end;

> steward%40manscat.com">stewardmanscat.com wrote:
>> DELPHI 5
>>
>> PROBLEM
>> I have managed to lose the name property of my custom control?
>> IE:
>>
>> if ActiveControl=MyControl then
>;> print('This never gets executed even when ActiveControl is
>> MyControl');
>
> How do you know?
>
> How do you know that ActiveControl is MyControl if a conditional statement
> fails, indicating that ActiveControl *isn't* MyControl?
>
> Where are those two identifiers declared? (Ctrl+Click on them; don't
> assume you know where they're declared.) Where do they get assigned?
>
> Can you write a minimal program that reproduces the error, and then post
>; the code here?
>
>> print(ActiveControl.Name); // this is blank
>
> What do you expect it to print instead?
>
>;> The control derives from TCustomControl, and does not muck/change with
>;> any
>> name properties.
>
> If you're not changing the Name property, then it will always have its
> default empty value. It's the IDE that names your components when you drop
>; them in the designer. Merely creating an instance doesn't give it a name.
> The IDE-given names are restored when a form gets loaded.
>
> --
> Rob
>
>
>

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )