Activated event called before OnPaint

  • Thread starter Thread starter ShakeDoctor
  • Start date Start date
S

ShakeDoctor

Hi, when I set the Activated event for a form like so:

this.Activated += new EventHandler(Form_Activated);

in the constructor for the form (after InitialiseComponent()), the
Form_Activated method is called *before* the OnPaint method for the form.

However, I want to paint the form first, and then have the Form_Activated
method called, because it contains a call to a lengthy process, and the user
can't see that anything is happening.

What's the fix?

TIA.
 
well the Form_Load *definitely* gets called before the form is painted. I
was under the impression that the Activated event occurred after the form is
shown, but obviously not.
 
If im not wrong the activated event just means that the form is now in the
forground it may and would have already been painted...
 
You can force the form to draw itself. For example, in the Form_Load event
you can do something like the following:

this.Visible = true;
this.Refresh();

Hope this helps.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "ShakeDoctor" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| References: <[email protected]>
<[email protected]>
| Subject: Re: Activated event called before OnPaint
| Lines: 31
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <[email protected]>
| Date: Fri, 22 Apr 2005 17:05:09 GMT
| NNTP-Posting-Host: 82.46.100.40
| X-Complaints-To: (e-mail address removed)
| X-Trace: text.news.blueyonder.co.uk 1114189509 82.46.100.40 (Fri, 22 Apr
2005 18:05:09 BST)
| NNTP-Posting-Date: Fri, 22 Apr 2005 18:05:09 BST
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!npeer.de.kpn-eurorings.net!border2.nntp.ams.giganews.com!nntp.giganews
..com!pe2.news.blueyonder.co.uk!blueyonder!pe1.news.blueyonder.co.uk!blueyond
er!text.news.blueyonder.co.uk!53ab2750!not-for-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.compactframework:27609
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| well the Form_Load *definitely* gets called before the form is painted.
I
| was under the impression that the Activated event occurred after the form
is
| shown, but obviously not.
|
| | > Shouldn't you be using the form_load event too?
| >
| > | >> Hi, when I set the Activated event for a form like so:
| >>
| >> this.Activated += new EventHandler(Form_Activated);
| >>
| >> in the constructor for the form (after InitialiseComponent()), the
| >> Form_Activated method is called *before* the OnPaint method for the
form.
| >>
| >> However, I want to paint the form first, and then have the
Form_Activated
| >> method called, because it contains a call to a lengthy process, and the
| > user
| >> can't see that anything is happening.
| >>
| >> What's the fix?
| >>
| >> TIA.
| >>
| >>
| >
| >
|
|
|
 
Actually you can call the application.doevents in the form load. this may
help it
 
Back
Top