Fórum Dúvida componente Shape, Delhpi 10 #576955

14/03/2017

0

Bem estou com um problema eu estou fazendo um alternância de figuras geométricas, só q eu quero q depois q aparecer uma figura o programa fique com o formulário em branco por exemplo apareça um quadrado vermelho, depois n apareceça nada na tela e depois apareça um quadrado azul. Não estou conseguindo esse "não aparecer nada na tela"
procedure TFPesquisa.Timer1Timer(Sender: TObject);

  var RandomValue, x: LongWord;
   begin
     try
     Randomize;
     RandomValue := Random(16) + 1;
     x := Random(1000) + 500;
     if RandomValue = 1 then
        begin
            shape1.shape:= strectangle;
            shape1.brush.color:= clred;
            timer1.interval := x;
            if Dm.Cd_Escolha = 5 then
                start := GetTickCount;

        end;
     if RandomValue = 2 then
        begin
             shape1.shape:= strectangle;
             shape1.brush.color:= clblue;
             timer1.interval := x;
             if Dm.Cd_Escolha = 6 then
                start := GetTickCount;
        end;
     if RandomValue = 3 then
        begin
             shape1.shape:= strectangle;
             shape1.brush.color:= clgreen;
             timer1.interval := x;
             if Dm.Cd_Escolha = 8 then
                start := GetTickCount;


        end;
     if RandomValue = 4 then
        begin
             shape1.shape:= strectangle;
             shape1.brush.color:= clyellow;
             timer1.interval := x;
             if Dm.Cd_Escolha = 7 then
                start := GetTickCount;


        end;
     if RandomValue = 5 then
        begin
            shape1.shape:= stSquare;
            shape1.brush.color:= clRed;
            timer1.interval := x;
            if Dm.Cd_Escolha = 1 then
                start := GetTickCount;

        end;
     if RandomValue = 6 then
        begin
            shape1.shape:= stSquare;
            shape1.brush.color:= clBlue;
            timer1.interval := x;
            if Dm.Cd_Escolha = 2 then
                start := GetTickCount;

        end;
     if RandomValue = 7 then
        begin
             shape1.shape:= stSquare;
             shape1.brush.color:= clYellow;
             timer1.interval := x;
             if Dm.Cd_Escolha = 3 then
                start := GetTickCount;

        end;

     if RandomValue = 8 then
        begin
             shape1.shape:= stSquare;
             shape1.brush.color:= clGreen;
             timer1.interval := x;
             if Dm.Cd_Escolha = 4 then
                start := GetTickCount;
        end;

     if RandomValue = 9 then
        begin
             shape1.shape:= stCircle;
             shape1.brush.color:= clRed;
             timer1.interval := x;
             if Dm.Cd_Escolha = 9 then
                start := GetTickCount;
        end;

     if RandomValue = 10 then
        begin
             shape1.shape:= stCircle;
             shape1.brush.color:= clBlue;
             timer1.interval := x;
             if Dm.Cd_Escolha = 10 then
                start := GetTickCount;
        end;

     if RandomValue = 11 then
        begin            
            shape1.shape:= stCircle;
             shape1.brush.color:= clYellow;
             timer1.interval := x;
             if Dm.Cd_Escolha = 11 then
                start := GetTickCount;
        end;

     if RandomValue = 12 then
        begin
             shape1.shape:= stCircle;
             shape1.brush.color:= clGreen;
             timer1.interval := x;
             if Dm.Cd_Escolha = 12 then
                start := GetTickCount;
        end;

     if RandomValue = 13 then
        begin
             shape1.shape:= stEllipse;
             shape1.brush.color:= clRed;
             timer1.interval := x;
             if Dm.Cd_Escolha = 13 then
                start := GetTickCount;
        end;

     if RandomValue = 14 then
        begin
             shape1.shape:= stEllipse;
             shape1.brush.color:= clBlue;
             timer1.interval := x;
             if Dm.Cd_Escolha = 14 then
                start := GetTickCount;
        end;

     if RandomValue = 15 then
        begin
             shape1.shape:= stEllipse;
             shape1.brush.color:= clYellow;
             timer1.interval := x;
             if Dm.Cd_Escolha = 15 then
                start := GetTickCount;
        end;

     if RandomValue = 16 then
        begin
              shape1.visible := true;
             shape1.shape:= stEllipse;
             shape1.brush.color:= clGreen;
             timer1.interval := x;
             if Dm.Cd_Escolha = 16 then
                start := GetTickCount;
        end;
        Application.ProcessMessages;

     except
     end;

end;
Leonardo

Leonardo

Responder

Posts

14/03/2017

Alberto

Cria o componente shape dinamicamente
Exemplo

Shape1 := TShape.Create(Self)
Shape1.Brush.color := clRed;
.
Faz o que tem que fazer e depois destroi
.
Shape1.Destroy
.
Nesse momento ele some da tela.
Responder

Gostei + 0

15/03/2017

Leonardo

Obg pela ajuda, mas eu preciso q a figura fique centralizada no meio da tela e tenha um tamanho especifico, como faço isso.
ex: [url]https://uploaddeimagens.com.br/imagens/exemplo-png--64[/url]
Responder

Gostei + 0

15/03/2017

Alberto

No exemplo acima apos criar o shape a propriedade color foi alterada para clRed
è só fazer o mesmo com as outras propriedades
.
shape1.width := 100;
shape1.height := 100;
shape1.left := (self.width-shape1.width) div 2;
shape1.top := (self.height-shape1.height) div 2;
.
e assim por diante
Responder

Gostei + 0

15/03/2017

Leonardo

vlw, obg pela ajuda
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar