If you set the styles of a control with GUICtrlSetStyle() and happen to forget the styles you set, then why not try GUICtrlGetStyle() To get the Hex value e.g. 00100000 then use this little conversion >> Local $aArray = GUICtrlGetStyle($iLabel)
_GUICtrlGetStyle_Convert($aArray)
_ArrayDisplay($aArray, 'The Style = 0101 & the ExStyle = 00100000'))Function: #include-once
#include <WinAPI.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: GUICtrlGetStyle
; Description ...: Retrieves the Styles/ExStyles value(s) of a control.
; Syntax ........: GUICtrlGetStyle($hWnd)
; Parameters ....: $hWnd - Control ID/Handle to the control
; Return values .: $aArray[2] = [Style, ExStyle]
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func GUICtrlGetStyle($hWnd)
If Not IsHWnd($hWnd) Then
$hWnd = GUICtrlGetHandle($hWnd)
EndIf
Local $aReturn = [_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)]
Return $aReturn
EndFunc ;==>GUICtrlGetStyleExample use of Function: #include <Array.au3> ; Required only for _ArrayDisplay(), but not the UDF!
#include <GUIConstantsEx.au3>
#include 'GUICtrlGetStyle.au3'
Example()
Func Example()
Local $hGUI = GUICreate('GUICtrlGetStyle() Example', 280, 90)
; This label is using 'magic numbers' instead of the constant variables. It's advisable to use $SS_CENTER & $GUI_WS_EX_PARENTDRAG
; instead of 0x0101 & 0x00100000, but this has been done for proof of concept only. See the second _Array display for more details.
Local $iLabel = GUICtrlCreateLabel('This is a Label with $SS_CENTER & $GUI_WS_EX_PARENTDRAG set as the Styles.', 10, 10, 270, 45, 0x0101, 0x00100000) ; $SS_CENTER, $GUI_WS_EX_PARENTDRAG
Local $iButton = GUICtrlCreateButton('GetStyle Array', 95, 55, 85, 25)
GUISetState(@SW_SHOW, $hGUI)
Local $aArray = 0
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $iButton
$aArray = GUICtrlGetStyle($iLabel)
_ArrayDisplay($aArray)
GUICtrlDelete($iLabel)
GUICtrlCreateLabel('This is a NEW Label with $SS_CENTER & $GUI_WS_EX_PARENTDRAG set as the Styles/ExStyles.', 10, 10, 270, 50, $aArray[0], $aArray[1])
; This is the reason why 'magic numbers' were used, so as to see they match the same values in GUICtrlCreateLabel.
$aArray = GUICtrlGetStyle($iLabel)
_GUICtrlGetStyle_Convert($aArray)
_ArrayDisplay($aArray, 'The Style = 0x0101 & the ExStyle = 0x00100000')
EndSwitch
WEnd
GUIDelete($hGUI)
EndFunc ;==>Example
Func _GUICtrlGetStyle_Convert(ByRef $aArray)
If UBound($aArray) = 2 Then
$aArray[0] = '0x' & Hex($aArray[0], 4)
$aArray[1] = '0x' & Hex($aArray[1], 8)
EndIf
EndFunc ;==>_GUICtrlGetStyle_Convert