home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch26code / about.cls next >
Text File  |  1995-08-01  |  8KB  |  181 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "About"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. '**************************************************************
  9. ' ABOUT.CLS - This is the About class which is used to display
  10. '             the about dialog. Its Creatable and Public
  11. '             properties have been set so that it is only
  12. '             visible to this project.
  13. '**************************************************************
  14. Option Explicit
  15. '**************************************************************
  16. ' Declare private variables for your properties as Variant so
  17. ' you can take advantage of IsEmpty(). Rememeber that Variants
  18. ' are very inefficent because they are the largest data type,
  19. ' so you should try to limit your use of them.
  20. ' I included variants, just to demonstrate a varity of
  21. ' techniques, but I normally avoid variants at all costs.
  22. '**************************************************************
  23. Private App, AppCompany, VerNum, User, Company
  24. Private RegNum, AboutMsg
  25. '**************************************************************
  26. ' NOTE: For all of the following properties, if a Get is
  27. '       performed before a Let, then a default value will be
  28. '       returned. However, this value is NOT stored in its
  29. '       related private variable.
  30. '**************************************************************
  31. '**************************************************************
  32. ' This is a Read/Write property which should be set with the
  33. ' name of the program that is using this object.
  34. '**************************************************************
  35. Public Property Let AppName(str As String)
  36.     App = str
  37. End Property
  38.  
  39. Public Property Get AppName() As String
  40.     AppName = IIf(IsEmpty(App), "AppName  Default", App)
  41. End Property
  42. '**************************************************************
  43. ' This is a Read/Write property which should be set with the
  44. ' name of the company who wrote the application that is
  45. ' calling this object.
  46. '**************************************************************
  47. Public Property Let AppCompanyName(str As String)
  48. Attribute AppCompanyName.VB_Description = "The software vendors name who will appear in the about box. (Read/Write)"
  49.     AppCompany = str
  50. End Property
  51.  
  52. Public Property Get AppCompanyName() As String
  53.     AppCompanyName = IIf(IsEmpty(AppCompany), _
  54.                          "AppCompanyName Default", AppCompany)
  55. End Property
  56. '**************************************************************
  57. ' This is a Read/Write property which should be set with the
  58. ' version number of the application which is using this object.
  59. '**************************************************************
  60. Public Property Let VersionNumber(str As String)
  61. Attribute VersionNumber.VB_Description = "The version number of the calling application as you want it to appear in the about box. (Read/Write)"
  62.     VerNum = str
  63. End Property
  64.  
  65. Public Property Get VersionNumber() As String
  66.    VersionNumber = IIf(IsEmpty(VerNum), "1.00", VerNum)
  67. End Property
  68. '**************************************************************
  69. ' This is a Read/Write property which should be set with the
  70. ' name of the end user who is using your application.
  71. '**************************************************************
  72. Public Property Let UserName(str As String)
  73.     User = str
  74. End Property
  75.  
  76. Public Property Get UserName() As String
  77.     UserName = IIf(IsEmpty(User), "UserName Default", User)
  78. End Property
  79. '**************************************************************
  80. ' This is a Read/Write property which should be set with the
  81. ' user's (see above) company name.
  82. '**************************************************************
  83. Public Property Let CompanyName(str As String)
  84. Attribute CompanyName.VB_Description = "The end user's company name that will appear in the about box. (Read/Write)"
  85.     Company = str
  86. End Property
  87.  
  88. Public Property Get CompanyName() As String
  89.     CompanyName = IIf(IsEmpty(Company), "CompanyName Default", _
  90.                       Company)
  91. End Property
  92. '**************************************************************
  93. ' This is a Read/Write property which should be set with a
  94. ' registration or serial number of the product that called
  95. ' this object.
  96. '**************************************************************
  97. Public Property Let Registration(str As String)
  98. Attribute Registration.VB_Description = "The registration or serial number you want to appear in the about box. (Read/Write)"
  99.     RegNum = str
  100. End Property
  101.  
  102. Public Property Get Registration() As String
  103.     Registration = IIf(IsEmpty(RegNum), "Registration Default", _
  104.                        RegNum)
  105. End Property
  106. '**************************************************************
  107. ' This is a Read/Write property which can contain up to 2
  108. ' lines of text to display in the about box. The text will
  109. ' automatically wrap, so carriage returns aren't required.
  110. '**************************************************************
  111. Public Property Let Message(str As String)
  112. Attribute Message.VB_Description = "Any any additional info you want to appear in the about box between the black lines. (Read/Write)"
  113.     AboutMsg = str
  114. End Property
  115.  
  116. Public Property Get Message() As String
  117.     Message = IIf(IsEmpty(AboutMsg), "Message Default", AboutMsg)
  118. End Property
  119. '**************************************************************
  120. ' This method detrmines how the dialog box should be displayed,
  121. ' then it loads it with the appropriate values and displays it.
  122. '**************************************************************
  123. Public Sub ShowAbout(AsSplash As Boolean)
  124.     '**********************************************************
  125.     ' Set the variable so the about box knows how to
  126.     ' display itself.
  127.     '**********************************************************
  128.     bSplashScreen = AsSplash
  129.     '**********************************************************
  130.     ' Set the common elements used by the splash screen and
  131.     ' about box.
  132.     '**********************************************************
  133.     With AboutBox
  134.         .lbl(0) = AppName
  135.         .lbl(1) = "Version " & VersionNumber
  136.         .lbl(2) = "Copyright ⌐ " & Year(Now) & " " & AppCompanyName
  137.         .lbl(3) = UserName
  138.         .lbl(4) = CompanyName
  139.         .lbl(5) = Registration
  140.         .lbl(6) = Message
  141.     End With
  142.     
  143.     If AsSplash Then
  144.         '******************************************************
  145.         ' Show About Box as Splash Screen by removing its
  146.         ' caption, hiding the ok button, and displaying it as
  147.         ' modeless.
  148.         '******************************************************
  149.         With AboutBox
  150.             .cmdOk.Visible = False
  151.             .Caption = ""
  152.             .Show
  153.             '**************************************************
  154.             ' NOTE: This refresh is required, because splash
  155.             '       screens are usually show during peak
  156.             '       processing times. If you don't refresh,
  157.             '       then you'll just display a white form.
  158.             '**************************************************
  159.             .Refresh
  160.         End With
  161.         '******************************************************
  162.         ' Set the about box on top to prevent it from
  163.         ' disappearing during event processing.
  164.         '******************************************************
  165.         AlwaysOnTop AboutBox.hwnd, False
  166.     Else
  167.         With AboutBox
  168.             .cmdOk.Visible = True
  169.             .Caption = "About " & AppCompanyName
  170.             .Show 1
  171.         End With
  172.     End If
  173. End Sub
  174. '**************************************************************
  175. ' Unloads the about box
  176. '**************************************************************
  177. Public Sub HideSplash()
  178.     Unload AboutBox
  179. End Sub
  180.  
  181.