Jump to content

Recommended Posts

Posted (edited)

OMG this must be so simple but i just can't figure it out! :shocked: I want to include an about window in my program which

  • is modal
  • has only an icon to close it (not maximize n stuff)
  • preferably has an ok button by default
  • does make the entire programm exit when closed
  • can contain user defined controls such as icons and labels
MsgBox is not the right thing and i can't figure out the right line of code with GUICreate. HELP PLX! :( Edited by pwn4g3
Posted (edited)

this is just a form with a ok button on it is that what you wanted i never did number 4 as i dont know what code that would be

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 322, 230, 193, 115)
$Button1 = GUICtrlCreateButton("AButton1", 240, 192, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit

    EndSwitch
WEnd

Koda is a good porgram to make guis with i use it all the time makes tings a lot easy http://www.autoitscript.com/forum/index.php?showtopic=32299

^ is the topic on koda

Edited by thenewkid

some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with

Posted (edited)

For your inspiration - Here is my simple version of About window with active URL labels:

#NoTrayIcon
#include <Constants.au3>
#include <GUIConstants.au3>

Opt("GUICloseOnESC",1)
Opt("GUIOnEventMode",1)

$about = GuiCreate("About",215,150,-1,-1,BitOR($WS_CAPTION,$WS_SYSMENU))
GUISetOnEvent ($GUI_EVENT_CLOSE, "AboutOK" )
GUICtrlCreateIcon (@AutoItExe,-1,11,11)
GUICtrlCreateLabel ("App name 1.0",59,11,135,20)
GUICtrlSetFont (-1,10, 800, 0, "Arial") ; bold
GUICtrlCreateLabel ("(c) 2005" & @CRLF & @CRLF & "Zedna",59,30,135,40)
$email = GUICtrlCreateLabel ("author@somewhere.com",59,70,135,15)
GuiCtrlSetFont($email, 8.5, -1, 4) ; underlined
GuiCtrlSetColor($email,0x0000ff)
GuiCtrlSetCursor($email,0)
GUICtrlSetOnEvent(-1, "OnEmail")
$www = GUICtrlCreateLabel ("www.autoitscript.com/forum/",59,85,140,15)
GuiCtrlSetFont($www, 8.5, -1, 4) ; underlined
GuiCtrlSetColor($www,0x0000ff)
GuiCtrlSetCursor($www,0)
GUICtrlSetOnEvent(-1, "OnWWW")
GUICtrlCreateButton ("OK",65,115,75,23,BitOr($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))
GUICtrlSetState (-1, $GUI_FOCUS)
GUICtrlSetOnEvent(-1, "AboutOK")
GUISetState(@SW_SHOW, $about)

While 1 
    Sleep(100)
WEnd

Func OnEmail()
    Run(@ComSpec & " /c " & 'start mailto:author@somewhere.com?subject=Something', "", @SW_HIDE)
EndFunc

Func OnWWW()
    Run(@ComSpec & " /c " & 'start www.autoitscript.com/forum/', "", @SW_HIDE)
EndFunc

Func AboutOK()
    Exit
EndFunc

Func OnAutoItExit()
    GUIDelete($about)
EndFunc
Edited by Zedna
Posted

Hi,

Here is my version to "About Window" (not so simple, but cool :shocked: ), it's used like an UDF function:

#include <GUIConstants.au3>

$Title = "About Info"

$MainLabel = "My program Name"
$CopyRLabel = "Copyright © " & @YEAR & " Company/Author. All rights reserved."

$NameURL1 = "App Web Page"
$URL1 = "http://www.autoitscript.com"
$NameURL2 = "Email"
$URL2 = "mailto:creat0rx@yahoo.com"
$NameURL3 = "Some additional link"
$URL3 = "http://personalwebpafe.com"
$LinkColor = 0x0000FF
$BkColor = 0xFFFFFF

$hWnd = WinGetHandle(WinGetTitle(""))

_About($Title, $MainLabel, $CopyRLabel, "v1.0", $NameURL1, $URL1, $NameURL2, $URL2, $NameURL3, $URL3, @AutoItExe, $LinkColor, $BkColor, -1, -1, -1, -1, $hWnd)

Func _About($Title, $MainLabel, $CopyRLabel, $VerLabel, $NameURL1, $URL1, $NameURL2, $URL2, $NameURL3, $URL3, $IconFile="", $LinkColor=0x0000FF, $BkColor=0xFFFFFF, $Left=-1, $Top=-1, $Style=-1, $ExStyle=-1, $Parent=0)
    Local $OldEventOpt = Opt("GUIOnEventMode", 0)
    Local $OldRunErrOpt = Opt("RunErrorsFatal", 0)
    Local $GUI, $LinkTop=120, $Msg
    Local $CurIsOnCtrlArr[1]
    
    Local $LinkVisitedColor[4] = [3, $LinkColor, $LinkColor, $LinkColor]
    Local $LinkLabel[4]
    
    WinSetState($Parent, "", @SW_DISABLE)
    
    If $ExStyle = -1 Then $ExStyle = ""
    $GUI = GUICreate($Title, 320, 240, $Left, $Top, $Style, 0x00000080+$ExStyle, $Parent)
    GUISetBkColor($BkColor)

    GUICtrlCreateLabel($MainLabel, 40, 20, 280, 25, 1)
    GUICtrlSetFont(-1, 16)

    GUICtrlCreateIcon($IconFile, 0, 10, 20)

    GUICtrlCreateGraphic(5, 75, 310, 3, $SS_ETCHEDFRAME)
    
    For $i = 1 To 3
        $LinkLabel[$i] = GUICtrlCreateLabel(Eval("NameURL" & $i), 150, $LinkTop, 145, 15, 1)
        GUICtrlSetCursor(-1, 0)
        GUICtrlSetColor(-1, $LinkColor)
        GUICtrlSetFont(-1, 9, 400, 0)
        $LinkTop += 30
    Next

    GUICtrlCreateLabel("Program version: " & @LF & $VerLabel, 10, 130, 150, 35, 1)
    GUICtrlSetFont(-1, 10, 600, 0, "Tahoma")
    
    GUICtrlCreateLabel($CopyRLabel, 0, 220, 320, -1, 1)

    GUISetState(@SW_SHOW, $GUI)

    While 1
        $Msg = GUIGetMsg()
        If $Msg = -3 Then ExitLoop
        For $i = 1 To 3
            If $Msg = $LinkLabel[$i] Then
                $LinkVisitedColor[$i] = 0xAC00A9
                GUICtrlSetColor($LinkLabel[$i], $LinkVisitedColor[$i])
                ShellExecute(Eval("URL" & $i))
            EndIf
        Next
        If WinActive($GUI) Then
            For $i = 1 To 3
                ControlHover($GUI, $LinkLabel[$i], $i, $CurIsOnCtrlArr, 0xFF0000, $LinkVisitedColor[$i])
            Next
        EndIf
    WEnd
    WinSetState($Parent, "", @SW_ENABLE)
    GUIDelete($GUI)
    Opt("GUIOnEventMode", $OldEventOpt)
    Opt("RunErrorsFatal", $OldRunErrOpt)
EndFunc

Func ControlHover($hWnd, $CtrlID, $CtrlNum, ByRef $CurIsOnCtrlArr, $HoverColor=0xFF0000, $LinkColor=0x0000FF)
    Local $CursorCtrl = GUIGetCursorInfo($hWnd)
    ReDim $CurIsOnCtrlArr[UBound($CurIsOnCtrlArr)+1]
    If $CursorCtrl[4] = $CtrlID And $CurIsOnCtrlArr[$CtrlNum] = 1 Then
        GUICtrlSetFont($CtrlID, 9, 400, 6)
        GUICtrlSetColor($CtrlID, $HoverColor)
        $CurIsOnCtrlArr[$CtrlNum] = 0
    ElseIf $CursorCtrl[4] <> $CtrlID And $CurIsOnCtrlArr[$CtrlNum] = 0 Then
        GUICtrlSetFont($CtrlID, 9, 400, 0)
        GUICtrlSetColor($CtrlID, $LinkColor)
        $CurIsOnCtrlArr[$CtrlNum] = 1
    EndIf
EndFunc

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 3 months later...
Posted

The solution for me was:

Opt("GUIOnEventMode", 1)

Dim $about = GUICreate([...])
GUISetOnEvent($GUI_EVENT_CLOSE, "HideInfo", $about)

Func HideInfo()
    GUISetState(@SW_HIDE, $about)
EndFunc

It seems it can only be achieved with Opt("GUIOnEventMode", 1).

  • 1 month later...
Posted

  jackit said:

Zedna, can I modify your 'About' GUI and use in my app?

Of course Yes :)

There was some disccusion about licences of code posted on the forum

and somebody said something like: 

  Quote

Everything posted on the forum can be used without permission

If author didn't want others use his code he wouldn't post his code on the forum.

So take it/use it/be happy with it :)

Posted

this is a very simple solution

if $msg = $about then
$child1 = GUICreate("About",220, 220,-1,-1,-1,$WS_EX_TOOLWINDOW,$parent)
$font = "Ariel"
Opt("RunErrorsFatal",0)
GUICtrlCreateLabel("My Program",50,30,150,30)
GUICtrlSetFont(-1,10,400,$font)
GUICtrlCreateIcon("my icon.ico",-1,85,65,48,48)
GUICtrlCreateLabel("Written By Me", 55,120,150,30)
GUICtrlSetFont (-1,10, 400, $font)
$aboutok = GUICtrlCreateButton ("OK",75,170,75,25)
GUISetState()
Do
$msg1 = GUIGetMsg()
if $msg1 = $aboutok then
ExitLoop
endif
Until $msg1 = $GUI_EVENT_CLOSE
GUIDelete($child1)
endif
[u]You can download my projects at:[/u] Pulsar Software
Posted

  Quote

this line doesn't seem to work:

Try this:

Run(@ComSpec & ' /c start mailto:author@somewhere.com?subject=Something', '', @SW_HIDE)

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  Quote

It doesn't work either

And this one?:

ShellExecute("mailto:author@somewhere.com?subject=Something")

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  Quote

which part of your 'About' script made the window 'always on top' as well as 'tabless'(taskbar)? And it only closes when the user clicks on OK or the X button?

It's not have an "Always on top" attribute, it's just created as child for main GUI window (using last parametr in GuiCreate() Func as handle to parent Gui).

And the 'tabless effect' is because it using $WS_EX_TOOLWINDOW ExStyle (0x00000080), you can pass then $WS_EX_APPWINDOW ExStyle to _About() func to display the window on taskbar.

BTW, my example here is old and it have some issues (such as CPU increesing), i will post my new example shortly (in the Examples forum).

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted
  Quote

How do I apply it?

I not sure what you want to apply? just add the style $WS_EX_TOOLWINDOW as ExStyle after BitOr if you do not like that the app will be displayed on the taskbar.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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
  • Recently Browsing   0 members

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