Skip to main content
Email Password   helpLost your password?

Sample Image - aboutbox.gif

Introduction

The About Box dialog isn't an essential part of any application, but it serves an important role, as the "dogtags" for your application.

There are two distinct, and very different, audiences for this dialog.

You definitely should have an About Box-- but to continue with the dogtag analogy, if you're whipping out dogtags on a regular basis, that's symptomatic of a deeper problem (Mediiiic!). When you do need it, it can be a lifesaver. It's OK to be used infrequently, but it also needs to provide decent diagnostic info. Decorative About Boxes with their scrolling text and 3D graphics may be fun, but they aren't helpful.

In order to serve the needs of these two vastly different user groups, my About Box provides two views: a simple, basic view for users, and a vastly more detailed view (accessible through a "More >>" button) for developers.

Using the code

This form is intended to be a standalone, resuable component; simply drag and drop the AboutBox.vb file into your project, then instantiate it as you would any other form. It has no special dependencies.

Private Sub MenuItemAbout_Click(ByVal sender As System.Object,_
                   ByVal e As System.EventArgs) Handles MenuItemAbout.Click
   Dim frmAbout As New AboutBox
   frmAbout.ShowDialog(Me)
End Sub

That provides the simplest, default About Box behavior. This should work for most applications right out of the box (as pictured in the screenshot). If you want to customize the form's behavior, it does have a number of optional properties that can be set before showing the dialog:

Public Property AppEntryAssembly() As System.Reflection.Assembly
Public Property AppTitle() As String
Public Property AppDescription() As String
Public Property AppVersion() As String
Public Property AppCopyright() As String
Public Property AppImage() As Image
Public Property AppMoreInfo() As String
Public Property AppDetailsButton() As Boolean

The sample application demonstrates how to set these properties to customize the text in the dialog.

Points of Interest

The primary information presented by the About Box form is automatically derived from the AssemblyInfo.* file. The AssemblyInfo.* file should always be populated for all of your assemblies as a best programming practice, but you'll want to make doubly sure in this case.

<Assembly: AssemblyTitle("About Box Demo")>
<Assembly: AssemblyDescription("Demonstration of AboutBox.vb code")>
<Assembly: AssemblyCompany("Atwood Heavy Industries")>
<Assembly: AssemblyProduct("Demo code")>
<Assembly: AssemblyCopyright("� 2004, Atwood Heavy Industries")>
<Assembly: AssemblyTrademark("All Rights Reserved")>

The rest of the detailed information is gathered through .NET's built in, and very powerful, reflection capabilities.

The build date is automatically calculated for each assembly based on the Build and Revision numbers specified in the AssemblyInfo.*:

<Assembly: AssemblyVersion("4.1.*")>

This algorithm only works if standard auto-increment values were used (as pictured):

dt = CType("01/01/2000", DateTime). _
  AddDays(AssemblyVersion.Build). _
  AddSeconds(AssemblyVersion.Revision * 2)
If TimeZone.IsDaylightSavingTime(dt, _
  TimeZone.CurrentTimeZone.GetDaylightChanges(dt.Year)) Then
  dt = dt.AddHours(1)
End If
If dt > DateTime.Now Or AssemblyVersion.Build < 730 Or _
  AssemblyVersion.Revision = 0 Then
  dt = AssemblyLastWriteTime(a)
End If

If you've overridden the Build or Revision numbers, I can't calculate build date that way. In those scenarios, I use GetLastWriteTime on the assembly DLL file. I'm not aware of any more accurate methods to get build date, but between these two, the build time is usually correct.

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
Generalthank you Pin
serjik_avr
23:18 8 Nov '09  
Generalgood article Pin
Donsw
17:26 15 Mar '09  
QuestionPlace holders are visible [modified] Pin
Jiong Mai
4:27 22 Sep '08  
AnswerRe: Place holders are visible Pin
Jiong Mai
5:38 1 Dec '08  
GeneralRe: Place holders are visible Pin
ubik
21:24 14 Jan '09  
QuestionCan we have a WPF Version ? Pin
ubik
2:19 4 Aug '08  
QuestionExcellent Work! Details button disappears after the 1st time. Pin
WarrenG
14:18 22 May '08  
GeneralWell done. Pin
Daniel Landers
3:53 27 Mar '08  
Generalhelpful Pin
Abhijit Jana
4:51 15 Jan '08  
GeneralProblem when using with XslCompiledTransform Pin
Mattman206
5:22 8 Aug '07  
Generaladditions Pin
Mr.Mullet
2:03 2 Jul '07  
GeneralHelp with Pin
bgc-waterman
9:18 28 Feb '07  
GeneralConversion to c# Pin
mejax
10:26 24 Jan '07  
GeneralRe: Conversion to c# Pin
Robert M. Bouwens
3:52 31 Jan '07  
GeneralRe: Conversion to c# Pin
mejax
7:01 31 Jan '07  
AnswerRe: Conversion to c# Pin
wumpus1
11:26 26 Feb '07  
GeneralRe: Conversion to c# Pin
mejax
0:13 27 Feb '07  
GeneralRe: Conversion to c# Pin
wumpus1
10:58 5 Mar '07  
GeneralRe: Conversion to c# Pin
mejax
0:50 6 Mar '07  
GeneralRe: Conversion to c# Pin
jcooper987
12:10 23 Jul '08  
GeneralThanks for the code--- Pin
mef526
8:59 8 Feb '06  
GeneralThanks! Pin
Fenra
9:26 6 Dec '05  
GeneralNice One Pin
Sk8tz
21:05 5 Apr '05  
GeneralWeb Application ? Pin
mejax
22:13 3 Jan '05  
GeneralRe: Web Application ? Pin
wumpus1
15:11 9 Feb '05  


Last Updated 4 Mar 2007 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009