[Lazarus] Obtaining Control Address

SteveG steveg at nevets.com.au
Fri Jul 30 02:50:55 CEST 2010


SteveG wrote:
> Paul Ishenin wrote:
>> 30.07.2010 8:06, SteveG wrote:
>>> Would anybody know how to obtain the address of the following control?
>>>
>>> Arg1 := @Application.Components[0];
>>>
>>> This results in "Variable identifier expected" error
>>
>> A class instance is already a pointer.
>>
>> Arg1 := Application.Components[0] is enough.
> 
> Thanks Paul, something new every day :)
> 

I am trying to do the following, but the second assignment type is where 
I am having problems

NOTE - this is just an example, assuming that app.comp[0] is the one I 
want (which its not) - otherwise the first assign works ok

Suggestions much appreciated

procedure TForm1.Button1Click(Sender: TObject);
var str1	:string;
begin
   str1 := IntToStr( PtrInt( Button1 ) );                      // WORKS	
   str1 := IntToStr( PtrInt( Application.Components[0] ) );    // FAILS

   TButton( pointer(StrToIntDef(Trim( str1 ), 0)) ).Caption := 'OK';
end;







More information about the Lazarus mailing list