#include-once
#include <GUIconstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WinAPIEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Color.au3>
#include <ColorConstants.au3>
#include "StringSize.au3"

#comments-start

Author:
xTcisloVe

Requierements:
	StringSizeUDF made by Melba23 - Download at: https://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/

Description:
	Customizable Message Box, which scales its size depending on the parameters set.

Syntax:
	_sMsgBox($sTitle, $sButtons, $sText, $aParameter, $sDefaultButton, $sTimeout, $iButtonWidth, $iButtonHeight, $iButtonSeperator, $iLeftRightSpace, $iButtonBottomSpace, $sButtonStyle, $iLabelTopBottomSpace, $sLabelStyle, $sMsgBoxBkClr, $sButtonBkClr, $sButtonTxClr, $sLabelBkClr, $sLabelTxClr, $iTransparency, $sIcon, $iResizeMethod)

Parameter:
	-$sTitle				- The Title your message box should have.

	-$sButtons				- The Buttons you like.
							- Choose the Buttons you like: "Yes;No;Maybe;Exit"
							- Or choose one of the following default buttons:
							- $MB_OK = 0 ; One push button: OK
							- $MB_OKCANCEL = 1 ; Two push buttons: OK and Cancel
							- $MB_ABORTRETRYIGNORE = 2 ; Three push buttons: Abort, Retry, and Ignore
							- $MB_YESNOCANCEL = 3 ; Three push buttons: Yes, No, and Cancel
							- $MB_YESNO = 4 ; Two push buttons: Yes and No
							- $MB_RETRYCANCEL = 5 ; Two push buttons: Retry and Cancel
							- $MB_CANCELTRYCONTINUE = 6 ; Three buttons: Cancel, Try Again and Continue

	-$sText					- The Text your message box should show.
							- Use &@CRLF or &@LF for Line Breaks.
							- If a line is too long for the selected settings, the message box will be resized. (3 Methods)
	[Optional]
	-$aParameter			- Every following parameter can also be set here, in just one command.
							- Use it like this: "ButtonWidth=200;Transparency=10"
							- See below for the syntax for every parameter.

	-$sDefaultButton		- The default push button for your msgbox.
							- Use it like :
							- _sMsgBox("Test", "Yes;No", "Test", "", 1)
							- _sMsgBox("Test", "Yes;No", "Test", "", "Yes")
							- _sMsgBox("Test", "Yes;No", "Test", "db=1")
							- _sMsgBox("Test", "Yes;No", "Test", "DefaultButton=Yes")

	-$sTimeout				- The Autoclose timeout or a button timeout.
							- For Autoclose use it like:
							- _sMsgBox("Test", "Yes;No", "Test", "", "", 10)
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "10")
							- _sMsgBox("Test", "Yes;No", "Test", "to=10")
							- _sMsgBox("Test", "Yes;No", "Test", "Timeout=10")
							- For Button timeout use it like:
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "1,10")
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "Yes,10")
							- _sMsgBox("Test", "Yes;No", "Test", "to=1,10")
							- _sMsgBox("Test", "Yes;No", "Test", "Timeout=Yes,10")

	-$iButtonWidth			- Desired Button Width. Use it like:
							- Default or "" = 100
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", 200)
							- _sMsgBox("Test", "Yes;No", "Test", "bw=200")
							- _sMsgBox("Test", "Yes;No", "Test", "ButtonWidth=200")

	-$iButtonHeight			- Desired Button Height. Use it like:
							- Default or "" = 30
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", 40)
							- _sMsgBox("Test", "Yes;No", "Test", "bh=40")
							- _sMsgBox("Test", "Yes;No", "Test", "ButtonHeight=40")

	-$iButtonSeperator		- Desired Button Seperator. Use it like:
							- Default or "" = 15
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", 20)
							- _sMsgBox("Test", "Yes;No", "Test", "bs=20")
							- _sMsgBox("Test", "Yes;No", "Test", "ButtonSperator=20")

	-$iLeftRightSpace		- Desired Button Space to the left and right of the Message Box. Use it like:
							- Default or "" = 15
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", 20)
							- _sMsgBox("Test", "Yes;No", "Test", "lrs=20")
							- _sMsgBox("Test", "Yes;No", "Test", "LeftRightSpace=20")

	-$iButtonBottomSpace	- Desired Space to the bottom of the Message Box to the buttons. Use it like:
							- Default or "" = 15
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", 20)
							- _sMsgBox("Test", "Yes;No", "Test", "bbs=20")
							- _sMsgBox("Test", "Yes;No", "Test", "ButtonBottomSpace=20")

	-$sButtonStyle			- Desired Button Style. Use it like:
							- Default or "" = 0.
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", 1)
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "Center")
							- _sMsgBox("Test", "Yes;No", "Test", "bst=1")
							- _sMsgBox("Test", "Yes;No", "Test", "ButtonStyle=Center")
							- Possible Styles: 1=Center, 2=Bottom, 3=Multiline, 4=Top, 5=VCenter and 6=Flat.

	-$iLabelTopBottomSpace	- Desired Space to the bottom of the Message Box to the buttons. Use it like:
							- Default or "" = 15
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", 20)
							- _sMsgBox("Test", "Yes;No", "Test", "ltbs=20")
							- _sMsgBox("Test", "Yes;No", "Test", "LabelTopBottomSpace=20")

	-$sLabelStyle			- Desired Label Style. Use it like:
							- Default or "" = Align Left.
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", 1)
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "Center")
							- _sMsgBox("Test", "Yes;No", "Test", "lst=1")
							- _sMsgBox("Test", "Yes;No", "Test", "LabelStyle=Center")
							- Possible Styles: 1=Center, 2=Right and 3=Sunken.

	-$sMsgBoxBkClr			- Desired Msgbox Background Color. Use it like:
							- Default or "" = Windows Classic Style.
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", $COLOR_AQUA)
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "mbc=0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "MsgBoxBkColor=0x00FFFF")
							- Possible Colors:
									$COLOR_AQUA = 0x00FFFF
									$COLOR_BLACK = 0x000000
									$COLOR_BLUE = 0x0000FF
									$COLOR_CREAM = 0xFFFBF0
									$COLOR_FUCHSIA = 0xFF00FF
									$COLOR_GRAY = 0x808080
									$COLOR_GREEN = 0x008000
									$COLOR_LIME = 0x00FF00
									$COLOR_MAROON = 0x8B1C62
									$COLOR_MEDBLUE = 0x0002C4
									$COLOR_MEDGRAY = 0xA0A0A4
									$COLOR_MONEYGREEN = 0xC0DCC0
									$COLOR_NAVY = 0x000080
									$COLOR_OLIVE = 0x808000
									$COLOR_PURPLE = 0x800080
									$COLOR_RED = 0xFF0000
									$COLOR_SILVER = 0xC0C0C0
									$COLOR_SKYBLUE = 0xA6CAF0
									$COLOR_TEAL = 0x008080
									$COLOR_WHITE = 0xFFFFFF
									$COLOR_YELLOW = 0xFFFF00
									$CLR_NONE = 0xFFFFFFFF
									$CLR_DEFAULT = 0xFF000000

	-$sButtonBkClr			- Desired Button Background Color. Use it like:
							- Default or "" = Windows Classic Style.
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", $COLOR_AQUA)
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "bbc=0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "ButtonBkColor=0x00FFFF")

	-$sButtonTxClr			- Desired Button Text Color. Use it like:
							- Default or "" = Windows Classic Style.
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", $COLOR_AQUA)
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", "0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "btc=0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "ButtonTxColor=0x00FFFF")

	-$sLabelBkClr			- Desired Label Background Color. Use it like:
							- Default or "" = Windows Classic Style.
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", "", $COLOR_AQUA)
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "lbc=0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "LabelBkColor=0x00FFFF")

	-$sLabelTxClr			- Desired Label TextColor. Use it like:
							- Default or "" = Windows Classic Style.
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", $COLOR_AQUA)
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "ltc=0x00FFFF")
							- _sMsgBox("Test", "Yes;No", "Test", "LabelTxColor=0x00FFFF")

	-$iTransparency			- Desired Msg Box Transparency. Use it like:
							- Default or "" = 0 % which means: solid - 100 % would mean: invisible.
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 25)
							- _sMsgBox("Test", "Yes;No", "Test", "tr=25")
							- _sMsgBox("Test", "Yes;No", "Test", "Transparency=25")

	-$sIcon					- Desired Msg Box Icon. Use it like:
							- Default or "" = 1 which means default logo. 0 = No Logo.
							- Or a valid file path to an ico file like: "D:\Batch Space\ICON\Headset.ico"
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "D:\Batch Space\ICON\Headset.ico")
							- _sMsgBox("Test", "Yes;No", "Test", "ICON=D:\Batch Space\ICON\Headset.ico")
							- _sMsgBox("Test", "Yes;No", "Test", "Icon=0")

	-$iResizeMethod			- The method to resize the message box in case the text is too long for selected parameters.
							- Default or "" = 1 = Resize Left Right Space, 2 = Resize Buttons, 3 =  Resize Button Seperators.
							- Or a valid file path to an ico file like: "D:\Batch Space\ICON\Headset.ico"
							- _sMsgBox("Test", "Yes;No", "Test", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 1)
							- _sMsgBox("Test", "Yes;No", "Test", "rm=2")
							- _sMsgBox("Test", "Yes;No", "Test", "ResizeMethod=3")

							- To change every Value do it like:
							_sMsgBox("Test", "Yes;No", "Test", "Yes", "", "No,10", 200, 40, 20, 20, 20, "Top", 20, "Center", "0x00FFFF", "0x00FFFF", "0x00FFFF", "0x00FFFF", "0x00FFFF", 25, "D:\Batch Space\ICON\Headset.ico", 2)

							- Different way:
								_sMsgBox("Test", "Yes;No", "Test", "db=1;to=10;bw=200;bh=40;bs=20;lrs=20;bbs=20;bst=1;ltbs=20;lst=1;mbc=0x00FFFF;bbc=0x00FFFF;btc=0x00FFFF;lbc=0x00FFFF;ltc=0x00FFFF;tr=25;Icon=D:\Batch Space\ICON\Headset.ico;rm=2")

							-Only like to change the icon?:
								_sMsgBox("Test", "Yes;No", "Test", "Icon=D:\Batch Space\ICON\Headset.ico")

	-Return Values:			- If succesfull @error will be 0, if not @error will be 1. @extended will be -1
							- @extended will hold the Button number you pressed.
							- @extended will be 0 if u close the message box or the autoclose timeout close it.
							- If u assign a string to the msgbox u will get the Button Name you pressed.

	Example:

	local $Message = _sMsgBox("Test", 6, "Continue?")
		if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")

#comments-end

Func _sMsgBox($sTitle, _
		$sButtons, _
		$sText, _
		$aParameter = "", _
		$sDefaultButton = "", _
		$sTimeout = "", _
		$iButtonWidth = "", _
		$iButtonHeight = "", _
		$iButtonSeperator = "", _
		$iLeftRightSpace = "", _
		$iButtonBottomSpace = "", _
		$sButtonStyle = "", _
		$iLabelTopBottomSpace = "", _
		$sLabelStyle = "", _
		$sMsgBoxBkClr = "", _
		$sButtonBkClr = "", _
		$sButtonTxClr = "", _
		$sLabelBkClr = "", _
		$sLabelTxClr = "", _
		$iTransparency = "", _
		$sIcon = "", _
		$iResizeMethod = "")

	If Opt("GUIOnEventMode", 0) Then
		Opt("GUIOnEventMode", 1)
		Local $sOnEventMode
	EndIf

	If IsInt($sText) Then $sText = "" & $sText & ""

	If ($aParameter = "0") Or ($aParameter = "") Then $aParameter = Default

	If $aParameter <> Default Then
		Local $aSearch = [[18, 18], _
						["DB", "DefaultButton"], _
						["TO", "Timeout"], _
						["BW", "ButtonWidth"], _
						["BH", "ButtonHeight"], _
						["BS", "ButtonSeperator"], _
						["LRS", "LeftRightSpace"], _
						["BBS", "ButtonBottomSpace"], _
						["BST", "ButtonStyle"], _
						["LTBS", "LabelTopBottomSpace"], _
						["LST", "LabelStyle"], _
						["MBC", "MsgBoxBkColor"], _
						["BBC", "ButtonBkColor"], _
						["BTC", "ButtonTxColor"], _
						["LBC", "LabelBkColor"], _
						["LTC", "LabelTxColor"], _
						["TR", "Transparency"], _
						["ICON", "Icon"], _
						["RM", "ResizeMethod"]]
		$aParameter = StringSplit($aParameter, ";")
		For $i = 1 To $aParameter[0]
			$x = StringSplit($aParameter[$i], "=")
			$y = _ArraySearch($aSearch, $x[1], 0, 0, 0, 2)
			If $y = -1 Then ExitLoop
			If $y = 1 And $sDefaultButton = "" Then $sDefaultButton = $x[2]
			If $y = 2 And $sTimeout = "" Then $sTimeout = $x[2]
			If $y = 3 And $iButtonWidth = "" Then $iButtonWidth = $x[2]
			If $y = 4 And $iButtonHeight = "" Then $iButtonHeight = $x[2]
			If $y = 5 And $iButtonSeperator = "" Then $iButtonSeperator = $x[2]
			If $y = 6 And $iLeftRightSpace = "" Then $iLeftRightSpace = $x[2]
			If $y = 7 And $iButtonBottomSpace = "" Then $iButtonBottomSpace = $x[2]
			If $y = 8 And $sButtonStyle = "" Then $sButtonStyle = $x[2]
			If $y = 9 And $iLabelTopBottomSpace = "" Then $iLabelTopBottomSpace = $x[2]
			If $y = 10 And $sLabelStyle = "" Then $sLabelStyle = $x[2]
			If $y = 11 And $sMsgBoxBkClr = "" Then $sMsgBoxBkClr = $x[2]
			If $y = 12 And $sButtonBkClr = "" Then $sButtonBkClr = $x[2]
			If $y = 13 And $sButtonTxClr = "" Then $sButtonTxClr = $x[2]
			If $y = 14 And $sLabelBkClr = "" Then $sLabelBkClr = $x[2]
			If $y = 15 And $sLabelTxClr = "" Then $sLabelTxClr = $x[2]
			If $y = 16 And $iTransparency = "" Then $iTransparency = $x[2]
			If $y = 17 And $sIcon = "" Then $sIcon = $x[2]
			If $y = 18 And $iResizeMethod = "" Then $iResizeMethod = $x[2]
		Next
		If ($y = -1) Then
			Return SetError(1, -1, _sMsgBoxError($x[1] & '=' & $x[2], _ArrayToString($aSearch, @TAB&'or'&@TAB, 1, 18), $x[1] & '=' & $x[2]))
		EndIf
	EndIf

	If ($sDefaultButton = Default) Or ($sDefaultButton = "") Then $sDefaultButton = 0

	If ($sTimeout = Default) Or ($sTimeout = "") Then $sTimeout = 0

	If ($iButtonWidth = Default) Or ($iButtonWidth = "") Then $iButtonWidth = 100

	If ($iButtonHeight = Default) Or ($iButtonHeight = "") Then $iButtonHeight = 30

	If ($iButtonSeperator = Default) Or ($iButtonSeperator = "") Then $iButtonSeperator = 15

	If ($iLeftRightSpace = Default) Or ($iLeftRightSpace = "") Then $iLeftRightSpace = 15

	If ($iButtonBottomSpace = Default) Or ($iButtonBottomSpace = "") Then $iButtonBottomSpace = 15

	If ($sButtonStyle = Default) Or ($sButtonStyle = "") Then $sButtonStyle = 0

	If ($iLabelTopBottomSpace = Default) Or ($iLabelTopBottomSpace = "") Then $iLabelTopBottomSpace = 15

	If ($sLabelStyle = Default) Or ($sLabelStyle = "") Then $sLabelStyle = 0

	If ($iTransparency = Default) Or ($iTransparency = "") Then $iTransparency = 0

	If ($sIcon = Default) Or ($sIcon = "") Then $sIcon = 1

	If ($iResizeMethod = Default) Or ($iResizeMethod = "") Then $iResizeMethod = 1

	If ($sMsgBoxBkClr = Default) Or ($sMsgBoxBkClr = "") Then $sMsgBoxBkClr = 0

	If ($sButtonBkClr = Default) Or ($sButtonBkClr = "") Then $sButtonBkClr = 0

	If ($sButtonTxClr = Default) Or ($sButtonTxClr = "") Then $sButtonTxClr = 0

	If ($sLabelBkClr = Default) Or ($sLabelBkClr = "") Then $sLabelBkClr = 0

	If ($sLabelTxClr = Default) Or ($sLabelTxClr = "") Then $sLabelTxClr = 0

	If IsInt($sButtons) Or ($sButtons = Default) Or ($sButtons = "") Then
		If ($sButtons > 6) Or ($sButtons < 0) And ($sButtons <> Default) Then
			Return SetError(1, -1, _sMsgBoxError("$sButtons", '0-6 or own Buttons like: "Yes;No"', $sButtons))
		Else
			If ($sButtons = 0) Or ($sButtons = Default) Or ($sButtons = "") Then $sButtons = "OK"
			If ($sButtons = 1) Then $sButtons = "OK;Cancel"
			If ($sButtons = 2) Then $sButtons = "Abort;Retry;Ignore"
			If ($sButtons = 3) Then $sButtons = "Yes;No;Cancel"
			If ($sButtons = 4) Then $sButtons = "Yes;No"
			If ($sButtons = 5) Then $sButtons = "Retry;Cancel"
			If ($sButtons = 6) Then $sButtons = "Cancel;Try Again;Continue"
		EndIf
	EndIf

	Local $aButton_ = StringSplit($sButtons, ";")

	If ($sDefaultButton <> 0) Or Not StringIsDigit($sDefaultButton) Then
		For $i = 1 To $aButton_[0]
			If ($aButton_[$i] = $sDefaultButton) Or ($i = $sDefaultButton) Then ExitLoop
		Next
		If ($i >= $aButton_[0] + 1) Then
			Return SetError(1, -1, _sMsgBoxError("$sDefaultButton", 'Choose one of your Buttons: '&@LF&_ArrayToString($aButton_, @LF, 1), $sDefaultButton))
		EndIf
		$sDefaultButton = $i
	EndIf

	If StringInStr($sTimeout, ",") Or Not StringIsDigit($sTimeout) Then
		Local $aTimeout_ = StringSplit($sTimeout, ",")
		If $aTimeout_[0] <> 2 Or Not StringIsDigit($aTimeout_[2]) Then
			Return SetError(1, -1, _sMsgBoxError("$sTimeout", '10 or "10" or "1,10" or "Yes,10". Default=0', $sTimeout))
		Else
			For $i = 1 To $aButton_[0]
				If $aButton_[$i] = $aTimeout_[1] Or $i = $aTimeout_[1] Then ExitLoop
			Next
			If ($i > $aButton_[0]) Then
				Return SetError(1, -1, _sMsgBoxError("$sTimeoutButton", 'Choose one of your Buttons: '&@LF&_ArrayToString($aButton_, @LF, 1), $aTimeout_[1]))
			Else
				Local $sTimeoutButton = $i
				$sTimeout = $aTimeout_[2]
			EndIf
		EndIf
	EndIf
	If ($sTimeout <> 0) Then
		Local $sTimeoutInit = TimerInit()
		Local $sTimeoutInitVar = TimerInit()
		Local $sTimeoutMs = $sTimeout * 1000
		$sTimeout -= 1
	EndIf

	If Not StringIsDigit($iButtonWidth) Then
		Return SetError(1, -1, _sMsgBoxError("$iButtonWidth", 'Choose a number. Default=100', $iButtonWidth))
	EndIf

	If Not StringIsDigit($iButtonHeight) Then
		Return SetError(1, -1, _sMsgBoxError("$iButtonHeight", 'Choose a number. Default=30', $iButtonHeight))
	EndIf

	If Not StringIsDigit($iButtonSeperator) Then
		Return SetError(1, -1, _sMsgBoxError("$iButtonSeperator", 'Choose a number. Default=15', $iButtonSeperator))
	EndIf

	If Not StringIsDigit($iLeftRightSpace) Then
		Return SetError(1, -1, _sMsgBoxError("$iLeftRightSpace", 'Choose a number. Default=15', $iLeftRightSpace))
	EndIf

	If Not StringIsDigit($iButtonBottomSpace) Then
		Return SetError(1, -1, _sMsgBoxError("$iButtonBottomSpace", 'Choose a number. Default=15', $iButtonBottomSpace))
	EndIf

	If ($sButtonStyle < 0) Or ($sButtonStyle > 6) Or Not StringIsDigit($sButtonStyle) Then
		If ($sButtonStyle <> "Center") And ($sButtonStyle <> "Bottom") And ($sButtonStyle <> "Multiline") And ($sButtonStyle <> "Top") And ($sButtonStyle <> "VCenter") And ($sButtonStyle <> "Flat") Then
			Return SetError(1, -1, _sMsgBoxError("$sButtonStyle", 'Choose a Style: 1-6'&@LF&'"Center" "Bottom" "Multiline" "Top" "VCenter" "Flat"', $sButtonStyle))
		EndIf
		If ($sButtonStyle = "Center") Or ($sButtonStyle = 1) Then $sButtonStyle = $BS_CENTER
		If ($sButtonStyle = "Bottom") Or ($sButtonStyle = 2) Then $sButtonStyle = $BS_BOTTOM
		If ($sButtonStyle = "Multiline") Or ($sButtonStyle = 3) Then $sButtonStyle = $BS_MULTILINE
		If ($sButtonStyle = "Top") Or ($sButtonStyle = 4) Then $sButtonStyle = $BS_TOP
		If ($sButtonStyle = "VCenter") Or ($sButtonStyle = 5) Then $sButtonStyle = $BS_VCENTER
		If ($sButtonStyle = "Flat") Or ($sButtonStyle = 6) Then $sButtonStyle = $BS_FLAT
	EndIf

	If Not StringIsDigit($iLabelTopBottomSpace) Then
		Return SetError(1, -1, _sMsgBoxError("$iLabelTopBottomSpace", 'Choose a number. Default=15', $iLabelTopBottomSpace))
	EndIf

	If ($sLabelStyle < 0) Or ($sLabelStyle > 3) Or Not StringIsDigit($sLabelStyle) Then
		If $sLabelStyle <> "Center" And $sLabelStyle <> "Right" And $sLabelStyle <> "Sunken" Then
			Return SetError(1, -1, _sMsgBoxError("$sButtonStyle", 'Choose a Style: 1-3'&@LF&'"Center" "Right" "Sunken"', $sButtonStyle))
		EndIf
		If $sLabelStyle = "Center" Then $sLabelStyle = 1
		If $sLabelStyle = "Right" Then $sLabelStyle = 2
		If $sLabelStyle = "Sunken" Or $sLabelStyle = 3 Then $sLabelStyle = 4096
		If $sLabelStyle = 0 Then $sLabelStyle = -1
	EndIf

	If ($sMsgBoxBkClr <> "0") And Not StringRegExp($sMsgBoxBkClr, '^0x[[:xdigit:]]+$') Then
		Return SetError(1, -1, _sMsgBoxError("$sMsgBoxBkClr", 'Choose a hex color code, like: 0x00FFFF.'&@LF&'Default=0xFF0000 - Windows Classic Style.', $sMsgBoxBkClr))
	EndIf

	If $sButtonBkClr <> "0" And Not StringRegExp($sButtonBkClr, '^0x[[:xdigit:]]+$') Then
		Return SetError(1, -1, _sMsgBoxError("$sButtonBkClr", 'Choose a hex color code, like: 0x00FFFF.'&@LF&'Default=0xFF0000 - Windows Classic Style.', $sButtonBkClr))
	EndIf

	If $sButtonTxClr <> "0" And Not StringRegExp($sButtonTxClr, '^0x[[:xdigit:]]+$') Then
		Return SetError(1, -1, _sMsgBoxError("$sButtonTxClr", 'Choose a hex color code, like: 0x00FFFF.'&@LF&'Default=0xFF0000 - Windows Classic Style.', $sButtonTxClr))
	EndIf

	If $sLabelBkClr <> "0" And Not StringRegExp($sLabelBkClr, '^0x[[:xdigit:]]+$') Then
		Return SetError(1, -1, _sMsgBoxError("$sLabelBkClr", 'Choose a hex color code, like: 0x00FFFF.'&@LF&'Default=0xFF0000 - Windows Classic Style.', $sLabelBkClr))
	EndIf

	If $sLabelTxClr <> "0" And Not StringRegExp($sLabelTxClr, '^0x[[:xdigit:]]+$') Then
		Return SetError(1, -1, _sMsgBoxError("$sLabelTxClr", 'Choose a hex color code, like: 0x00FFFF.'&@LF&'Default=0xFF0000 - Windows Classic Style.', $sLabelTxClr))
	EndIf

	If Not StringIsDigit($iTransparency) Or ($iTransparency < 0) Or ($iTransparency > 100) Then
		Return SetError(1, -1, _sMsgBoxError("$iTransparency", 'Choose % 0 - 100. Default=0 > Solid.', $iTransparency))
	Else
		$iTransparency = (100 - $iTransparency) / 100 * 255
	EndIf

	If Not StringIsDigit($sIcon) Or ($sIcon < 0) Or ($sIcon > 1) Then
		If Not FileExists($sIcon) Or StringRight($sIcon, 4) <> ".ico" Then
			If ($sIcon <> 0) Or ($sIcon <> 1) Then
			Return SetError(1, -1, _sMsgBoxError("$sIcon", 'Choose a valid .ico filepath.'&@LF&'Default=1 or 0 for no icon.', $sIcon))
			EndIf
		EndIf
	EndIf

	If Not StringIsDigit($iResizeMethod) Or ($iResizeMethod < 1) Or ($iResizeMethod > 3) Then
		Return SetError(1, -1, _sMsgBoxError('ResizeMethod has to be a number.(1-3)-Default=1', $iTransparency))
	EndIf

	Local $iGUIWidth = $iLeftRightSpace + ($aButton_[0] * $iButtonWidth) + (($aButton_[0] - 1) * $iButtonSeperator) + $iLeftRightSpace
	Local $iMaxLabelWidth = $iGUIWidth - $iLeftRightSpace - $iLeftRightSpace

	Local $aLabelSize_ = _StringSize($sText, Default, Default, Default, Default, $iMaxLabelWidth)
	If @error = 3 Or $aLabelSize_[2] >= $iMaxLabelWidth Then
		$aLabelSize_ = _StringSize($sText, Default, Default, Default, Default)
		$iMaxLabelWidth = $aLabelSize_[2]
		$iGUIWidth = $iMaxLabelWidth + $iLeftRightSpace + $iLeftRightSpace
		Local $Resize
	EndIf

	Local $iGUIHeight = $iLabelTopBottomSpace + $aLabelSize_[3] + $iLabelTopBottomSpace + $iButtonHeight + $iButtonBottomSpace

	Local $hGUI = GUICreate($sTitle, $iGUIWidth, $iGUIHeight, -1, -1, -1, $WS_EX_DLGMODALFRAME)
	If $sMsgBoxBkClr <> 0 Then GUISetBkColor($sMsgBoxBkClr, $hGUI)

	Switch $sIcon
		Case 0, "0"
			_WinAPI_DestroyIcon(_WinAPI_GetClassLongEx($hGUI, $GCL_HICON))
			_WinAPI_SetClassLongEx($hGUI, $GCL_HICON, 0)
			_WinAPI_SetClassLongEx($hGUI, $GCL_HICONSM, 0)
		Case 1, "1"
			Local $sWow64 = ""
			If @AutoItX64 Then $sWow64 = "\Wow6432Node"
			$sIcon = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\icons\au3.ico"
	EndSwitch

	If Not IsInt($sIcon) Then GUISetIcon($sIcon)

	GUICtrlCreateLabel($aLabelSize_[0], $iLeftRightSpace, $iLabelTopBottomSpace, $iMaxLabelWidth, $aLabelSize_[3], $sLabelStyle)
	If $sLabelBkClr <> 0 Then GUICtrlSetBkColor(-1, $sLabelBkClr)
	If $sLabelTxClr <> 0 Then GUICtrlSetColor(-1, $sLabelTxClr)

	If IsDeclared("Resize") Then
		If $iResizeMethod = 1 Then $iLeftRightSpace = (($iGUIWidth - ($aButton_[0] * $iButtonWidth) - (($aButton_[0] - 1) * $iButtonSeperator))) / 2
		If $iResizeMethod = 2 Then $iButtonWidth = ($iMaxLabelWidth - ($aButton_[0] - 1) * $iButtonSeperator) / $aButton_[0]
		If $iResizeMethod = 3 Then $iButtonSeperator = ($aLabelSize_[2] - ($aButton_[0] * $iButtonWidth)) / ($aButton_[0] - 1)
	EndIf

	Local $iButtonTop = $iLabelTopBottomSpace + $aLabelSize_[3] + $iLabelTopBottomSpace

	$First_Button = GUICtrlCreateDummy()
	For $i = 1 To $aButton_[0]
		$x = $iLeftRightSpace + (($i - 1) * $iButtonWidth) + (($i - 1) * $iButtonSeperator)
		If $i = $sDefaultButton Then
			If IsDeclared("sTimeoutButton") And $i = $sTimeoutButton Then
				Local $hTimeoutButton = GUICtrlCreateButton($aButton_[$i], $x, $iButtonTop, $iButtonWidth, $iButtonHeight, BitOR($BS_DEFPUSHBUTTON, $sButtonStyle))
			Else
				GUICtrlCreateButton($aButton_[$i], $x, $iButtonTop, $iButtonWidth, $iButtonHeight, BitOR($BS_DEFPUSHBUTTON, $sButtonStyle))
			EndIf
		Else
			If IsDeclared("sTimeoutButton") And $i = $sTimeoutButton Then
				Local $hTimeoutButton = GUICtrlCreateButton($aButton_[$i], $x, $iButtonTop, $iButtonWidth, $iButtonHeight, $sButtonStyle)
			Else
				GUICtrlCreateButton($aButton_[$i], $x, $iButtonTop, $iButtonWidth, $iButtonHeight, $sButtonStyle)
			EndIf
			If $sButtonBkClr <> 0 Then GUICtrlSetBkColor(-1, $sButtonBkClr)
			If $sButtonTxClr <> 0 Then GUICtrlSetColor(-1, $sButtonTxClr)
		EndIf
	Next
	$Last_Button = GUICtrlCreateDummy()

	GUISetState(@SW_SHOW, $hGUI)
		If $iTransparency <> 255 Then WinSetTrans($hGUI, "", $iTransparency)

	While 1
		$Msg = GUIGetMsg(0)
		Switch $Msg
			Case $GUI_EVENT_CLOSE
				GUIDelete($hGUI)
				Return SetError(0, 0, "Closed-by-User")

			Case $First_Button To $Last_Button
				For $i = 1 To $aButton_[0]
					If $aButton_[$i] = GUICtrlRead($Msg) Then ExitLoop
				Next
				GUIDelete($hGUI)
				If IsDeclared("sOnEventMode") Then Opt("GUIOnEventMode", 0)
				If $i > $aButton_[0] And IsDeclared("sTimeoutButton") Then
					Return SetError(0, $sTimeoutButton, $aButton_[$sTimeoutButton])
				EndIf
				Return SetError(0, $i, $aButton_[$i])
		EndSwitch

		If IsDeclared("sTimeoutInit") Then
			If TimerDiff($sTimeoutInit) >= $sTimeoutMs Then
				GUIDelete($hGUI)
				If IsDeclared("sOnEventMode") Then Opt("GUIOnEventMode", 0)
				If Not IsDeclared("sTimeoutButton") Then Return SetError(0, 0, "Closed-by-Timeout")
				Return SetError(0, $sTimeoutButton, $aButton_[$sTimeoutButton])
			Else
				If TimerDiff($sTimeoutInitVar) >= 1000 Then
					If Not IsDeclared("sTimeoutButton") Then
						WinSetTitle($hGUI, "", "[" & $sTimeout & "] - " & $sTitle)
					Else
						GUICtrlSetData($hTimeoutButton, $aButton_[$sTimeoutButton] & " [" & $sTimeout & "]")
					EndIf
					$sTimeout -= 1
					$sTimeoutInitVar = TimerInit()
				EndIf
			EndIf
		EndIf
	WEnd
EndFunc   ;==>_sMsgBox

Func _sMsgBoxError($sParameter, $sDefault, $sValue)
	Local $Error = 'Error!' & @LF & @LF & 'Wrong Paramter: ' & @LF & $sParameter & @LF & @LF & 'Possible values: ' & @CR & $sDefault & @LF & @LF & 'Your Value: ' & $sValue
	If MsgBox(4, "sMsgBox Error", $Error & @CRLF & @CRLF & "Exit Script?") = 6 Then Exit
	Return $Error
EndFunc   ;==>_sMsgBoxErrorHandling