[fpc-pascal] FPC + GTK2 : Using variable into a Widget name ?

Vincent Snijders vsnijders at quicknet.nl
Fri Jan 4 14:34:13 CET 2008


tom at guilleminot.org schreef:
> Hi,
> 
> I use FPC with GTK2 and I have the following problem :
> In a loop with I'd like to be able to use the indice (incremented integer)
> on the name of widget to perform some actions.

Use an array.

> Here is an example :
> 
>   var
>     pFSImage01, pFSImage02, pFSImage03 : PGtkWidget;
>   ...

   var pFSImage : array[1..3] of PGtkWidget;

    For I:=1 to 3 do
    begin
         pFSImage[I] := gtk_image_new_from_file('./mypix.jpg');
   	gtk_fixed_put(pGTKFIXED(pFSFixed), pGTKWIDGET(pFSImage[I]) , 100*I, 20);
    	gtk_widget_show(pFSImage[I]);
    end;

Vincent



More information about the fpc-pascal mailing list