vb.net - Closing startup form kills application -


i make form fades in fades out , loads form up. when new form has loaded closes the start form.

problem when closes start form kills apllication.

public class splash dim appearance boolean = false  private sub splash_load(byval sender system.object, byval e system.eventargs) handles mybase.load     opacity = 0     fadein.start() end sub  private sub fadein_tick(byval sender system.object, byval e system.eventargs) handles fadein.tick     if not appearance         opacity += 0.015     end if     if opacity = 1         appearance = true     end if     if appearance = true         opacity -= 0.015         if opacity = 0             form1.show()         end if     end if end sub end class  public class form1  private function webload()     while webbrowser1.readystate <> webbrowserreadystate.complete         application.doevents()     end while     return 0 end function private function login(byval user string, byval pass string)     webbrowser1.navigate("http://caan/sc5/sc_login/aspx/login_launch.aspx?source=esolbranchlive")     webload()     webbrowser1.document.getelementbyid("txtusername").setattribute("value", user)     webbrowser1.document.getelementbyid("txtpassword").setattribute("value", pass)      dim allimgtags htmlelementcollection = webbrowser1.document.getelementsbytagname("img")     if allimgtags isnot nothing         each img htmlelement in allimgtags             if img.getattribute("src").contains("/images/sc5login07.jpg")                 img.invokemember("click")                 exit             end if         next img     end if     return 0 end function  private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load      login(user, pass)     webbrowser2.navigate("http://caan/sc5/sc_partscentre/aspx/partscentre_frameset.aspx")     webbrowser1.navigate("http://caan/sc5/sc_repairjob/aspx/repairjob_frameset.aspx")     splash.close() end sub end class 

i aware there propper splash screen form doesnt stay open long enough. on fadeout closes , launches app

my main question how can stop splash.close() closing whole application?

answer

sorted now, wont let me answer @ bottem...

used splashscreen provided in visualbasic express , added couple lines found on msdn application events

applicationevents

namespace  ' following events available myapplication: '  ' startup: raised when application starts, before startup form created. ' shutdown: raised after application forms closed.  event not raised if application terminates abnormally. ' unhandledexception: raised if application encounters unhandled exception. ' startupnextinstance: raised when launching single-instance application , application active.  ' networkavailabilitychanged: raised when network connection connected or disconnected. partial friend class myapplication     protected overrides function oninitialize( _ byval commandlineargs  _ system.collections.objectmodel.readonlycollection(of string)) boolean          me.minimumsplashscreendisplaytime = 7000         return mybase.oninitialize(commandlineargs)     end function  end class end namespace 

splashscreen1.vb

public notinheritable class splashscreen1 dim appearance boolean = false  private sub splashscreen1_load(byval sender object, byval e system.eventargs) handles me.load      if my.application.info.title <> ""         applicationtitle.text = my.application.info.title     else         applicationtitle.text = system.io.path.getfilenamewithoutextension(my.application.info.assemblyname)     end if      version.text = system.string.format(version.text, my.application.info.version.major, my.application.info.version.minor)      copyright.text = my.application.info.copyright      opacity = 0     fade.start() end sub  private sub mainlayoutpanel_paint(byval sender system.object, byval e system.windows.forms.painteventargs) handles mainlayoutpanel.paint end sub  private sub timer1_tick(byval sender system.object, byval e system.eventargs) handles fade.tick     fade.interval = 100     if not appearance         opacity += 0.1     end if      if appearance = true                 opacity -= 0.1         end if     if opacity = 1         fade.interval = 5000         appearance = true     end if end sub end class 

you should check shutdown mode option in application page of project http://msdn.microsoft.com/en-us/library/tzdks800(v=vs.90).aspx , tell value of shutdown mode , startup form.

i guess shutdown mode set when startup form closes , startup form set splash.

in case, try set shutdown mode on last window close , should solve issue.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -