frmSplash Form

frmSplash Form

The form frmSplash is a splash screen. It is added to the project if you specify a splash screen at application startup in the VB Application Wizard. After being upgraded, this form has two problems. First, as the frmAbout form does, frmSplash inserts the application version into a label. As we discussed in the earlier section on App.Revision, you should replace the version code in Form_Load. The following Visual Basic 6 code

lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." _    & App.Revision

upgrades to

lblVersion.Text = "Version " & _ System.Diagnostics.FileVersionInfo.GetVersionInfo( _ System.Reflection.Assembly.GetExecutingAssembly.Location _ ).FileMajorPart _ & "." & System.Diagnostics.FileVersionInfo.GetVersionInfo( _ System.Reflection.Assembly.GetExecutingAssembly.Location _ ).FileMinorPart & "." & App.Revision

Replace this code with the following:

lblVersion.Text = "Version " & Application.ProductVersion

The second problem is something new. Applications with a splash screen perform a series of steps in Sub Main to

  1. Show the frmSplash form.

  2. Refresh the frmSplash form (forcing the form to be fully painted).

  3. Load the frmMain form.

  4. Unload the frmSplash form.

  5. And finally, show the frmMain form.

Here is the code that performs this series of steps:

Sub Main()    frmSplash.Show    frmSplash.Refresh    Set fMainForm = New frmMain    Load fMainForm    Unload frmSplash    fMainForm.Show End Sub

After upgrading, this code looks like the following:

Public Sub Main()    frmSplash.DefInstance.Show()    frmSplash.DefInstance.Refresh()    fMainForm.DefInstance = New frmMain    'UPGRADE_ISSUE: Load statement is not supported.    Load(fMainForm)    frmSplash.DefInstance.Close()    System.Windows.Forms.Application.Run(fMainForm.DefInstance) End Sub

This code causes a compile error because the Load statement is not supported in Visual Basic .NET. To fix the error, remove the Load(fMainForm) statement; the application will work normally. The updated Sub Main event will look like this:

Public Sub Main()    frmSplash.DefInstance.Show()    frmSplash.DefInstance.Refresh()    fMainForm.DefInstance = New frmMain    frmSplash.DefInstance.Close()    System.Windows.Forms.Application.Run(fMainForm.DefInstance) End Sub



Upgrading Microsoft Visual Basic 6.0to Microsoft Visual Basic  .NET
Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET w/accompanying CD-ROM
ISBN: 073561587X
EAN: 2147483647
Year: 2001
Pages: 179

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net