HtmLayout est un moteur de rendu html/css, avec cette udf il est possible de faire une gui entièrement en html.
il est necessaire de telecharger la dll ici : http://www.terrainformatica.com/htmlayo ... outDLL.zip
► Afficher le texte
Code : Tout sélectionner
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <HtmLayout Constants.au3>
#include-once
Global $aHLelementsfound = 0
Global $HtmLayoutdll = 0
Global $HtmLayoutRef = 0
Global $HandleWindowsAttachEvent = 0
Global $HtmLayoutEvHandler = 0
Global $aHLDOM_error[7]
$aHLDOM_error[0] = "function completed successfully"
$aHLDOM_error[1] = "invalid HWND"
$aHLDOM_error[2] = "invalid HELEMENT"
$aHLDOM_error[3] = "attempt to use HELEMENT which is not marked by HTMLayout_UseElement()"
$aHLDOM_error[4] = "parameter is invalid, e.g. pointer is null"
$aHLDOM_error[5] = "operation failed, e.g. invalid html in HTMLayoutSetElementHtml()"
$aHLDOM_error[6] = "Dllcall error"
; #FUNCTION# ====================================================================================================
; Name...........: _HLStartup
; Description....: Initialize HtmLayout
; Syntax.........: _HLStartup($dll = "HtmLayout.dll")
; Parameters.....: $dll - Path to HtmLayout DLL [Optional]
;
; Return values..: Success - 1
; Failure - 0
; Remarks........:
; ===============================================================================================================
Func _HLStartup($dll = "HtmLayout.dll")
$HtmLayoutRef += 1
If $HtmLayoutRef > 1 Then Return 1
$HtmLayoutdll = DllOpen($dll)
If $HtmLayoutdll = -1 Then Return SetError(1, 0, 0)
Return 1
EndFunc
; #FUNCTION# ====================================================================================================
; Name...........: _HLCreateGui
; Description....: Create HtmLayout Windows
; Syntax.........: _HLCreateGui($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50)
; Parameters.....: $ParentGui - Handle of parent Gui
; $x - [Optional]
; $y - [Optional]
; $w - [Optional]
; $h - [Optional]
;
; Return values..: Success - HTMLayout window handle.
; Failure - 0
; Remarks........:
; ===============================================================================================================
Func _HLCreateGui($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50)
$result = DllCall($HtmLayoutdll, "wstr", "HTMLayoutClassNameW")
If @error Then Return 0
$ClassName = $result[0]
$HtmLayoutHwnd = _WinAPI_CreateWindowEx(0, $ClassName, "", BitOR($WS_CHILD, $WS_VISIBLE, $WS_CLIPCHILDREN), $x, $y, $w, $h, $ParentGui)
Return $HtmLayoutHwnd
EndFunc ;==>_HLCreateGui
; #FUNCTION# ====================================================================================================
; Name...........: _HLLoadFile
; Description....: Load HTML file.
; Syntax.........: _HLLoadFile($HLHwnd, $file)
; Parameters.....: $HLHwnd - HTMLayout window handle.
; $file - File name of an HTML file.
;
; Return values..: Success - 1
; Failure - 0
; Remarks........:
; ===============================================================================================================
Func _HLLoadFile($HLHwnd, $file)
$result = DllCall($HtmLayoutdll, "BOOL", "HTMLayoutLoadFile", "HWND", $HLHwnd, "wstr", $file)
Return $result[0]
EndFunc ;==>_HLLoadFile
; #FUNCTION# ====================================================================================================
; Name...........: _HLLoadHtml
; Description....: Load HTML from memory.
; Syntax.........: _HLLoadHtml($HLHwnd, $String)
; Parameters.....: $HLHwnd - HTMLayout window handle.
; $String - HTML to load.
;
; Return values..: Success - 1
; Failure - 0
; Remarks........:
; ===============================================================================================================
Func _HLLoadHtml($HLHwnd, $String)
$StringSize = StringLen($String)
$result = DllCall($HtmLayoutdll, "BOOL", "HTMLayoutLoadHtml", "HWND", $HLHwnd, "str", $String, "UINT", $StringSize)
Return $result[0]
EndFunc ;==>_HLLoadHtml
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetRootElement
; Description....: Get root DOM element of HTML document.
; Syntax.........: _HLGetRootElement($HLHwnd)
; Parameters.....: $HLHwnd - HTMLayout window handle.
;
; Return values..: Success - Return root element.
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........: Root DOM object is always a 'HTML' element of the document.
; ===============================================================================================================
Func _HLGetRootElement($HLHwnd)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetRootElement", "HWND", $HLHwnd, "ptr*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[2]
EndFunc ;==>_HLGetRootElement
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetChildrenCount
; Description....: Get number of child elements.
; Syntax.........: _HLGetChildrenCount($el)
; Parameters.....: $el - DOM element handle which child elements you need to count
;
; Return values..: Success - Return number of child elements
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetChildrenCount($el)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetChildrenCount", "ptr", $el, "UINT*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[2]
EndFunc ;==>_HLGetChildrenCount
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetNthChild
; Description....: Get handle of Nth child element.
; Syntax.........: _HLGetNthChild($el, $nth)
; Parameters.....: $el - DOM element handle
; $nth - number of the child element
;
; Return values..: Success - Return handle of the child element
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetNthChild($el, $nth)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetNthChild", "ptr", $el, "UINT", $nth-1, "ptr*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[3]
EndFunc ;==>_HLGetNthChild
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetParentElement
; Description....: Get parent element.
; Syntax.........: _HLGetParentElement($el)
; Parameters.....: $el - DOM element handle which parent you need
;
; Return values..: Success - Return handle of the parent element
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetParentElement($el)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetParentElement", "ptr", $el, "ptr*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[2]
EndFunc ;==>_HLGetParentElement
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetElementHtml
; Description....: Get Html of the element.
; Syntax.........: _HLGetElementHtml($el, $outer = 1)
; Parameters.....: $el - DOM element handle
; $outer - BOOL, if TRUE will return outer HTML otherwise inner. [Optional]
;
; Return values..: Success - Return Html of element
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetElementHtml($el, $outer = 1)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetElementHtml", "ptr", $el, "str*", "", "BOOL", $outer)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[2]
EndFunc ;==>_HLGetElementHtml
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetElementInnerText
; Description....: Get inner text of the element.
; Syntax.........: _HLGetElementInnerText($el)
; Parameters.....: $el - DOM element handle
;
; Return values..: Success - Return innertext of element
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetElementInnerText($el)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetElementInnerText", "ptr", $el, "str*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[2]
EndFunc ;==>_HLGetElementInnerText
; #FUNCTION# ====================================================================================================
; Name...........: _HLSetElementInnerText
; Description....: Set inner text of the element.
; Syntax.........: _HLSetElementInnerText($el, $String)
; Parameters.....: $el - DOM element handle
; $String - Innertext
;
; Return values..: Success - Return 1
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLSetElementInnerText($el, $String)
$len = StringLen($String)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutSetElementInnerText", "ptr", $el, "str", $String, "UINT", $len)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return 1
EndFunc ;==>_HLSetElementInnerText
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetAttributeCount
; Description....: Get number of element's attributes.
; Syntax.........: _HLGetAttributeCount($el)
; Parameters.....: $el - DOM element handle
;
; Return values..: Success - Return number of element attributes.
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetAttributeCount($el)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetAttributeCount", "ptr", $el, "UINT*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[2]
EndFunc ;==>_HLGetAttributeCount
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetNthAttribute
; Description....: Get value of any element's attribute by attribute's number.
; Syntax.........: _HLGetNthAttribute($el, $nth)
; Parameters.....: $el - DOM element handle
; $nth - number of desired attribute
;
; Return values..: Success - Return Array with name and value of attribute. $return[0] = name, $return[1] = value
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetNthAttribute($el, $nth)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetNthAttribute", "ptr", $el, "UINT", $nth, "str*", "", "wstr*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Dim $aRet[2]
$aRet[0] = $result[3]
$aRet[1] = $result[4]
Return $aRet
EndFunc ;==>_HLGetNthAttribute
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetAttributeByName
; Description....: Get value of any element's attribute by name.
; Syntax.........: _HLGetAttributeByName($el, $AttName)
; Parameters.....: $el - DOM element handle
; $AttName - attribute name
;
; Return values..: Success - Return attribute value
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetAttributeByName($el, $AttName)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetAttributeByName", "ptr", $el, "str", $AttName, "wstr*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[3]
EndFunc ;==>_HLGetAttributeByName
; #FUNCTION# ====================================================================================================
; Name...........: _HLSetAttributeByName
; Description....: Set attribute's value.
; Syntax.........: _HLSetAttributeByName($el, $AttName, $value)
; Parameters.....: $el - DOM element handle
; $AttName - attribute name
; $value - new attribute value or 0 if you want to remove attribute.
;
; Return values..: Success - Return 1
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLSetAttributeByName($el, $AttName, $value)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutSetAttributeByName", "ptr", $el, "str", $AttName, "wstr", $value)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return 1
EndFunc ;==>_HLSetAttributeByName
; #FUNCTION# ====================================================================================================
; Name...........: _HLClearAttributes
; Description....: Remove all attributes from the element.
; Syntax.........: _HLClearAttributes($el)
; Parameters.....: $el - DOM element handle
;
; Return values..: Success - Return 1
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLClearAttributes($el)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutClearAttributes", "ptr", $el)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return 1
EndFunc ;==>_HLClearAttributes
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetElementIndex
; Description....: Get element index.
; Syntax.........: _HLGetElementIndex($el)
; Parameters.....: $el - DOM element handle
;
; Return values..: Success - Return index of element
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetElementIndex($el)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetElementIndex", "ptr", $el, "UINT*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[2]
EndFunc ;==>_HLGetElementIndex
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetElementType
; Description....: Get element's type.
; Syntax.........: _HLGetElementType($el)
; Parameters.....: $el - DOM element handle
;
; Return values..: Success - Return Type of element
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetElementType($el)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetElementType", "ptr", $el, "str*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[2]
EndFunc ;==>_HLGetElementType
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetStyleAttribute
; Description....: Get element's style attribute.
; Syntax.........: _HLGetStyleAttribute($el, $StyleName)
; Parameters.....: $el - DOM element handle
; $StyleName - name of the style attribute
;
; Return values..: Success - Return value of the style attribute.
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLGetStyleAttribute($el, $StyleName)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutGetStyleAttribute", "ptr", $el, "wstr", $StyleName, "wstr*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[3]
EndFunc ;==>_HLGetStyleAttribute
; #FUNCTION# ====================================================================================================
; Name...........: _HLSetStyleAttribute
; Description....: Set element's style attribute.
; Syntax.........: _HLSetStyleAttribute($el, $StyleName, $StyleValue)
; Parameters.....: $el - DOM element handle
; $StyleName - name of the style attribute
; $StyleValue - value of the style attribute.
;
; Return values..: Success - Return 1
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLSetStyleAttribute($el, $StyleName, $StyleValue)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutSetStyleAttribute", "ptr", $el, "str", $StyleName, "wstr", $StyleValue)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return 1
EndFunc ;==>_HLSetStyleAttribute
; #FUNCTION# ====================================================================================================
; Name...........: _HLVisitElements
; Description....: Return Array of elements in a DOM that meets specified criteria.
; Syntax.........: _HLVisitElements($el, $TagName = "", $AttributeName = "", $AttributeValue = "", $depth = 0)
; Parameters.....: $el - DOM element handle
; $TagName - comma separated list of tag names to search, e.g. "div", "p", "div,p" etc. [Optional]
; $AttributeName - name of attribute, can contain wildcard characters. [Optional]
; $AttributeValue - value of attribute, can contain wildcard characters.[Optional]
; $depth - 0 means all descendants, 1 - direct children only, 2 - children and their children and so on. [Optional]
;
; Return values..: Success - Return array of element, $return[0] : number of element.
; Failure - Return 0 if no element found else Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLVisitElements($el, $TagName = "", $AttributeName = "", $AttributeValue = "", $depth = 0)
$TagType = "str"
$AttType = "str"
$AttVType = "wstr"
If $TagName = "" Then $TagType = "ptr"
If $AttributeName = "" Then $AttType = "ptr"
If $AttributeValue = "" Then $AttVType = "ptr"
$handle = DllCallbackRegister("_HLElementsCallback", "BOOL", "ptr;ptr")
Dim $aHLelementsfound[1]
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutVisitElements", "ptr", $el, $TagType, $TagName, $AttType, $AttributeName, $AttVType, $AttributeValue, "ptr", DllCallbackGetPtr($handle), "ptr", "", "DWORD", $depth)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
DllCallbackFree($handle)
$HLelementsCount = UBound($aHLelementsfound)
If $HLelementsCount = 1 Then Return 0
$aHLelementsfound[0] = $HLelementsCount-1
Return $aHLelementsfound
EndFunc ;==>_HLVisitElements
Func _HLElementsCallback($el, $param)
Local $iUBound = UBound($aHLelementsfound)
ReDim $aHLelementsfound[$iUBound + 1]
$aHLelementsfound[$iUBound] = $el
EndFunc ;==>_HLElementsCallback
; #FUNCTION# ====================================================================================================
; Name...........: _HLSelectElements
; Description....: Return Array of elements in a DOM that meets specified CSS selectors.
; Syntax.........: _HLSelectElements($el, $CssSel)
; Parameters.....: $el - DOM element handle
; $CssSel - comma separated list of CSS selectors, e.g.: div, id, div[align="right"].
;
; Return values..: Success - Return Array of elements, $return[0] : number of element.
; Failure - Return 0 if no element found else Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........: See list of supported selectors: http://terrainformatica.com/htmlayout/selectors.whtm
; ===============================================================================================================
Func _HLSelectElements($el, $CssSel)
$handle = DllCallbackRegister("_HLElementsCallback", "BOOL", "ptr;ptr")
Dim $aHLelementsfound[1]
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutSelectElements", "ptr", $el, "str", $CssSel, "ptr", DllCallbackGetPtr($handle), "ptr", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
DllCallbackFree($handle)
$HLelementsCount = UBound($aHLelementsfound)
If $HLelementsCount = 1 Then Return 0
$aHLelementsfound[0] = $HLelementsCount-1
Return $aHLelementsfound
EndFunc ;==>_HLSelectElements
; #FUNCTION# ====================================================================================================
; Name...........: _HLSelectParent
; Description....: Find parent of the element by CSS selector.
; Syntax.........: _HLSelectParent($el, $CssSel, $depth = 0)
; Parameters.....: $el - DOM element handle
; $CssSel - comma separated list of CSS selectors, e.g.: div, id, div[align="right"].
; $depth - if depth == 1 then it will test only element itself.
; Use depth = 1 if you just want to test he element for matching given CSS selector(s).
; depth = 0 will scan the whole child parent chain up to the root. [Optional]
;
; Return values..: Success - Return parent of the element.
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _HLSelectParent($el, $CssSel, $depth = 0)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutSelectParent", "ptr", $el, "str", $CssSel, "UINT", $depth, "ptr*", "")
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return $result[4]
EndFunc ;==>_HLSelectParent
; #FUNCTION# ====================================================================================================
; Name...........: _HLSetElementHtml
; Description....: Set inner or outer html of the element.
; Syntax.........: _HLSetElementHtml($el, $html, $where)
; Parameters.....: $el - DOM element handle
; $html - string containing html text
; $where - possible values are:
; 0: replace content of the element
; 1: insert html before first child of the element
; 2: insert html after last child of the element
; 3: replace element by html, a.k.a. element.outerHtml = "something"
; 4: insert html before the element
; 5: insert html after the element
;
; Return values..: Success - Return 1
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........: Value 3,4 and 5 for $where do not work for inline elements like
; ===============================================================================================================
Func _HLSetElementHtml($el, $html, $where)
$htmllen = StringLen($html)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutSetElementHtml", "ptr", $el, "str", $html, "DWORD", $htmllen, "UINT", $where)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return 1
EndFunc ;==>_HLSetElementHtml
; #FUNCTION# ====================================================================================================
; Name...........: _HLDeleteElement
; Description....: Delete element.
; Syntax.........: _HLDeleteElement($el)
; Parameters.....: $el - DOM element handle
;
; Return values..: Success - Return 1
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........: After call to this function $el will become invalid.
; ===============================================================================================================
Func _HLDeleteElement($el)
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutDeleteElement", "ptr", $el)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
Return 1
EndFunc ;==>_HLDeleteElement
;~ EXTERN_C HLDOM_RESULT HLAPI HTMLayoutShowPopup (HELEMENT hePopup, HELEMENT heAnchor, UINT placement)
;~ Shows block element (DIV) in popup window.
;~ Func _HLShowPopup($HtmLayoutdll, $el, $anchor, $placement)
;~ $result = DllCall($HtmLayoutdll, "int", "HTMLayoutShowPopup", "ptr", $el, "ptr", $anchor, "UINT", $placement)
;~ If @error Then Return 0
;~ Return 1
;~ EndFunc
; #FUNCTION# ====================================================================================================
; Name...........: _HLWindowAttachEventHandler
; Description....: Attach/Detach ElementEventProc to the htmlayout window.
; Syntax.........: _HLWindowAttachEventHandler($hwnd, $func)
; Parameters.....: $hwnd - HWND of HtmLayout windows
; $func - Function to receive events (need two params eg: $func($ev, $prm)
; $events - Events you want receive (see remarks)
; Return values..: Success - Return 1
; Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........: _HLGetParam must use for read param of event.
;~ Events can be :
;~ $HANDLE_INITIALIZATION : attached/detached
;~ $HANDLE_MOUSE : mouse events
;~ $HANDLE_KEY : key events
;~ $HANDLE_FOCUS : focus events, if this flag is set it also means that element it attached to is focusable
;~ $HANDLE_SCROLL : scroll events
;~ $HANDLE_SIZE : size changed event
;~ $HANDLE_DATA_ARRIVED : requested data () has been delivered
;~ $HANDLE_BEHAVIOR_EVENT : secondary, synthetic events:
;~ BUTTON_CLICK, HYPERLINK_CLICK, etc.,
;~ a.k.a. notifications from intrinsic behaviors
;~ $HANDLE_METHOD_CALL : behavior specific methods
;~ $HANDLE_EXCHANGE : system drag-n-drop events
;~ $HANDLE_ALL : all of them
; ===============================================================================================================
Func _HLWindowAttachEventHandler($hwnd, $func, $events)
$HandleWindowsAttachEvent = DllCallbackRegister("HLEvHandler", "BOOL", "ptr;ptr;UINT;ptr")
$result = DllCall($HtmLayoutdll, "int", "HTMLayoutWindowAttachEventHandler", "HWND", $hwnd, "ptr", DllCallbackGetPtr($HandleWindowsAttachEvent), "ptr", "", "UINT", $DISABLE_INITIALIZATION+$events)
If @error Then Return SetError(6,0,-1)
If $result[0] <> 0 Then SetError($result[0],0,-1)
$HtmLayoutEvHandler = $func
Return 1
EndFunc ;==>_HLWindowAttachEventHandler
Func HLEvHandler($tag,$el,$ev,$prm)
$a = DllStructCreate("UINT cmd", $prm)
$cmd = DllStructGetData($a, "cmd")
$a = 0
If $cmd > 32768 Then Return
Execute ($HtmLayoutEvHandler&"("&$ev&","&$prm&")")
EndFunc
; #FUNCTION# ====================================================================================================
; Name...........: _HLGetParam
; Description....: Get parameter of events
; Syntax.........: _HLGetParam($ev, $prm)
; Parameters.....: $ev - Type of event see remarks of _HLWindowAttachEventHandler
; $prm - Parameter of event
;
; Return values..: Success - return an array depending of event
; Failure - Return -1
; Remarks........: For Uppercase type see "HtmLayout Constants.au3"
; $HANDLE_MOUSE : $ret[12]=[MOUSE_EVENTS, target el, curs xpos el rel, curs ypos el rel, curs xpos doc rel, curs ypos doc rel, MOUSE_BUTTONS, KEYBOARD_STATES, CURSOR_TYPE, is on icon, el dragged, DRAGGING_TYPE]
; $HANDLE_KEY : $ret[4]=[KEY_EVENTS, target el, key code, KEYBOARD_STATES]
; $HANDLE_FOCUS : $ret[4]=[FOCUS_EVENTS, target el, focus by click, cancel]
; $HANDLE_SCROLL: $ret[4]=[SCROLL_EVENTS, target el, scroll pos, 1 if vert scroll]
; $HANDLE_BEHAVIOR_EVENT : $ret[5]=[BEHAVIOR_EVENTS, target el, source el, EVENT_REASON or EDIT_CHANGED_REASON, data]
;===============================================================================================================
Func _HLGetParam($ev, $prm)
Local $ap = -1
If $ev = $HANDLE_MOUSE Then
$str = "UINT cmd;ptr target;DWORD posx;DWORD posy;DWORD pos_documentx;DWORD pos_documenty;UINT button_state;UINT alt_state;UINT cursor_type;BOOL is_on_icon;ptr dragging;UINT dragging_mode"
$ap = getstructdata($str,$prm)
EndIf
If $ev = $HANDLE_KEY Then
$str = "UINT cmd;ptr target;UINT key_code;UINT alt_state"
$ap = getstructdata($str,$prm)
EndIf
If $ev = $HANDLE_FOCUS Then
$str = "UINT cmd;ptr target;BOOL by_mouse_click;BOOL cancel"
$ap = getstructdata($str,$prm)
EndIf
If $ev = $HANDLE_SCROLL Then
$str = "UINT cmd;ptr target;int pos;BOOL vertical"
$ap = getstructdata($str,$prm)
EndIf
If $ev = $HANDLE_BEHAVIOR_EVENT Then
$str = "UINT cmd;ptr heTarget;ptr he;UINT reason;ptr data"
$ap = getstructdata($str,$prm)
EndIf
If $ev = $HANDLE_METHOD_CALL Then
$str = "UINT cmd;ptr heTarget;ptr he;UINT reason;ptr data"
$ap = getstructdata($str,$prm)
EndIf
Return $ap
EndFunc
Func getstructdata($str,$prm)
$a = DllStructCreate($str, $prm)
$b = StringSplit ( $str, ";")
Dim $ret[$b[0]]
For $i = 0 To $b[0]-1
$ret[$i] = DllStructGetData($a,$i+1)
Next
Return $ret
EndFunc