Jump to content

Sciter Dll UDF !


GMib
 Share

Recommended Posts

Sciter is a HTML/CSS renderer and layout manager. you can make powerfull html gui.

you need sciter-x.dll from Sciter SDK

you can also download HtmLayout Demo for see lot of exemples of use. (run browse.exe in bin folder and open htm file in html_samples)

post-55441-12726332638257_thumb.jpgpost-55441-12727117450876_thumb.jpg

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Sciter-Constants.au3>
#include-once

Global $aHLelementsfound = 0
Global $Sciterdll = 0
Global $SciterRef = 0
Global $HandleWindowsAttachEvent = 0
Global $SciterEvHandler = 0
Global $aHLDOM_error[7]
Global $sciterhtml
$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 Sciter_UseElement()"
$aHLDOM_error[4] = "parameter is invalid, e.g. pointer is null"
$aHLDOM_error[5] = "operation failed, e.g. invalid html in SciterSetElementHtml()"
$aHLDOM_error[6] = "Dllcall error"

; #FUNCTION# ====================================================================================================
; Name...........:  _StStartup
; Description....:  Initialize Sciter
; Syntax.........:  _StStartup($dll = "Sciter-x.dll")
; Parameters.....:  $dll - Path to sciter DLL [Optional]
;
; Return values..:  Success - 1
;                   Failure - 0
; Remarks........:
; ===============================================================================================================
Func _StStartup($dll = "Sciter-x.dll") ;ok
    $SciterRef += 1
    If $SciterRef > 1 Then Return 1
    $Sciterdll = DllOpen($dll)
    If $Sciterdll = -1 Then Return SetError(1, 0, 0)
    Return 1
EndFunc

; #FUNCTION# ====================================================================================================
; Name...........:  _StCreate
; Description....:  Create Sciter Windows
; Syntax.........:  _StCreate($x = 0, $y = 0, $w = 100, $h = 50)
; Parameters.....:  $x - [Optional]
;                   $y - [Optional]
;                   $w - [Optional]
;                   $h - [Optional]
;
; Return values..:  Success - Sciter window handle.
;                   Failure - 0
; Remarks........:
; ===============================================================================================================
Func _StCreate($x = 0, $y = 0, $w = 100, $h = 50) ;ok
    If $x = -1 Then $x = @DesktopWidth / 2 - ($w/2)
    If $y = -1 Then $y = @DesktopHeight / 2 - ($h/2)
    $result = DllCall($Sciterdll, "wstr", "SciterClassNameW")
    If @error Then Return 0
    $ClassName = $result[0]
    $SciterHwnd = _WinAPI_CreateWindowEx(BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW ), $ClassName, "", BitOR($WS_VISIBLE,$WS_popup,$WS_CLIPCHILDREN), $x, $y, $w, $h,0)
    Return $SciterHwnd
EndFunc   ;==>_StCreateGui

; #FUNCTION# ====================================================================================================
; Name...........:  _StIncGui
; Description....:  Create Sciter Windows as child of $ParentGui
; Syntax.........:  _StIncGui($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 - Sciter window handle.
;                   Failure - 0
; Remarks........:
; ===============================================================================================================
Func _StIncGui($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50) ;ok
    $result = DllCall($Sciterdll, "wstr", "SciterClassNameW")
    If @error Then Return 0
    $ClassName = $result[0]
    $SciterHwnd = _WinAPI_CreateWindowEx(0, $ClassName, "", BitOR($WS_CHILD, $WS_VISIBLE,$WS_CLIPCHILDREN), $x, $y, $w, $h,$ParentGui)
    Return $SciterHwnd
EndFunc   ;==>_StIncGui

; #FUNCTION# ====================================================================================================
; Name...........:  _StLoadFile
; Description....:  Load HTML file.
; Syntax.........:  _StLoadFile($STHwnd, $file)
; Parameters.....:  $STHwnd - Sciter window handle.
;                   $file - File name of an HTML file.
;
; Return values..:  Success - 1
;                   Failure - 0
; Remarks........:
; ===============================================================================================================
Func _StLoadFile($STHwnd, $file) ;ok
    $result = DllCall($Sciterdll, "BOOL", "SciterLoadFile", "HWND", $STHwnd, "wstr", $file)
    If @error Then Return 0
    Return $result[0]
EndFunc   ;==>_StLoadFile

; #FUNCTION# ====================================================================================================
; Name...........:  _StLoadHtml
; Description....:  Load HTML from memory.
; Syntax.........:  _StLoadHtml($STHwnd, $String)
; Parameters.....:  $STHwnd - Sciter window handle.
;                   $String - HTML to load.
;
; Return values..:  Success - 1
;                   Failure - 0
; Remarks........:
; ===============================================================================================================
Func _StLoadHtml($STHwnd, $String) ;ok
    $StringSize = StringLen($String)
    $result = DllCall($Sciterdll, "BOOL", "SciterLoadHtml", "HWND", $STHwnd, "str", $String, "UINT", $StringSize, "str", @ScriptDir)
    If @error Then Return SetError(@error,0,0)
    Return 1
EndFunc   ;==>_StLoadHtml

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetRootElement
; Description....:  Get root DOM element of HTML document.
; Syntax.........:  _StGetRootElement($STHwnd)
; Parameters.....:  $STHwnd - Sciter 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 _StGetRootElement($STHwnd) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetRootElement", "HWND", $STHwnd, "ptr*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[2]
EndFunc   ;==>_StGetRootElement

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetElementHtml
; Description....:  Get Html of the element.
; Syntax.........:  _StGetElementHtml($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 _StGetElementHtml($el, $outer = 1) ;ok
    $sciterhtml = ""
    $LPCBYTE_RECEIVER = DllCallbackRegister("SciterByteCallback", "ptr", "str;UINT;ptr")
    $result = DllCall($Sciterdll, "int", "SciterGetElementHtmlCB", "ptr", $el, "BOOL", $outer, "ptr", DllCallbackGetPtr($LPCBYTE_RECEIVER), "ptr", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    DllCallbackFree($LPCBYTE_RECEIVER)
    Return $sciterhtml
EndFunc
Func SciterByteCallback($byte,$num,$prm)
    $sciterhtml = BinaryToString($byte,4)
EndFunc

; #FUNCTION# ====================================================================================================
; Name...........:  _StSetElementHtml
; Description....:  Set inner or outer html of the element.
; Syntax.........:  _StSetElementHtml($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 _StSetElementHtml($el, $html, $where = 0) ;ok
    $htmllen = StringLen($html)
    $result = DllCall($Sciterdll, "int", "SciterSetElementHtml", "ptr", $el, "str", $html, "DWORD", $htmllen, "UINT", $where)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return 1
EndFunc   ;==>_StSetElementHtml

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetElementText
; Description....:  Get inner text of the element
; Syntax.........:  _StGetElementText($el)
; Parameters.....:  $el - DOM element handle
;
; Return values..:  Success - return text element
;                   Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _StGetElementText($el) ;ok
    $sciterhtml = ""
    $LPCWSTR_RECEIVER = DllCallbackRegister("SciterWSTRCallback", "ptr", "wstr;UINT;ptr")
    $result = DllCall($Sciterdll, "int", "SciterGetElementTextCB", "ptr", $el, "ptr", DllCallbackGetPtr($LPCWSTR_RECEIVER), "ptr", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    DllCallbackFree($LPCWSTR_RECEIVER)
    Return $sciterhtml
EndFunc
Func SciterWSTRCallback($wstr,$num,$prm)
    $sciterhtml = $wstr
EndFunc

; #FUNCTION# ====================================================================================================
; Name...........:  _StSetElementText
; Description....:  Set inner text of the element.
; Syntax.........:  _StSetElementText($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 _StSetElementText($el, $String) ;ok
    $len = StringLen($String)
    $result = DllCall($Sciterdll, "int", "SciterSetElementText", "ptr", $el, "wstr", $String, "UINT", $len)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return 1
EndFunc   ;==>_StSetElementText

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetChildrenCount
; Description....:  Get number of child elements.
; Syntax.........:  _StGetChildrenCount($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 _StGetChildrenCount($el) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetChildrenCount", "ptr", $el, "UINT*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[2]
EndFunc   ;==>_StGetChildrenCount

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetFocusElement
; Description....:  Get focused DOM element of HTML document.
; Syntax.........:  _StGetFocusElement($hwnd)
; Parameters.....:  $hwnd - Sciter windows handle
;
; Return values..:  Success - Return focus element or 0 if no focus
;                   Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:  To set focus on element use _StSetElementState($el, $STATE_FOCUS,0)
; ===============================================================================================================
Func _StGetFocusElement($hwnd) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetFocusElement", "HWND", $hwnd, "ptr*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[2]
EndFunc

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetElementState
; Description....:  Get state bits, see ELEMENT_STATE_BITS in "Sciter-constants.au3"
; Syntax.........:  _StGetElementState($el)
; Parameters.....:  $el - Dom element handle
;
; Return values..:  Success - Return Statebits
;                   Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _StGetElementState($el) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetElementState", "ptr", $el, "UINT*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[2]
EndFunc

; #FUNCTION# ====================================================================================================
; Name...........:  _StSetElementState
; Description....:  Set state bits, see ELEMENT_STATE_BITS in "Sciter-constants.au3"
; Syntax.........:  _StSetElementState($el, $stateToSet, $stateToClear = 0, $upt = 1)
; Parameters.....:  $el - Dom handle element
;                   $stateToSet -
;                   $stateToClear - [Optional]
;                   $upt - [Optional]
;
; Return values..:  Success - Return 1
;                   Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _StSetElementState($el, $stateToSet, $stateToClear = 0, $upt = 1)
    $result = DllCall($Sciterdll, "int", "SciterSetElementState", "ptr", $el, "UINT", $stateToSet, "UINT", $stateToClear, "BOOL", $upt)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return 1
EndFunc

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetNthChild
; Description....:  Get handle of Nth child element.
; Syntax.........:  _StGetNthChild($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 _StGetNthChild($el, $nth) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetNthChild", "ptr", $el, "UINT", $nth-1, "ptr*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[3]
EndFunc   ;==>_StGetNthChild

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetParentElement
; Description....:  Get parent element.
; Syntax.........:  _StGetParentElement($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 _StGetParentElement($el) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetParentElement", "ptr", $el, "ptr*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[2]
EndFunc   ;==>_StGetParentElement

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetAttributeCount
; Description....:  Get number of element's attributes.
; Syntax.........:  _StGetAttributeCount($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 _StGetAttributeCount($el) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetAttributeCount", "ptr", $el, "UINT*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[2]
EndFunc   ;==>_StGetAttributeCount

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetNthAttribute
; Description....:  Get value of any element's attribute by attribute's number.
; Syntax.........:  _StGetNthAttribute($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 _StGetNthAttribute($el, $nth);ok
    $result = DllCall($Sciterdll, "int", "SciterGetNthAttribute", "ptr", $el, "UINT", $nth, "str*", "", "wstr*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Dim $aRet[2]
    $aRet[0] = $result[3]
    $aRet[1] = $result[4]
    Return $aRet
EndFunc   ;==>_StGetNthAttribute

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetAttributeByName
; Description....:  Get value of any element's attribute by name.
; Syntax.........:  _StGetAttributeByName($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 _StGetAttributeByName($el, $AttName);ok
    $result = DllCall($Sciterdll, "int", "SciterGetAttributeByName", "ptr", $el, "str", $AttName, "wstr*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[3]
EndFunc   ;==>_StGetAttributeByName

; #FUNCTION# ====================================================================================================
; Name...........:  _StSetAttributeByName
; Description....:  Set attribute's value.
; Syntax.........:  _StSetAttributeByName($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 _StSetAttributeByName($el, $AttName, $value) ;ok
    $result = DllCall($Sciterdll, "int", "SciterSetAttributeByName", "ptr", $el, "str", $AttName, "wstr", $value)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return 1
EndFunc   ;==>_StSetAttributeByName

; #FUNCTION# ====================================================================================================
; Name...........:  _StClearAttributes
; Description....:  Remove all attributes from the element.
; Syntax.........:  _StClearAttributes($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 _StClearAttributes($el) ;ok
    $result = DllCall($Sciterdll, "int", "SciterClearAttributes", "ptr", $el)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return 1
EndFunc   ;==>_StClearAttributes

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetElementIndex
; Description....:  Get element index.
; Syntax.........:  _StGetElementIndex($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 _StGetElementIndex($el) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetElementIndex", "ptr", $el, "UINT*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[2]
EndFunc   ;==>_StGetElementIndex

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetElementType
; Description....:  Get element's type.
; Syntax.........:  _StGetElementType($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........: For <div> return will be set to "div".
; ===============================================================================================================
Func _StGetElementType($el) ;ok
    $result = DllCall($Sciterdll, "int", "SciterGetElementType", "ptr", $el, "str*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[2]
EndFunc   ;==>_StGetElementType

; #FUNCTION# ====================================================================================================
; Name...........:  _StGetStyleAttribute
; Description....:  Get element's style attribute.
; Syntax.........:  _StGetStyleAttribute($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 _StGetStyleAttribute($el, $StyleName);ok
    $result = DllCall($Sciterdll, "int", "SciterGetStyleAttribute", "ptr", $el, "str", $StyleName, "wstr*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[3]
EndFunc   ;==>_StGetStyleAttribute

; #FUNCTION# ====================================================================================================
; Name...........:  _StSetStyleAttribute
; Description....:  Set element's style attribute.
; Syntax.........:  _StSetStyleAttribute($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 _StSetStyleAttribute($el, $StyleName, $StyleValue);ok
    $result = DllCall($Sciterdll, "int", "SciterSetStyleAttribute", "ptr", $el, "str", $StyleName, "wstr", $StyleValue)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return 1
EndFunc   ;==>_StSetStyleAttribute

; #FUNCTION# ====================================================================================================
; Name...........:  _StCreateElement
; Description....:  Create new element, the element is disconnected initially from the DOM.
; Syntax.........:  _StCreateElement($tag, $txt = "")
; Parameters.....:  $tag - html tag of the element e.g. "div", "option", etc.
;                   $txt - initial text of the element or "". text here is a plain text. [Optional]
;
; Return values..:  Success - Return handle of element
;                   Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:
; ===============================================================================================================
Func _StCreateElement($tag, $txt = "");ok
    If $txt <> "" Then
        $result = DllCall($Sciterdll, "int", "SciterCreateElement", "str", $tag, "wstr", $txt, "ptr*", "")
    Else
        $result = DllCall($Sciterdll, "int", "SciterCreateElement", "str", $tag, "ptr", "", "ptr*", "")
    EndIf
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[3]
EndFunc   ;==>_StCreateElement

; #FUNCTION# ====================================================================================================
; Name...........:  _StInsertElement
; Description....:  Insert element at index position of parent.
; Syntax.........:  _StInsertElement($el, $elparent, $index)
; Parameters.....:  $el - Handle element
;                   $elparent - Handle element of parent
;                   $index - position of the element in parent collection.
;
; Return values..:  Success - Return 1
;                   Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:  It is not an error to provide index greater than elements count in parent - it will be appended.
; ===============================================================================================================
Func _StInsertElement($el, $elparent, $index);ok
    $result = DllCall($Sciterdll, "int", "SciterInsertElement", "ptr", $el, "ptr", $elparent, "UINT", $index)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return 1
EndFunc



; #FUNCTION# ====================================================================================================
; Name...........:  _StSelectElements
; Description....:  Return Array of elements in a DOM that meets specified CSS selectors.
; Syntax.........:  _StSelectElements($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/Sciter/selectors.whtm
; ===============================================================================================================
Func _StSelectElements($el, $CssSel);ok
    $handle = DllCallbackRegister("StElementsCallback", "BOOL", "ptr;ptr")
    Dim $aHLelementsfound[1]
    $result = DllCall($Sciterdll, "int", "SciterSelectElementsW", "ptr", $el, "wstr", $CssSel, "ptr", DllCallbackGetPtr($handle), "ptr", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    DllCallbackFree($handle)
    $HLelementsCount = UBound($aHLelementsfound)
    If $HLelementsCount = 1 Then Return 0
    $aHLelementsfound[0] = $HLelementsCount-1
    Return $aHLelementsfound
EndFunc   ;==>_StSelectElements
Func StElementsCallback($el, $param)
    Local $iUBound = UBound($aHLelementsfound)
    ReDim $aHLelementsfound[$iUBound + 1]
    $aHLelementsfound[$iUBound] = $el
EndFunc   ;==>_StElementsCallback

; #FUNCTION# ====================================================================================================
; Name...........:  _StSelectParent
; Description....:  Find parent of the element by CSS selector.
; Syntax.........:  _StSelectParent($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 _StSelectParent($el, $CssSel, $depth = 0) ;ok
    $result = DllCall($Sciterdll, "int", "SciterSelectParentW", "ptr", $el, "wstr", $CssSel, "UINT", $depth, "ptr*", "")
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return $result[4]
EndFunc   ;==>_StSelectParent

; #FUNCTION# ====================================================================================================
; Name...........:  _StDeleteElement
; Description....:  Delete element.
; Syntax.........:  _StDeleteElement($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 _StDeleteElement($el)
    $result = DllCall($Sciterdll, "int", "SciterDeleteElement", "ptr", $el)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    Return 1
EndFunc   ;==>_StDeleteElement


;~ EXTERN_C HLDOM_RESULT HLAPI  SciterShowPopup (HELEMENT hePopup, HELEMENT heAnchor, UINT placement)
;~   Shows block element (DIV) in popup window.
;~ Func _StShowPopup($Sciterdll, $el, $anchor, $placement)
;~  $result = DllCall($Sciterdll, "int", "SciterShowPopup", "ptr", $el, "ptr", $anchor, "UINT", $placement)
;~  If @error Then Return 0
;~  Return 1
;~ EndFunc

; #FUNCTION# ====================================================================================================
; Name...........:  _StWindowAttachEventHandler
; Description....:  Attach/Detach ElementEventProc to the Sciter window.
; Syntax.........:  _StWindowAttachEventHandler($hwnd, $func, $events)
; Parameters.....:  $hwnd - HWND of Sciter windows
;                   $func - Function to receive events (need two params eg: $func($ev, $arrayparam)
;                   $events - Events you want receive (see remarks)
;                       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.
;~                      $HANDLE_METHOD_CALL     : behavior specific methods
;~                      $HANDLE_EXCHANGE        : system drag-n-drop events
;~                      $HANDLE_ALL             : all of them
; Return values..:  Success - Return 1
;                   Failure - Return -1, @error is set. (see $aHLDOM_error[@error] for details)
; Remarks........:  For Uppercase type see "Sciter-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 _StWindowAttachEventHandler($hwnd, $func, $events)
    $HandleWindowsAttachEvent = DllCallbackRegister("HLEvHandler", "BOOL", "ptr;ptr;UINT;ptr")
    $result = DllCall($Sciterdll, "int", "SciterWindowAttachEventHandler", "HWND", $hwnd, "ptr", DllCallbackGetPtr($HandleWindowsAttachEvent), "ptr", "", "UINT", $DISABLE_INITIALIZATION+$events)
    If @error Then Return SetError(6,0,-1)
    If $result[0] <> 0 Then Return SetError($result[0],0,-1)
    $SciterEvHandler = $func
    Return 1
EndFunc   ;==>_StWindowAttachEventHandler

Func HLEvHandler($tag,$el,$ev,$prm)
    $ap = -1
    $a = DllStructCreate("UINT cmd", $prm)
    $cmd = DllStructGetData($a, "cmd")
    $a = 0
    If $cmd > 32768 Then Return
    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
    Execute ($SciterEvHandler&"("&$ev&",$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

changelog :

0.2 :   Add _StDebug() for display css/html error in scite console.
        Correct some error in Sciter-constants
        Add taskbar and title param in _StCreate
        Add skin gui exemple
0.1 : First release

Calltips:

_StStartup ($dll = "Sciter-x.dll")  Initialize Sciter (required: #include <Sciter-UDF.au3>)
_StCreate ($x = 0, $y = 0, $w = 100, $h = 50)  Create Sciter Windows (required: #include <Sciter-UDF.au3>)
_StIncGui ($ParentGui, $x = 0, $y = 0, $w = 100, $h = 50)  Create Sciter Windows as child of $ParentGui (required: #include <Sciter-UDF.au3>)
_StLoadFile ($STHwnd, $file)  Load HTML file. (required: #include <Sciter-UDF.au3>)
_StLoadHtml ($STHwnd, $String)  Load HTML from memory. (required: #include <Sciter-UDF.au3>)
_StGetRootElement ($STHwnd)  Get root DOM element of HTML document. (required: #include <Sciter-UDF.au3>)
_StGetElementHtml ($el, $outer = 1)  Get Html of the element. (required: #include <Sciter-UDF.au3>)
_StSetElementHtml ($el, $html, $where)  Set inner or outer html of the element. (required: #include <Sciter-UDF.au3>)
_StGetElementText ($el)  Get inner text of the element (required: #include <Sciter-UDF.au3>)
_StSetElementText ($el, $String)  Set inner text of the element. (required: #include <Sciter-UDF.au3>)
_StGetChildrenCount ($el)  Get number of child elements. (required: #include <Sciter-UDF.au3>)
_StGetFocusElement ($hwnd)  Get focused DOM element of HTML document. (required: #include <Sciter-UDF.au3>)
_StGetElementState ($el)  Get state bits, see ELEMENT_STATE_BITS in "Sciter-constants.au3" (required: #include <Sciter-UDF.au3>)
_StSetElementState ($el, $stateToSet, $stateToClear = 0, $upt = 1)  Set state bits, see ELEMENT_STATE_BITS in "Sciter-constants.au3" (required: #include <Sciter-UDF.au3>)
_StGetNthChild ($el, $nth)  Get handle of Nth child element. (required: #include <Sciter-UDF.au3>)
_StGetParentElement ($el)  Get parent element. (required: #include <Sciter-UDF.au3>)
_StGetAttributeCount ($el)  Get number of element's attributes. (required: #include <Sciter-UDF.au3>)
_StGetNthAttribute ($el, $nth)  Get value of any element's attribute by attribute's number. (required: #include <Sciter-UDF.au3>)
_StGetAttributeByName ($el, $AttName)  Get value of any element's attribute by name. (required: #include <Sciter-UDF.au3>)
_StSetAttributeByName ($el, $AttName, $value)  Set attribute's value. (required: #include <Sciter-UDF.au3>)
_StClearAttributes ($el)  Remove all attributes from the element. (required: #include <Sciter-UDF.au3>)
_StGetElementIndex ($el)  Get element index. (required: #include <Sciter-UDF.au3>)
_StGetElementType ($el)  Get element's type. (required: #include <Sciter-UDF.au3>)
_StGetStyleAttribute ($el, $StyleName)  Get element's style attribute. (required: #include <Sciter-UDF.au3>)
_StSetStyleAttribute ($el, $StyleName, $StyleValue)  Set element's style attribute. (required: #include <Sciter-UDF.au3>)
_StCreateElement ($tag, $txt = "")  Create new element, the element is disconnected initially from the DOM. (required: #include <Sciter-UDF.au3>)
_StInsertElement ($el, $elparent, $index)  Insert element at index position of parent. (required: #include <Sciter-UDF.au3>)
_StSelectElements ($el, $CssSel)  Return Array of elements in a DOM that meets specified CSS selectors. (required: #include <Sciter-UDF.au3>)
_StSelectParent ($el, $CssSel, $depth = 0)  Find parent of the element by CSS selector. (required: #include <Sciter-UDF.au3>)
_StDeleteElement ($el)  Delete element. (required: #include <Sciter-UDF.au3>)
_StWindowAttachEventHandler ($hwnd, $func, $events)  Attach/Detach ElementEventProc to the Sciter window. (required: #include <Sciter-UDF.au3>)

Sciter-UDF.7z

Edited by GMib
Link to comment
Share on other sites

you can also download HtmLayout Demo for see lot of exemples of use. (run browse.exe in bin folder and open htm file in html_samples)

Do you have the autoit source code for this examples and not the binaries?

Basically if you have a simple code how to use the UDF I will appreciate that much..:idea:

I am eager to html solution in GUI.

Regards,

Edited by lsakizada

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Do you have the autoit source code for this examples and not the binaries?

Demo is not autoit apps, il you want c++ source download HtmLayout SDK

Basically if you have a simple code how to use the UDF I will appreciate that much..:idea:

see "Ex func.au3" and "Ex OSD menu.au3" in 7zip file.
Link to comment
Share on other sites

Hi GMib

I missed those examples.

It is wonderfull script! although I have not time to learn it well.

I played around and modify the EX_OSD_Menue.au3 example to be run inside a GUI.

Thats realy a good option for me to be used with project and I am appreciate you for sharing the code.

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>
#include <WinApi.au3>
#include <Sciter-UDF.au3>
#include <StaticConstants.au3>
Global Const $SC_DRAGMOVE = 0xF012
Opt("MouseCoordMode", 2)

Local $tMsg
Opt("TrayMenuMode", 1)

$frmMain = GUICreate("Sciter in GUI example", 333, 441, 192, 124, $WS_POPUP, 0)
GUISetState(@SW_SHOW)

GUISetBkColor(0x1D4BAA, $frmMain)
$rgn = _WinAPI_CreateRoundRectRgn(0, 0, 333, 441, 3, 3)
_WinAPI_SetWindowRgn($frmMain, $rgn)
DrawBar()

_StStartup()
If @error Then MsgBox(0, "error", "Error dllopen")
$ST = _StIncGui($frmMain, 2, 20, 300, 500)
WinSetOnTop($ST, "", 1)

$fi = FileRead(@ScriptDir & '\osd.htm')
_StLoadHtml($ST, $fi)
_StWindowAttachEventHandler($ST, "_events", $HANDLE_KEY + $HANDLE_BEHAVIOR_EVENT)

While 1
    $tMsg = TrayGetMsg()
    Switch $tMsg
        Case $TRAY_EVENT_PRIMARYDOWN
            GUISetState(@SW_SHOW)
            DrawBar()
            WinSetState("frmMain", "", @SW_RESTORE)
            Opt("TrayIconHide", 1)
    EndSwitch

    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
        Case $frmMain
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                    _WinAPI_DestroyWindow($ST)
                    exit
                Case $GUI_EVENT_PRIMARYDOWN
                    $mPos = MouseGetPos()
                    If $mPos[1] <= 20 Then
                        If $mPos[0] >= 295 And $mPos[0] <= 316 Then
                            GUISetState(@SW_HIDE)
                            Opt("TrayIconHide", 0)
                        ElseIf $mPos[0] >= 313 And $mPos[0] <= 322 Then
                            _WinAPI_DestroyWindow($ST)
                    exit
                        Else
                            _SendMessage($frmMain, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
                        EndIf
                    EndIf
            EndSwitch
        Case $ST
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                    ;Exit
                    _WinAPI_DestroyWindow($ST)
                    exit
            EndSwitch
    EndSwitch

WEnd

Func DrawBar()
    Local $aDim = WinGetClientSize($frmMain)
    Local $hDC = _WinAPI_GetDC($frmMain)
    ; Bar
    Local $hBrush = _WinAPI_CreateSolidBrush(StringRegExpReplace("0x1D4BAA", "(.{2})(.{2})(.{2})(.{2})", "\1\4\3\2"))
    Local $hRect = DllStructCreate($tagRECT)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 0)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", 20)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    ; Minimize
    $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3)
    DllStructSetData($hRect, "Left", $aDim[0] - 37)
    DllStructSetData($hRect, "Top", 12)
    DllStructSetData($hRect, "Right", $aDim[0] - 28)
    DllStructSetData($hRect, "Bottom", 14)
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    ; Close
    Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0xd8ded3)
    Local $hSelected = _WinAPI_SelectObject($hDC, $hPen)
    _WinAPI_DrawLine($hDC, $aDim[0] - 20, 5, $aDim[0] - 11, 14)
    _WinAPI_DrawLine($hDC, $aDim[0] - 20, 14, $aDim[0] - 11, 5)
    _WinAPI_SelectObject($hDC, $hSelected)
    _WinAPI_DeleteObject($hPen)
    $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3)
    ; Frame Edge
    $hBrush = _WinAPI_CreateSolidBrush(0x686a65)
    DllStructSetData($hRect, "Left", $aDim[0] - 1)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", 20)
    DllStructSetData($hRect, "Right", 1)
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    DllStructSetData($hRect, "Left", 0)
    DllStructSetData($hRect, "Top", $aDim[1] - 1)
    DllStructSetData($hRect, "Right", $aDim[0])
    DllStructSetData($hRect, "Bottom", $aDim[1])
    _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)
    _WinAPI_DeleteObject($hBrush)
    _WinAPI_ReleaseDC($frmMain, $hDC)
    AdlibRegister("DrawBar")
EndFunc   ;==>DrawBar
Func _events($ev, $ad)
    local $label
    If $ev = $HANDLE_BEHAVIOR_EVENT Then
        $bh = $ad[0]
        If $bh = $MENU_ITEM_ACTIVE Then
            ;ConsoleWrite("Item :" & _StGetAttributeByName($ad[1], "no") & " Active" & @CRLF)
             GUICtrlDelete($label)
            $label= __create_label(10, 360, "Item :" & _StGetAttributeByName($ad[1], "no") & " Active" & @CRLF,  120,  20)
            ;GUICtrlDelete($label)
        ElseIf $bh = $MENU_ITEM_CLICK Then
            ;ConsoleWrite("Click on Item :" & _StGetAttributeByName($ad[1], "no") & @CRLF)
             GUICtrlDelete($label)
             $label= __create_label(10, 360, "Click on Item :" & _StGetAttributeByName($ad[1], "no") ,  120,  20)
            
        ElseIf $bh = $CONTEXT_MENU_REQUEST Then ; Right click for reload osd.htm (for testing change in html/css)
            $fi = FileRead(@ScriptDir & '\osd.htm')
            _StLoadHtml($ST, $fi)
        EndIf

    ElseIf $ev = $HANDLE_KEY Then
        $KeyEvent = $ad[0]
        If $KeyEvent = $KEY_DOWN Then
            $key = $ad[2]
            If $key = 27 Then 
            _WinAPI_DestroyWindow($ST)
                    exit ; exit on esc press
            EndIf
        EndIf
    EndIf

EndFunc   ;==>_events

Func __create_label($I_LEFT, $I_TOP, $S_TEXT = '', $I_WIDTH = 120, $I_HEIGHT = 20)
    ;========== FUNCTION START
    Local $O_CONTROL
    ;==========
    $O_CONTROL = GUICtrlCreateLabel($S_TEXT, $I_LEFT, $I_TOP, $I_WIDTH, $I_HEIGHT, BitOR($SS_LEFT, $SS_CENTERIMAGE))
    GUICtrlSetColor($O_CONTROL, 0x8C8C8C)
    ;========== FUNCTION END
    Return $O_CONTROL
EndFunc   ;==>__create_label

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Hi GMib

I played around and modify the EX_OSD_Menue.au3 example to be run inside a GUI.

New version is up, try "Ex skin.au3" exemple for skinning window

Edited by GMib
Link to comment
Share on other sites

Two thumbs up for the new example :idea:

I wonder how come not many reply on this wonderfull example script too.

I am working to have this example with three frameset (top, left and right) that the top one is not resize.

no success yet.

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

I am working to have this example with three frameset (top, left and right) that the top one is not resize.

no success yet.

i don't understand your problem, you want width of top frame not resize ?

if yes, a simple width:200px; in css work.

Link to comment
Share on other sites

i don't understand your problem, you want width of top frame not resize ?

if yes, a simple width:200px; in css work.

GMib,

I tried to enhanced your 'Ex skin.au3' example to have a silk window with frames.

why frames? because I wanted to create a simmilar GUI to skype, babylon, and such kind of popular applications.

I think with your UDF its possible but I am not so strong with CSS, but this is my problem... :idea:

Anyway, I was able to set frames but the top one insist to resize and make the scrolls visible.

Edited by lsakizada

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Can you post your code ?

in most case specify width in your top div resolve the problem

Sure, even though my code is realy wrong :idea: but the idea is to have frames.

#include <GUIConstantsEx.au3>
#include <Sciter-UDF.au3>
#include <Array.au3>

_StStartup()
$ST = _StCreate(-1,-1,@DesktopWidth-500,@DesktopHeight-300,1,"Skin exemple")
GUISetBkColor(0x1D4BAA, $ST)
$fi = FileRead(@scriptdir&'\skin-view.htm')
_StLoadHtml($ST,$fi)
_StWindowAttachEventHandler($ST,"_events",$HANDLE_ALL)




While 1
sleep(32)
WEnd

Func _events($ev,$ad)
    If $ev = $HANDLE_KEY Then
        If $ad[0] = 0 Then
            $el = $ad[1]
            $code = $ad[2]
            If $code = 27 Then
                _WinAPI_DestroyWindow($ST)
                Exit
            EndIf
        EndIf
    EndIf
    
    If $ev = $HANDLE_BEHAVIOR_EVENT Then
        $bh = $ad[0]
        If $bh = $BUTTON_PRESS Then
            If _StGetAttributeByName($ad[1],"id") = "window-close" Then 
            _WinAPI_DestroyWindow($ST)
            Exit
            EndIf
        ElseIf $bh = $CONTEXT_MENU_REQUEST Then
            $fi = FileRead(@scriptdir&'\skin-view.htm')
            _StLoadHtml($ST,$fi)
        EndIf
    EndIf
EndFunc

[b]The AU3 file[/b]

The html file:

<html>
<head>
  <title>View (window) events</title>
  <style> 
  
    html 
    { 
        background-color:transparent;
        font:10pt Verdana; 
        //overflow:hidden;
        background-color:rgba(137,120,137,1);
        //background-color:transparent;
        //background-image:url(back.png);
        //background-repeat:expand;
        //background-position:8px 8px 8px 8px;
        OVERFLOW-Y: hidden;
    }



    body 
    { 
    
        //padding:3px;
        margin:0;
        width:100%%; 
        height:100%%;
        OVERFLOW-Y: hidden;
    //prototype: Body;
    //background-color:transparent;
    }

    #topbar
    {
        padding:3px;
        background-color:rgba(137,0,137,0.55);
        flow:horizontal;
        margin-bottom:3px;
    }

    #topbar #window-caption 
    {
        color: #274749;
     //background-color: white;
     //opacity: 0.75;
            padding:0 4px;
         margin:0 4px;
        height:*;
    outline:3px glow #B0CFD1 1px;
    }
    #window-content
    {
        background-color:transparent;
    padding:3px;
        width:100%%; 
        height:100%%; 
        overflow:hidden;
    }
    #topbar widget[type="button"] 
    {
        width:1em;
        height:1em;
        background-image:none;
    transition:none;
        padding:1px;
        font-family: marlett;
        font-size:10pt;
        color: #274749;
        border:1px solid #B0CFD1;
        text-align:center;
        vertical-align:center;
        margin:0;
    }
    #topbar widget[type="button"]:hover 
    {
        color:orange;
        border-color:orange;
        background-color:#B0CFD1;
    } 
    #topbar widget[type="button"]:active 
    {
        background-color:#274749;
    } 

    #topbar widget#window-minimize,
    #topbar widget#window-maximize { margin-right:2px; } 

    #topbar widget#window-icon
    {
        foreground-image:url(icon.png);
        foreground-repeat:no-repeat;
        foreground-position:50% 50%;
    }

    #bottombar 
    {
        background-color:rgba(137,130,0,0.75);
        margin-top:3px;
        flow:horizontal;
    }

    #bottombar #window-corner
    {
      margin-top:100%%;
        font-family: marlett;
        font-size:15pt;
        color: #274749;
        width:min-intrinsic;
    }

    #bottombar #window-status
    {
        color: #274749;
        font-size:9pt;
    margin:0;
    }
  
  div#test
  {
    widht:100px;
    height:100px;
    border:1px solid transparent;
overflow:hidden;
  }
 
  </style>
  <script type="text/tiscript">
  
  if( self.parent )
    return; // loading in the <frame>, don't do the rest. 
    
  // this is root document of the view    

  // setup window, remove standard window frame
  view.frame = false;
    
  // onStateChanged handler of the view object  
  function view.onStateChanged()
  {
    switch( view.state ) 
    {
      case View.WINDOW_MAXIMIZED:  self.select("#window-maximize").text = "2"; break;
      case View.WINDOW_SHOWN:      self.select("#window-maximize").text = "1"; break;
    }
  }
 

  /*class Body: Behavior
  {
    function attached()
    {
      view.move(10,10);
    }
  }*/  
  
  </script>
</head>

<body>
    <div id="topbar">
        <widget id="window-icon" type="button"></widget>
        <div id="window-caption">Sciter skinned window sample</div>
        <widget id="window-minimize" type="button">0</widget>
        <widget id="window-maximize" type="button">1</widget>
        <widget id="window-close" type="button">r</widget>
    </div>
    <div id="window-content" >
        
        <frameset rows="16%,84%"  >
        <frame scrolling="no" noresize src="http://google.com/product" name="top" frameborder="0" > 
        <frameset cols="30%,80%"  >
        <frame src="http://google.com" name="left"  >
        <frame src="http://google.com" name="right"  >
        </frameset>
        </frameset>

 
    </div>
    <div id="bottombar">
        <p id="window-status">This is the <i>status</i>...</p>
        <div id="window-corner">o</div>
    </div>

</body>
</html>

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

You want display url or your html in frame ?

I guess html because its intended to be GUI app.

EDIT: Actually, I am usig three html files right.html left.html and top.html, but I did not wanted to post all files...

Edited by lsakizada

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

try this :

<html>
<head>
  <title>View (window) events</title>
  <style> 
  
    html 
    { 
        background-color:transparent;
        font:10pt Verdana; 
        //overflow:hidden;
        background-color:rgba(137,120,137,1);
        //background-color:transparent;
        //background-image:url(back.png);
        //background-repeat:expand;
        //background-position:8px 8px 8px 8px;
        OVERFLOW-Y: hidden;
        
    }



    body 
    { 
    
        //padding:3px;
        margin:0;
        width:100%%; 
        height:100%%;
        OVERFLOW-Y: hidden;
    //prototype: Body;
    //background-color:transparent;
    min-height:500px;
    }

    #topbar
    {
        padding:3px;
        background-color:rgba(137,0,137,0.55);
        flow:horizontal;
        margin-bottom:3px;
    }

    #topbar #window-caption 
    {
        color: #274749;
     //background-color: white;
     //opacity: 0.75;
            padding:0 4px;
         margin:0 4px;
        height:*;
    outline:3px glow #B0CFD1 1px;
    }
    #window-content
    {
        background-color:transparent;
    padding:3px;
        width:100%%; 
        height:100%%; 
        overflow:hidden;
        
    }
    #topbar widget[type="button"] 
    {
        width:1em;
        height:1em;
        background-image:none;
    transition:none;
        padding:1px;
        font-family: marlett;
        font-size:10pt;
        color: #274749;
        border:1px solid #B0CFD1;
        text-align:center;
        vertical-align:center;
        margin:0;
    }
    #topbar widget[type="button"]:hover 
    {
        color:orange;
        border-color:orange;
        background-color:#B0CFD1;
    } 
    #topbar widget[type="button"]:active 
    {
        background-color:#274749;
    } 

    #topbar widget#window-minimize,
    #topbar widget#window-maximize { margin-right:2px; } 

    #topbar widget#window-icon
    {
        foreground-image:url(icon.png);
        foreground-repeat:no-repeat;
        foreground-position:50% 50%;
    }

    #bottombar 
    {
        background-color:rgba(137,130,0,0.75);
        margin-top:3px;
        flow:horizontal;
    }

    #bottombar #window-corner
    {
      margin-top:100%%;
        font-family: marlett;
        font-size:15pt;
        color: #274749;
        width:min-intrinsic;
    }

    #bottombar #window-status
    {
        color: #274749;
        font-size:9pt;
    margin:0;
    }
    
  .hcontainer { 
        width:100%%; height:100%%;  
        flow:horizontal;
        behavior:frame-set;
        border-spacing: 4px; /* width of splitter */
    }
    #top {
    flow:horizontal;
    width:100%%; 
    height:200px; 
    behavior:frame-set;
        border-spacing: 4px; /* width of splitter */
        background-color:window;
    }
    .vcontainer { 
        width:100%%; height:100%%;  
        flow:vertical;
        behavior:frame-set;
        border-spacing: 4px; /* width of splitter */
    }
        
    .left 
    {
      height:100%%; 
      margin:0;
      width:200px;    
      border:1px solid threedface;
      background-color:window;
    }
        
    .right
    {
      height:100%%; 
      width:100%%;  
    margin:0;  
      border:1px solid threedface;
      background-color:window;
    }
  </style>
  <script type="text/tiscript">
  
  if( self.parent )
    return; // loading in the <frame>, don't do the rest. 
    
  // this is root document of the view    

  // setup window, remove standard window frame
  view.frame = false;
    
  // onStateChanged handler of the view object  
  function view.onStateChanged()
  {
    switch( view.state ) 
    {
      case View.WINDOW_MAXIMIZED:  self.select("#window-maximize").text = "2"; break;
      case View.WINDOW_SHOWN:      self.select("#window-maximize").text = "1"; break;
    }
  }
 

  /*class Body: Behavior
  {
    function attached()
    {
      view.move(10,10);
    }
  }*/  
  
  </script>
</head>

<body>
    <div id="topbar">
        <widget id="window-icon" type="button"></widget>
        <div id="window-caption">Sciter skinned window sample</div>
        <widget id="window-minimize" type="button">0</widget>
        <widget id="window-maximize" type="button">1</widget>
        <widget id="window-close" type="button">r</widget>
    </div>
    <div id="window-content" class="vcontainer" >
    <div id="top">  
        Top : min height=200px
    </div>
    <div class="hcontainer">    
        <div class="left" style="min-width:100px;">Left 200px fixed</div>
        <div class="right">right</div>
    </div>    
    </div>
    <div id="bottombar">
        <p id="window-status">This is the <i>status</i>...</p>
        <div id="window-corner">o</div>
    </div>

</body>
</html>

i found in html_samples\frames\behaviors.htm

htmlayout support <include> tag for include your 3 html file in this. see http://www.terrainformatica.com/htmlayout/tags.whtm

Link to comment
Share on other sites

try this :

<html>
<head>
  <title>View (window) events</title>
  <style> 
  
    html 
    { 
        background-color:transparent;
        font:10pt Verdana; 
        //overflow:hidden;
        background-color:rgba(137,120,137,1);
        //background-color:transparent;
        //background-image:url(back.png);
        //background-repeat:expand;
        //background-position:8px 8px 8px 8px;
        OVERFLOW-Y: hidden;
        
    }



    body 
    { 
    
        //padding:3px;
        margin:0;
        width:100%%; 
        height:100%%;
        OVERFLOW-Y: hidden;
    //prototype: Body;
    //background-color:transparent;
    min-height:500px;
    }

    #topbar
    {
        padding:3px;
        background-color:rgba(137,0,137,0.55);
        flow:horizontal;
        margin-bottom:3px;
    }

    #topbar #window-caption 
    {
        color: #274749;
     //background-color: white;
     //opacity: 0.75;
            padding:0 4px;
         margin:0 4px;
        height:*;
    outline:3px glow #B0CFD1 1px;
    }
    #window-content
    {
        background-color:transparent;
    padding:3px;
        width:100%%; 
        height:100%%; 
        overflow:hidden;
        
    }
    #topbar widget[type="button"] 
    {
        width:1em;
        height:1em;
        background-image:none;
    transition:none;
        padding:1px;
        font-family: marlett;
        font-size:10pt;
        color: #274749;
        border:1px solid #B0CFD1;
        text-align:center;
        vertical-align:center;
        margin:0;
    }
    #topbar widget[type="button"]:hover 
    {
        color:orange;
        border-color:orange;
        background-color:#B0CFD1;
    } 
    #topbar widget[type="button"]:active 
    {
        background-color:#274749;
    } 

    #topbar widget#window-minimize,
    #topbar widget#window-maximize { margin-right:2px; } 

    #topbar widget#window-icon
    {
        foreground-image:url(icon.png);
        foreground-repeat:no-repeat;
        foreground-position:50% 50%;
    }

    #bottombar 
    {
        background-color:rgba(137,130,0,0.75);
        margin-top:3px;
        flow:horizontal;
    }

    #bottombar #window-corner
    {
      margin-top:100%%;
        font-family: marlett;
        font-size:15pt;
        color: #274749;
        width:min-intrinsic;
    }

    #bottombar #window-status
    {
        color: #274749;
        font-size:9pt;
    margin:0;
    }
    
  .hcontainer { 
        width:100%%; height:100%%;  
        flow:horizontal;
        behavior:frame-set;
        border-spacing: 4px; /* width of splitter */
    }
    #top {
    flow:horizontal;
    width:100%%; 
    height:200px; 
    behavior:frame-set;
        border-spacing: 4px; /* width of splitter */
        background-color:window;
    }
    .vcontainer { 
        width:100%%; height:100%%;  
        flow:vertical;
        behavior:frame-set;
        border-spacing: 4px; /* width of splitter */
    }
        
    .left 
    {
      height:100%%; 
      margin:0;
      width:200px;    
      border:1px solid threedface;
      background-color:window;
    }
        
    .right
    {
      height:100%%; 
      width:100%%;  
    margin:0;  
      border:1px solid threedface;
      background-color:window;
    }
  </style>
  <script type="text/tiscript">
  
  if( self.parent )
    return; // loading in the <frame>, don't do the rest. 
    
  // this is root document of the view    

  // setup window, remove standard window frame
  view.frame = false;
    
  // onStateChanged handler of the view object  
  function view.onStateChanged()
  {
    switch( view.state ) 
    {
      case View.WINDOW_MAXIMIZED:  self.select("#window-maximize").text = "2"; break;
      case View.WINDOW_SHOWN:      self.select("#window-maximize").text = "1"; break;
    }
  }
 

  /*class Body: Behavior
  {
    function attached()
    {
      view.move(10,10);
    }
  }*/  
  
  </script>
</head>

<body>
    <div id="topbar">
        <widget id="window-icon" type="button"></widget>
        <div id="window-caption">Sciter skinned window sample</div>
        <widget id="window-minimize" type="button">0</widget>
        <widget id="window-maximize" type="button">1</widget>
        <widget id="window-close" type="button">r</widget>
    </div>
    <div id="window-content" class="vcontainer" >
    <div id="top">  
        Top : min height=200px
    </div>
    <div class="hcontainer">    
        <div class="left" style="min-width:100px;">Left 200px fixed</div>
        <div class="right">right</div>
    </div>    
    </div>
    <div id="bottombar">
        <p id="window-status">This is the <i>status</i>...</p>
        <div id="window-corner">o</div>
    </div>

</body>
</html>

i found in html_samples\frames\behaviors.htm

htmlayout support <include> tag for include your 3 html file in this. see http://www.terrainformatica.com/htmlayout/tags.whtm

This is almost what I wanted to achive.

I wanted a fixed size for the top frameset.

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

<html>
<head>
  <title>View (window) events</title>
  <style> 
  
    html 
    { 
        background-color:transparent;
        font:10pt Verdana; 
        //overflow:hidden;
        background-color:rgba(137,120,137,1);
        //background-color:transparent;
        //background-image:url(back.png);
        //background-repeat:expand;
        //background-position:8px 8px 8px 8px;
        OVERFLOW-Y: hidden;
        
    }



    body 
    { 
    
        //padding:3px;
        margin:0;
        width:100%%; 
        height:100%%;
        OVERFLOW-Y: hidden;
    //prototype: Body;
    //background-color:transparent;
    min-height:500px;
    }

    #topbar
    {
        padding:3px;
        background-color:rgba(137,0,137,0.55);
        flow:horizontal;
        margin-bottom:3px;
    }

    #topbar #window-caption 
    {
        color: #274749;
     //background-color: white;
     //opacity: 0.75;
            padding:0 4px;
         margin:0 4px;
        height:*;
    outline:3px glow #B0CFD1 1px;
    }
    #window-content
    {
        background-color:transparent;
    padding:3px;
        width:100%%; 
        height:100%%; 
        overflow:hidden;
        
    }
    #topbar widget[type="button"] 
    {
        width:1em;
        height:1em;
        background-image:none;
    transition:none;
        padding:1px;
        font-family: marlett;
        font-size:10pt;
        color: #274749;
        border:1px solid #B0CFD1;
        text-align:center;
        vertical-align:center;
        margin:0;
    }
    #topbar widget[type="button"]:hover 
    {
        color:orange;
        border-color:orange;
        background-color:#B0CFD1;
    } 
    #topbar widget[type="button"]:active 
    {
        background-color:#274749;
    } 

    #topbar widget#window-minimize,
    #topbar widget#window-maximize { margin-right:2px; } 

    #topbar widget#window-icon
    {
        foreground-image:url(icon.png);
        foreground-repeat:no-repeat;
        foreground-position:50% 50%;
    }

    #bottombar 
    {
        background-color:rgba(137,130,0,0.75);
        margin-top:3px;
        flow:horizontal;
    }

    #bottombar #window-corner
    {
      margin-top:100%%;
        font-family: marlett;
        font-size:15pt;
        color: #274749;
        width:min-intrinsic;
    }

    #bottombar #window-status
    {
        color: #274749;
        font-size:9pt;
    margin:0;
    }
    
  .hcontainer { 
        width:100%%; height:100%%;  
        flow:horizontal;
        behavior:frame-set;
        border-spacing: 4px; /* width of splitter */
    }
    #top {
    width:100%%; 
    height:200px; 
    border-spacing: 4px; /* width of splitter */
    background-color:window;
    }
            
    .left 
    {
      height:100%%; 
      margin:0;
      width:200px;    
      border:1px solid threedface;
      background-color:window;
    }
        
    .right
    {
      height:100%%; 
      width:100%%;  
    margin:0;  
      border:1px solid threedface;
      background-color:window;
    }
  </style>
  <script type="text/tiscript">
  
  if( self.parent )
    return; // loading in the <frame>, don't do the rest. 
    
  // this is root document of the view    

  // setup window, remove standard window frame
  view.frame = false;
    
  // onStateChanged handler of the view object  
  function view.onStateChanged()
  {
    switch( view.state ) 
    {
      case View.WINDOW_MAXIMIZED:  self.select("#window-maximize").text = "2"; break;
      case View.WINDOW_SHOWN:      self.select("#window-maximize").text = "1"; break;
    }
  }
 

  /*class Body: Behavior
  {
    function attached()
    {
      view.move(10,10);
    }
  }*/  
  
  </script>
</head>

<body>
    <div id="topbar">
        <widget id="window-icon" type="button"></widget>
        <div id="window-caption">Sciter skinned window sample</div>
        <widget id="window-minimize" type="button">0</widget>
        <widget id="window-maximize" type="button">1</widget>
        <widget id="window-close" type="button">r</widget>
    </div>
    <div id="window-content">
    <div id="top">  
        Top 
    </div>
    <div class="hcontainer">    
        <div class="left" style="min-width:100px;">Left 200px fixed</div>
        <div class="right">right</div>
    </div>    
    </div>
    <div id="bottombar">
        <p id="window-status">This is the <i>status</i>...</p>
        <div id="window-corner">o</div>
    </div>

</body>
</html>

if you don't want the sizer between left and right remove "behavior:frame-set;" in .hcontainer

Edited by GMib
Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...