Jump to content

Ready made "About" dialog


GEOSoft
 Share

Recommended Posts

I know these are simple to create but here's one that's ready made as a udf'

Just copy the code below to about.au3 and place it in your include folder.

It uses relative positioning so it first checks the current GUICoordMode setting, changes it if required and then sets it back when exiting the function.

#include-once


;===============================================================================
; Function Name:    _GUICreateAbout()
; Description:          Create an "About" dialog
; Syntax:                 _GUICreateAbout([$aTtl[, $aTxt[,$cTxt[, $aGw[, $aGh[, $xPos[, $yPos[, $aStyle[, $aExStyle[, $hWin[ $aBg_Color[,$Bold]]]]]]]]]]]]])
; Parameter(s):           $aTtl -- the text that will appear on the title bar (default = "")
;                               $aTxt  -- text to appear in the main label (default = "")
;                               $cTxt  -- text to appear in the copyright label (default = "")
;                               $aGw -- The width of the window (default = 450)
;                               $aGh -- The height of the window (default = 200)
;                               $xPos  -- Left position of window.  (default = centered)
;                               $yPos  -- Top position of window.  (default = centered)
;                               $aStyle  -- Window Style.  (default = 0x00400000)
;                               $aExStyle -- Window extended style (default -1)
;                               $hWin  -- Name of the window to switch to on close.  (default = last used window)
;                               $aBg_Color -- The background color to use for the window (default = 0xfcfcfe)
;                               $Bold - 0 = Use standard font weight.  1 = Use bold (size 9, 500) font (default) 
; Requirement(s):         
; Return Value(s):    Success - Creates the About dialog
; Author(s):              GEOSoft.  Thanks to gafrost for his input.
; Note(s):                All Parameters are optional but the dialog is kind of useless without at least $aTxt
;                              The copyright text will be prefixed with 'Copyright©  ' and suffixed with the current year
;                              To use the copyright with a date span then $Copy_Txt = 'GEOSoft 2003 -' would display
;                                  Copyright©  GEOSoft 2003 - 2007
;                              You can modify the link text and URL but remember that you should give credit where due
;                                 In a future version I may add the ability to include more links.
; Modification(s):     June 11 / 2007 - Added a new label for copyright notice and added $Bold param
;===============================================================================

;_GUICreateAboutExample() ;;<<=======  Uncomment this line to run example
Func _GUICreateAboutExample()
   $Ttl = 'My dialog demo'
   $Ver = '1.0.0.0 (Beta)' ;;<<===  App version (optional)
   ;; <<===  Create the text that will be placed in the main label of the About box  ===>>
   $Abt_Txt = $ttl & '  version ' & $ver & @CRLF & ' Enter your name or your company name' & @CRLF & @CRLF
   $Abt_Txt &= $ttl & ' is used as a demonstration of  calling the "About" dialog.' & @CRLF
   $Frm_Example = GUICreate($Ttl, 260, 100)
   $Mnu_Help = GUICtrlCreateMenu('&Help')
   $Mnu_About = GUICtrlCreateMenuItem('&About', $Mnu_Help)
   $Lbl_Inst = GUICtrlCreateLabel('Click the Help menu >> "About" to run this example', 10, 10 ,240,20)
   $Btn_X = GUICtrlCreateButton('Close', 100, 40, 60,30)
   GUISetState()
   While 1
      $Msg = GUIGetMsg()
      Switch $Msg
         Case $Mnu_About
            _GUICreateAbout($Ttl & ' version: ' & $Ver, $Abt_Txt, 'GEOSoft')
         Case -3, $Btn_X
            ExitLoop
      EndSwitch
   Wend
   Exit
EndFunc   ;<==> _GUICreateAboutExample()

Func _GUICreateAbout( $aTtl = '' , $aTxt = '', $cTxt = '', $aGw = 450, $aGh = 300, $xPos = -1, $yPos = -1, $aStyle = 0x00400000, $aExStyle = -1, $hWin = '', $aBg_Color = 0xfcfcfe, $Bold = 1)
   ;;<<======== This GUI uses relative positioning so get the current value of GUICoordMode and change if required >>
   $sOpt = Opt ("GUICoordMode") 
   If $sOpt <> 2 Then Opt ("GUICoordMode","2")
   If $Bold <> 1 Then $Bold = 0
   If StringInStr($aTtl, 'about ') Then $aTtl = StringReplace($aTtj, 'about ','')
   Local $Msg, $aIco = @AutoItExe, $mp = $aGw/2
   ;;<<  Create the form  >>
   Local $Frm_Abt = GUICreate('About ' & $aTtl, $aGw, $aGh, $xPos, $yPos, $aStyle, $aExStyle)
   GUISetBkColor ($aBg_Color)
   GUICtrlCreateIcon($aIco, -1, 10, 10, 32, 32)
   Local $Abt_Lbl = GUICtrlCreateLabel('', 23, -1, $aGw -75, $aGh-130)
   If $Bold = 1 Then GuiCtrlSetFont($Abt_Lbl, 9,500)
   GUISetCoord(10, $aGh-115)
   GUICtrlCreateLabel('',-1, -1, $aGw-20, 4, 0x12) ;;<<=========  Create a divider line
   If $cTxt <> '' Then
    If NOT StringInStr($cTxt, 'Copyright') Then $cTxt = 'Copyright©  ' & $cTxt
    $cTxt &= Chr(32) & @Year
   EndIf
   Local $C_Lbl = GUICtrlCreateLabel('', -1, 5, $aGw -20, 20, 1)
   GUICtrlSetData($C_Lbl, $cTxt)
   ;;<<  Create the two labels for a hyperlink if required  >>
   GUISetCoord($aGw/2 - 177, $aGh -80)
   Local $Ai_Lbl = GUICtrlCreateLabel('Written entirely using AutoIt3 script:', -1,-1,175,20)
   Local $hLink = GUICtrlCreateLabel('http://www.autoitscript.com/autoit3/', 5, -1, 175, 20)
   GUICtrlSetColor($hLink,0x0000ff)
   GUICtrlSetCursor($hLink,0)
   GUICtrlSetTip($hLink, GUICtrlRead($hLink))
   GUISetCoord($Mp -30, $aGh -60)
   Local $Btn_Close = GUICtrlCreateButton('Close',-1, -1,60,30,1)
   GuiCtrlSetData($Abt_Lbl, $aTxt)
   GUISetState()
   While 1
      $Msg = GUIGetMsg()
      Switch $msg
         Case $Btn_Close
            GUIDelete($Frm_Abt)
            ExitLoop
         Case $hLink
            ;MsgBox(0,'TEST',GUICtrlRead($hLink)) ;;<<==========  For testing only
            ShellExecute(GUICtrlRead($hLink))
      EndSwitch
   Wend
   ;;<< Reset the GUICoordMode option if required >>
   If $sOpt <> 2 Then Opt ("GUICoordMode",$sOpt)
   GUISwitch ($hWin)
EndFunc    ;<===> _GUICreateAbout()

Edit::June 11 Added another label and 2 new parameters and a couple of cosmetic changes.

The label is for a copyright notice

the first new param is $cTxt which is the Copyright text (See Parameter(s) and Note(s) for usage

the second is $Bold which just sets the font size to 9 and font weight to 500 for better readability

Edit::May 21 Added a working example. Just uncomment the line that calls the example function.

Edit:: Added a divider line above the link labels.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

I knew there was another one around. In fact there is athird that I've seen that is simply a message box. I just got tired of writing a new one everytime I put something together and I wanted something small that gave AutoIt credit along with some flexibility for the user. I also always include the app icon so this does it ll for me.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

good one

Thanks, but I just finished making a few changes to it so I'll be changing my first post in a few minutes.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 3 weeks later...

I've made more changes to this function

Added another label and 2 new parameters and a couple of cosmetic changes.

The label is for a copyright notice just below the separator.

The first new param is $cTxt which is the Copyright text (See Parameter(s) and Note(s) for usage.

The second is $Bold which just sets the font size to 9 and font weight to 500 for better readability. (If set to 1)

An example of the Copyright text using a date span would be $cTxt = "GEOSoft 2003 -"

That would appear as "Copyright© GEOSoft 2003 - 2007"

I will also be adding two more labels in the next version to include another link which can be used to link to your own site for example.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...