Board index » delphi » Visible := False doesn't work in Form.OnShow event

Visible := False doesn't work in Form.OnShow event

I have a form with several image components.  In the form's OnShow event it
is determined if one of the image components should be shown or not.  If
not... the image's visible property is set to false.  Once the form is shown
and the user hits a button it runs through the same routine (to see if one
of the image components should be invisible and setting its Visible property
to False).
  My question is when the form is shown all the images are visible even if
one is set to false.  Once the user hits the button everything works great.
I have tried Application.ProcessMessages but it hasn't helped.  This only
happens when the form is shown and both the form and button call the same
event.  Any clues???

Thanks,
Peggy

 

Re:Visible := False doesn't work in Form.OnShow event


The events are triggered in this order:
OnCreate,OnShow,OnResize,OnActivate,OnPaint,OnClose,OnCloseQuery,OnDeactivate,OnHide,OnDestroy.

Try putting your code in some other event.

Quote
Peggy Schaefer wrote:
> I have a form with several image components.  In the form's OnShow event it
> is determined if one of the image components should be shown or not.  If
> not... the image's visible property is set to false.  Once the form is shown
> and the user hits a button it runs through the same routine (to see if one
> of the image components should be invisible and setting its Visible property
> to False).
>   My question is when the form is shown all the images are visible even if
> one is set to false.  Once the user hits the button everything works great.
> I have tried Application.ProcessMessages but it hasn't helped.  This only
> happens when the form is shown and both the form and button call the same
> event.  Any clues???

> Thanks,
> Peggy

Re:Visible := False doesn't work in Form.OnShow event


  Try it under OnPaint instead.  --  I forgot why this happens, but using
'OnPaint' should help...

--
Jason Wallace
SL Software
Dark...@SLSoftware.reno.nv.us
--
Bomb Technician:  If you see me running, try and keep up!
--

Quote
Peggy Schaefer <peggy...@earthlink.net> wrote in message

news:7ke0cn$6ht$1@fir.prod.itd.earthlink.net...
Quote
> I have a form with several image components.  In the form's OnShow event
it
> is determined if one of the image components should be shown or not.  If
> not... the image's visible property is set to false.  Once the form is
shown
> and the user hits a button it runs through the same routine (to see if one
> of the image components should be invisible and setting its Visible
property
> to False).
>   My question is when the form is shown all the images are visible even if
> one is set to false.  Once the user hits the button everything works
great.
> I have tried Application.ProcessMessages but it hasn't helped.  This only
> happens when the form is shown and both the form and button call the same
> event.  Any clues???

> Thanks,
> Peggy

Re:Visible := False doesn't work in Form.OnShow event


In article <7ke0cn$6h...@fir.prod.itd.earthlink.net>, "Peggy Schaefer"

Quote
<peggy...@earthlink.net> wrote:
> I have a form with several image components.  In the form's OnShow event it
> is determined if one of the image components should be shown or not.  If
> not... the image's visible property is set to false.  Once the form is shown
> and the user hits a button it runs through the same routine (to see if one
> of the image components should be invisible and setting its Visible property
> to False).
>   My question is when the form is shown all the images are visible even if
> one is set to false.  Once the user hits the button everything works great.
> I have tried Application.ProcessMessages but it hasn't helped.  This only
> happens when the form is shown and both the form and button call the same
> event.  Any clues???

> Thanks,
> Peggy

Try Placing the TImage components in a Panel. You will find that the
visible property will then work correctly.

Re:Visible := False doesn't work in Form.OnShow event


You could also try to redirect the Hide property to a Timer.

procedure TForm1.FormActivate(Sender :TObject); //or onshow whatever
begin
  Timer1.Enabled := False;
  bla
  bla
  bla
  Timer1.Enabled := True;
End;

procedure TForm1.OnTimer1; // Dubbleclick anyway --> don't know proc name
begin
  Timer.Enabled := False;
  Form1.Hide;
End;

Leon "The Sorceror" Friesema

Quote
Rashid Ali wrote:
> In article <7ke0cn$6h...@fir.prod.itd.earthlink.net>, "Peggy Schaefer"
> <peggy...@earthlink.net> wrote:

> > I have a form with several image components.  In the form's OnShow event it
> > is determined if one of the image components should be shown or not.  If
> > not... the image's visible property is set to false.  Once the form is shown
> > and the user hits a button it runs through the same routine (to see if one
> > of the image components should be invisible and setting its Visible property
> > to False).
> >   My question is when the form is shown all the images are visible even if
> > one is set to false.  Once the user hits the button everything works great.
> > I have tried Application.ProcessMessages but it hasn't helped.  This only
> > happens when the form is shown and both the form and button call the same
> > event.  Any clues???

> > Thanks,
> > Peggy

> Try Placing the TImage components in a Panel. You will find that the
> visible property will then work correctly.

Other Threads