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/