#include-once
#include <winapi.au3>

; #FUNCTION# =========================================================================================================
; Name...........: GUICtrlGetType
; Description ...: Retrieves the Typs of the control.
; Syntax.........: GUICtrlGetType($iControlID)
; Parameters ....: $iControlID - A valid control ID.
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Returns an string with the type.
;                  Failure - Returns the winapi erroc
; Author ........: guinness & additional information from Tigger1975.
; Example........; No
;=====================================================================================================================

func GUICtrlGetType($iControlID)
	Local $sType = _WinAPI_GetClassName($iControlID)
	Local $aStyle
	Switch $sType
		case "Button"
			$aStyle = GUICtrlGetStyle($iControlID)
			switch $aStyle[0]
				Case 0003
					$sType = "Checkbox"
			EndSwitch
	EndSwitch
	Return $sType
EndFunc


; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
; #FUNCTION# =========================================================================================================
; Name...........: GUICtrlGetStyle
; Description ...: Retrieves the Styles/ExStyles value(s) of the control.
; Syntax.........: GUICtrlGetStyle($iControlID)
; Parameters ....: $iControlID - A valid control ID.
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Returns an Array[2] = [Style, ExStyle] with the Styles/ExStyles value(s).
;                  Failure - Returns an Array with -1 as the 0 & 1 Index's.
; Author ........: guinness & additional information from Melba23.
; Example........; Yes
;=====================================================================================================================
Func GUICtrlGetStyle($iControlID)
    Local $aArray[2] = [-1, -1], $aExStyle, $aStyle, $hControl = GUICtrlGetHandle($iControlID)
    $aStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hControl, "int", 0xFFFFFFF0)
    If Not @error Then
        $aArray[0] = Hex($aStyle[0], 4)
	Else
		Return SetError(@error,1,"")
    EndIf
    $aExStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hControl, "int", 0xFFFFFFEC)
    If Not @error Then
        $aArray[1] = Hex($aExStyle[0], 8)
	Else
		Return SetError(@error,2,"")
    EndIf
    Return $aArray
EndFunc   ;==>GUICtrlGetStyle
