Veo un detalle:
Código Delphi
[-]
with NewBoton do
begin
case ventana_actual of
1: begin
NewBoton := TLabel.create(FPrincipal.GroupBoxProd1);
Parent := FPrincipal.GroupBoxProd1;
....
scontador:= IntToStr (contador);
nombre:= 'Boton';
Name := nombre+scontador;
end;
No veo lógico que uses el
With NewBoton do y acto seguido modifiques el valor porque creas un Tlabel nuevo.
Sugiero que muevas la frase
With NewBoton do más abajo:
Código Delphi
[-]
case ventana_actual of
1: begin
NewBoton := TLabel.create(FPrincipal.GroupBoxProd1);
Parent := FPrincipal.GroupBoxProd1;
end;
2: begin
NewBoton := TLabel.create(FPrincipal.GroupBoxProd2);
Parent := FPrincipal.GroupBoxProd2;
end;
3: begin
NewBoton := TLabel.create(FPrincipal.GroupBoxProd3);
Parent := FPrincipal.GroupBoxProd3;
end;
4: begin
NewBoton := TLabel.create(FPrincipal.GroupBoxProd4);
Parent := FPrincipal.GroupBoxProd4;
end;
end;
with NewBoton do
begin
scontador:= IntToStr (contador);
nombre:= 'Boton';
Name := nombre+scontador;
Color:= clMoneyGreen;
Width := ancho_boton;
Height := alto_boton;
Left := margen_izq;
Autosize := false;
Top := margen_sup;
Caption := varCaption;
if soyingrediente <>1 then
OnClick := mostrar_productos
else
OnClick := mostrar_productos;
margen_izq_ant := margen_izq;
margen_sup_ant := margen_sup;
end;
Por otra parte, cuando creas los labels, le dices que tiene un dueño, y realmente lo vas a destruir tú, pasale un "nil" mejor.
Saludos.