About Dialog

What would be the fastest way to make an about dialog in Xojo. I know that with VB,NET, you can use a very nice easy template that uses the settings of your application to get the information that is shown from within the about dialog.

In OSX you can use

  Declare Function NSClassFromString Lib "Cocoa" (aClassName As CFStringRef) As Ptr
  Declare Function SharedApplication Lib "Cocoa" Selector "sharedApplication" (receiver As Ptr) As Ptr
  
  Dim sA As Ptr = NSClassFromString("NSApplication")
  sA = SharedApplication(sA)
  
  Declare Sub OrderFrontStandardAboutPanel Lib "Cocoa" Selector "orderFrontStandardAboutPanel:" _
  (receiver As Ptr, iD As Ptr)
  
  OrderFrontStandardAboutPanel(sA, Nil)

I just put up a modal window with a default button and some label fields (so they don’t get the focus).

stAppName gets the name of the application.
StatVersion is a field right under where I put the stAppName field.
Copyrite is a field I locate just above the default OK button.
StaticText1 is a field at the bottom of the window promoting Xojo.
Of course the fields can go wherever you want.

Then I use the following code in the Open event:

  if TargetMacOS = True or TargetLinux = true then
    stAppName.text = App.ExecutableFile.Name
  else
    stAppName.text = left (App.ExecutableFile.Name, len(App.ExecutableFile.Name) - 4)
  end if
  
  StatVersion.Text = "Version " + Str(App.MajorVersion) + "." + str(App.MinorVersion) + "." +  str(App.BugVersion)
  
  // Xojo first release has broken the App.LongVersion field pick
  // so for the time being revert to using App.CopyrightText
  // created in the App's constants.
  Copyrite.Text = App.CopyrightText
  ' Copyrite.Text = App.LongVersion
  
    StatVersion.text = StatVersion.text + " - Built on " + RBVersionString + " - " + App.BuildDate.ShortDate
    StaticText1.Text = "This program is built with Xojo from Xojo, Inc."

Once done the way you want it, export the window so you can later import it to other apps.

[quote=27601:@Dale Arends]I just put up a modal window with a default button and some label fields (so they don’t get the focus).

stAppName gets the name of the application.
StatVersion is a field right under where I put the stAppName field.
Copyrite is a field I locate just above the default OK button.
StaticText1 is a field at the bottom of the window promoting Xojo.
Of course the fields can go wherever you want.

Then I use the following code in the Open event:

  if TargetMacOS = True or TargetLinux = true then
    stAppName.text = App.ExecutableFile.Name
  else
    stAppName.text = left (App.ExecutableFile.Name, len(App.ExecutableFile.Name) - 4)
  end if
  
  StatVersion.Text = "Version " + Str(App.MajorVersion) + "." + str(App.MinorVersion) + "." +  str(App.BugVersion)
  
  // Xojo first release has broken the App.LongVersion field pick
  // so for the time being revert to using App.CopyrightText
  // created in the App's constants.
  Copyrite.Text = App.CopyrightText
  ' Copyrite.Text = App.LongVersion
  
    StatVersion.text = StatVersion.text + " - Built on " + RBVersionString + " - " + App.BuildDate.ShortDate
    StaticText1.Text = "This program is built with Xojo from Xojo, Inc."

Once done the way you want it, export the window so you can later import it to other apps.[/quote]
Excellent. I forgot to ask about the variables that you have mentioned. Thanks

[quote=27553:@Axel Schneider]In OSX you can use

[code]
Declare Function NSClassFromString Lib “Cocoa” (aClassName As CFStringRef) As Ptr
Declare Function SharedApplication Lib “Cocoa” Selector “sharedApplication” (receiver As Ptr) As Ptr

Dim sA As Ptr = NSClassFromString(“NSApplication”)
sA = SharedApplication(sA)

Declare Sub OrderFrontStandardAboutPanel Lib “Cocoa” Selector “orderFrontStandardAboutPanel:” _
(receiver As Ptr, iD As Ptr)

OrderFrontStandardAboutPanel(sA, Nil)
[/code][/quote]
Thanks.

Axel’s solution is the easiest if you’re building Mac only, you can use the property list file and a “Credits.rtf” file in the resources to customise the about box. This is a genuine Apple about box. It will automagically display the app version app icon & copy right for you.

However Dale’s solution is more x-plat so if you’re building for other platforms than the Mac, then I’d suggest using his method. Although please note, if you intend to ship on the App Store, the version number has to be changed which breaks the Xojo version constants.

[quote=27665:@Sam Rowlands]Axel’s solution is the easiest if you’re building Mac only, you can use the property list file and a “Credits.rtf” file in the resources to customise the about box. This is a genuine Apple about box. It will automagically display the app version app icon & copy right for you.

However Dale’s solution is more x-plat so if you’re building for other platforms than the Mac, then I’d suggest using his method. Although please note, if you intend to ship on the App Store, the version number has to be changed which breaks the Xojo version constants.[/quote]
Thanks.