Aktuell:
C
#include <GUIconstants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>
#include "StringSize.au3"
Example()
exit
Func Example()
$PressedButton = _sMsgBox("Title", "Yes,No,3,4,5,6,7,8,9,10", Default, Default, Default, Default, "This is Line 1" & @LF & @LF & "This is Line 3", 5)
Switch @extended
case -2 ;--> Timer expired.
MsgBox(0, @extended, $PressedButton, 10)
case -1 ;--> Message Box closed with x.
MsgBox(0, @extended, $PressedButton, 10)
case 1 ;--> Yes button pressed.
MsgBox(0, @extended, "You pressed: " & $PressedButton, 10)
case 2 ;--> No button pressed.
MsgBox(0, @extended, "You pressed: " & $PressedButton, 10)
case Else ;--> Any other button pressed.
MsgBox(0, @extended, "You pressed: " & $PressedButton, 10)
EndSwitch
EndFunc
Func _sMsgBox($Title, $Buttons, $Button_Width, $Button_Height, $Button_Seperator, $Edge_Space, $Label_Text, $TimeOut)
if $Buttons = "" Then
MsgBox(0, "ERROR", "ERROR - No Button defined.")
Return "ERROR"
EndIf
If $Title = Default Or $Title = "" Then $Title = "Title"
If $Button_Width = Default Or $Button_Width = "" Then $Button_Width= 100
If $Button_Height = Default Or $Button_Height = "" Then $Button_Height= 30
If $Button_Seperator = Default Or $Button_Seperator = "" Then $Button_Seperator= 15
If $Edge_Space= Default Or $Edge_Space = "" Then $Edge_Space= 15
If $TimeOut = Default Or $TimeOut = "" Then $TimeOut= 0
If $TimeOut <> 0 Then
local $Timer=TimerInit()
local $Time=TimerInit()
local $CurrentTimer = $TimeOut-1, $CurrentTimerTemp
EndIf
local $aButtons = StringSplit($Buttons, ",")
Dim $Button_[($aButtons[0] + 1)]
Local $GUI_Width_Math = $Edge_Space
For $i = 1 To $aButtons[0]
$Button_[$i] = $GUI_Width_Math+$Button_Width+$Button_Seperator
$GUI_Width_Math = $Button_[$i]
Next
local $GUI_Width = $GUI_Width_Math-$Button_Seperator+$Edge_Space
Local $Max_Label_Width = $GUI_Width-$Edge_Space-$Edge_Space
local $Label_StringSize = _StringSize($Label_Text, Default, Default, Default, Default, $Max_Label_Width)
Local $Label_Width = $Label_StringSize[2]
Local $Label_Height = $Label_StringSize[3]
Local $GUI_Height = $Edge_Space+$Label_Height+$Edge_Space+$Button_Height+$Edge_Space
Local $Button_Top = $Edge_Space+$Label_Height+$Edge_Space
Dim $GUI_Button_[($aButtons[0] + 1)]
local $hGUI = GUICreate($Title, $GUI_Width, $GUI_Height)
GUISetStyle(BitOR($WS_CAPTION, $WS_POPUPWINDOW) )
GUICtrlCreateLabel($Label_StringSize[0], $Edge_Space, $Edge_Space, $Label_StringSize[2], $Label_StringSize[3])
local $ButtonMath = $Edge_Space
$Btn_Start = GUICtrlCreateDummy()
For $i = 1 To $aButtons[0]
$x = $ButtonMath
$GUI_Button_[$i] = GUICtrlCreateButton($aButtons[$i], $x, $Button_Top, $Button_Width, $Button_Height)
$ButtonMath = $x + $Button_Width + $Button_Seperator
Next
$Btn_End = GUICtrlCreateDummy()
GUISetState ()
While 1
$Msg = GUIGetMsg(0)
Switch $Msg
Case $GUI_EVENT_CLOSE
GUIDelete($hGUI)
Return SetExtended(-1, "MessageBox closed.")
Case $Btn_Start To $Btn_End
local $Return = GUICtrlRead($Msg)
Return SetExtended($Msg-4, $Return)
EndSwitch
If $TimeOut <> 0 Then
If TimerDiff($Timer) >= $TimeOut*1000 then
GUIDelete($hGUI)
Return SetExtended(-2, "TimeOut expired.")
Else
If TimerDiff($Time) >= 1000 then
WinSetTitle($hGUI, "", "[" & $CurrentTimer & "] - " & $Title)
$CurrentTimerTemp = $CurrentTimer
$CurrentTimer = $CurrentTimerTemp-1
$Time=TimerInit()
EndIf
EndIf
EndIf
Wend
EndFunc
;;;;;;;;;;AUTHOR: XTCISLOVE;;;;;;;;;;
Alles anzeigen
Funktioniert, ist aber nicht ganz richtig oder?