Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

System.Windows.Forms.Form_Load() calls Application.Exit and Form     flashes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe Duchtel - 07 Mar 2008 15:29 GMT
Hello -

I have a GUI that is contained in a Class which Inherits
SystemWindows.Forms.Form.  The Private Sub _Load() runs a few checks
on command arguments and in some cases calls Application.Exit after an
error message is output in a MsgBox().

What I am seeing, is that the GUI briefly appears and then
disappears ... like a quick flash.  Is there anything I could to avoid
that?  Is there a better way to exit out of the _Load() function?

Thanks,
Joe
Patrice - 07 Mar 2008 15:58 GMT
You could perhaps hide the window...

If possible my personal preference would be even to avoid doing this but
instead to check command line arguments before opening the window...

(for example in MyApplication.Startup that provides a e.cancel property to
cancel the application launch).

--
Patrice

> Hello -
>
[quoted text clipped - 9 lines]
> Thanks,
> Joe
Steve Gerrard - 07 Mar 2008 16:18 GMT
> Hello -
>
[quoted text clipped - 6 lines]
> disappears ... like a quick flash.  Is there anything I could to avoid
> that?  Is there a better way to exit out of the _Load() function?

I think it is generally not a good idea to exit out of a Load event. It is
confusing to Windows. :)

A better idea is to run your tests the first time the form is Activated:

Private Sub Form1_Activated( _
  ByVal sender As Object, ByVal e As System.EventArgs) _
  Handles MyBase.Activated

  Static Checked As Boolean
  If Not Checked Then
     Checked = True
     ' do your checks here...
  End If

End Sub
Joe Duchtel - 07 Mar 2008 19:00 GMT
> > Hello -
>
[quoted text clipped - 23 lines]
>
> End Sub

Hello -

I just tried this and it looks like the Activated event comes after
the Loaded.  So I will get the Form visible.  I guess that is not the
worst event.  At least it will not flash anymore.

Thanks,
Joe
Thorsten Doerfler - 07 Mar 2008 18:17 GMT
Joe Duchtel schrieb:
> I have a GUI that is contained in a Class which Inherits
> SystemWindows.Forms.Form.  The Private Sub _Load() runs a few checks
[quoted text clipped - 4 lines]
> disappears ... like a quick flash. Is there anything I could to avoid
> that? Is there a better way to exit out of the _Load() function?

Public Shared Sub Main()
 If Checked() Then
   Application.Run(New Form1)
 Else
   MsgBox("Failed!")
 End If
End Sub

In Project => Properties select 'Sub Main' as Startup Object.

Thorsten Doerfler
Signature

Microsoft MVP Visual Basic

vb-hellfire visual basic faq  | vb-hellfire - einfach anders
http://vb-faq.de/             | http://www.vb-hellfire.de/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.