Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web

A Template of Get/Set Application Settings with a Splash Screen

VB Source Codes


[Sample Mission]
      This sample demonstrates the usage of Get/Set Settings with Win32 API and how to add a splash screen in your program.

 

[Usage]

  1. Create a new a standard.exe project named as 'prjSplashSettings' and add a module named as 'mdlMain', add a form 'frmMain.frm' and 'frmSplash'
  2. Copy and Paste below Codes into each module
  3. Add below controls into the frmsplash.frm:

Label control:

lblVersion
lblProductName
lblAuthor
lblCopyright
lblLicenseTo
lblWarning

  1. Press F5 to Run

[Customize]

  1. Before newing a project, you should setup all properties of the application, such as application name
    application version number, etc. You can debug them by setting CC_DEBUG as TRUE.
  2. Modify the splash screen 'frmSplash' to suit your application titles.
  3. Replace all your public Settings/Setup variables at #SETTINGS

[Quick Use]

 

 

[NOTES]

 

 

[Other Variations]

 

 

[Codes as following]

Option Explicit

            '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
            '+++++                                                                   +++++'
            '+++++           MODULE LEVEL VARIABLES, CONSTANTS, DECLARATIONS,        +++++'
            '+++++                                                                   +++++'
            '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'

'''''''''''''''
''' Public  '''
'''         '''
'''''''''''''''

Public gsAppPath As String  'other app object properties are listed in InitApp().
Public fMainForm As frmMain 'frmMain is the name of the main form

'#SETTINGS
'Declaration of Public Settings/Setup Variables, for example:
'Public gbIfHighScore As Boolean
'...

'''''''''''''''
''' Private '''
'''         '''
'''''''''''''''

#Const CC_DEBUG = True 'compiler const

            '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
            '+++++                                                                   +++++'
            '+++++                              FUNCTIONS                            +++++'
            '+++++                                                                   +++++'
            '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'

'''''''''''''''''''''
''' COM Functions '''
'''               '''
'''''''''''''''''''''

'Anywhere it can be called to get all settings
Public Sub GetAllSetupValue()
On Error GoTo Err_GetAllSetupValue
    '#SETTINGS: Get settings from system registry, for example:
    'gbIfHighScore = GetSetting(App.Title, "Settings", "IfHighScore", True)
    'giHighScore = GetSetting(App.Title, "Settings", "HighScore", 90)
    '...
    
    Exit Sub
Err_GetAllSetupValue:
    MsgBox Err.Description
    Resume Next
End Sub

'Anywhere it can be called to save all settings
Public Sub SaveAllSetupValue()
On Error GoTo Err_SaveAllSetupValue
    DeleteSetting App.Title, "Settings"
    
    '#SETTINGS: Save settings into system registry, for example:
    'SaveSetting App.Title, "Settings", "IfHighScore", gbIfHighScore
    'SaveSetting App.Title, "Settings", "HighScore", giHighScore
    '...
    
    Exit Sub
Err_SaveAllSetupValue:
    MsgBox Err.Description
    Resume Next
End Sub


'''''''''''''''''''''''''
''' Private Functions '''
'''                   '''
'''''''''''''''''''''''''

Private Sub Main()  'Main Entry Here!
On Error GoTo Err_Main

    Call InitApp
    
    Load frmSplash
    
    Call GetAllSetupValue
    
    Set fMainForm = New frmMain
    Load fMainForm
    Unload frmSplash
    fMainForm.Show
    
    Exit Sub
Err_Main:
    MsgBox Err.Description
    End 'to force to stop the applcation if any error.
End Sub

Private Sub InitApp()

    'Convert application path into unique format.
    'Such as "C:" to "C:\", and "C:\My Applications\" to "C:\My Applications\"
    If Right$(App.Path, 1) <> "\" Then
        gsAppPath = App.Path & "\"
    Else
        gsAppPath = App.Path
    End If
    
    App.HelpFile = ""   'set the help file's path
 
    #If CC_DEBUG Then
        Debug.Print App.EXEName 'name of EXE file (without extension!). instead of the projeact name when designing.
        Debug.Print App.Title   'application's title which will display in Windows Task Lists.
        Debug.Print App.FileDescription
        
        Debug.Print App.ProductName
        Debug.Print App.Major
        Debug.Print App.Minor
        Debug.Print App.Revision
        Debug.Print App.CompanyName
        Debug.Print App.LegalCopyright
        Debug.Print App.LegalTrademarks
        Debug.Print App.Comments
    #End If
    
End Sub
Option Explicit

'Belows are all useful properties of the App object to show in the Splash window:
'
' comments              properties              samples
'---------------------  ----------------------  -----------------------
'EXE File Name          App.EXEName             "englishreview"
'Application Tittle     App.Title               "English Review"
'Description            App.FileDescription     "The SoftWare is licensed to : Shirley, Robert and their friends."
'Product Name           App.ProductName         "English Review"
'Major Version          App.Major               "1"
'Minor Version          App.Minor               "0"
'Revision               App.Revision            "0"

'Company Name           App.CompanyName         "Home CO, LTD."
'Copyright              App.LegalCopyright      "Copyright(C) 1999 - 2000, Home Corp."
'Trade Mark             App.LegalTrademarks

'Comment                App.Comments
'----------------------------------------------------------------------

Private Sub Form_Load()

    lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
    lblProductName.Caption = App.ProductName
    lblAuthor = "Robert Han"    'or, App.CompanyName
    lblCopyright = App.LegalCopyright
    lblLicenseTo = "User Name"
    lblWarning = "Warning: This computer program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program or any portion of it, may result in severe civil and criminal penlties. and will be prosecuted to the mazimum extent possible under the law."
    

    'Change the mouse pointer into Hourglass status
    'and restore it in a few seconds.
    Screen.MousePointer = vbHourglass
    DoEvents
    Me.Show
    Call Delay(3)   'if need
    
End Sub

Private Sub Delay(secs As Single)
    'Timer function return total seconds from 0:00AM.
    'To loop this application until the return value of Timer function
    'reaches the specified time.
    'At the same time, other applications can keep running by DoEvents
    Dim start As Single
    start = Timer
    While (Timer < (start + secs))
        DoEvents
    Wend
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Screen.MousePointer = vbDefault
End Sub

Copyright (c) 1999 - 2001, robert han, all rigths are reserved.