Jump to content

Status Bar


rysiora
 Share

Recommended Posts

ToolTips

This ToolTip text is displayed in two situations:

  • When the corresponding pane in the status bar contains only an icon.
  • When the corresponding pane in the status bar contains text that is truncated due to the size of the pane.
opt("MustDeclareVars", 1)

#include-once
#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>


Local $gui, $StatusBar1, $ret0, $ret1, $msg, $ret2, $retl1, $retcode, $asize[1]
Local $a[3] = [100, 350, -1]
Local $s[3] = ["New Text", "How about music", "Even More Text"]
$gui = GUICreate("StatusBar GUI", 500, -1, -1, -1, $WS_SIZEBOX)
GUISetState(@SW_SHOW)

$StatusBar1 = _GuiCtrlCreateStatusBar ($gui, $a, "")
_GuiCtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar1, "int", $SB_SETBKCOLOR, "int", 0, "int", _ReverseColorOrder(0xffff00))
_GuiCtrlStatusBarSetTip($StatusBar1,0,"Part 1")
_GuiCtrlStatusBarSetTip($StatusBar1,1,"Part 2")
_GuiCtrlStatusBarSetTip($StatusBar1,2,"Part 3")

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
 ;;;;;
    EndSelect
    
WEnd

Func _GuiCtrlStatusBarSetIcon($StatusBar, $i_part, $szIconFile, $iconID)
    Local $hIcon = DllStructCreate("int")
    Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", "shell32.dll", "int", $iconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1)
    $result = $result[0]
    If $result > 0 Then
        $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", DllStructGetData($hIcon, 1))
    EndIf
    DllCall("user32.dll", "int", "DestroyIcon", "hwnd", DllStructGetPtr($hIcon))
    $hIcon = 0
    Return $result[0]
EndFunc

Func _GuiCtrlStatusBarSetTip($StatusBar,$i_Part,$s_ToolTip)
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")
    DllStructSetData($struct,1,$s_ToolTip)
    if @error Then
        MsgBox(0,"","Error in DllStructCreate " & @error);
        SetError(-1)
        Return -1
    endif
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETTIPTEXT, "int", $i_Part, "int", DllStructGetPtr($struct))
    $struct = 0
EndFunc

Func _ReverseColorOrder($v_color)
   Local $tc = Hex(String($v_color), 6)
   Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
EndFunc;==>_ReverseColorOrder

opt("MustDeclareVars", 1)
#include-once
#include <Array.au3>
#include <guiconstants.au3>
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1++
; Language:    English
; Description:  Functions that assist with the Statusbar control
;
; ------------------------------------------------------------------------------
;=== Globals
Global $debug = True

Global Const $CCS_TOP = 0x1
Global Const $CCS_NOMOVEY = 0x2
Global Const $CCS_BOTTOM = 0x3
Global Const $CCS_NORESIZE = 0x4
Global Const $CCS_NOPARENTALIGN = 0x8
Global Const $CCS_NOHILITE = 0x10
Global Const $CCS_ADJUSTABLE = 0x20
Global Const $CCS_NODIVIDER = 0x40
;=== Status Bar Styles
Global Const $SBARS_SIZEGRIP = 0x100
;=== uFlags
Global Const $SBT_SUNKEN = 0x0;Default
Global Const $SBT_NOBORDERS = 0x100;The text is drawn without borders.
Global Const $SBT_POPOUT = 0x200; The text is drawn with a border to appear higher than the plane of the window.
Global Const $SBT_RTLREADING = 0x400;SB_SETTEXT, SB_SETTEXT, SB_GETTEXTLENGTH flags only: Displays text using right-to-left reading order on Hebrew or Arabic systems.
Global Const $SBT_OWNERDRAW = 0x1000;The text is drawn by the parent window.
;=== Messages to send to Statusbar
Global Const $SB_SETTEXT = 0x401
Global Const $SB_GETTEXT = 0x402
Global Const $SB_GETTEXTLENGTH = 0x403
Global Const $SB_SETPARTS = 0x404
Global Const $SB_GETPARTS = 0x406
Global Const $SB_GETBORDERS = 0x407
Global Const $SB_SETMINHEIGHT = 0x408
Global Const $SB_SIMPLE = 0x409
Global Const $SB_GETRECT = 0x40A
Global Const $SB_ISSIMPLE = 0x40E
Global Const $LowOrder = 0xFFFF
Local Const $WM_USER = 0x400
Global Const $SB_SETICON = ($WM_USER+15)
Local Const $CCM_FIRST = 0x2000
Local Const $CCM_SETBKCOLOR = ($CCM_FIRST + 1)
Global Const $SB_SETBKCOLOR = $CCM_SETBKCOLOR
Global Const $SB_SETTIPTEXT = ($WM_USER+16)
Global Const $SBT_TOOLTIPS = 0x800
;=== End Globals

;=== function list
;===============================================================================
;_GuiCtrlCreateStatusBar
;_GuiCtrlStatusBarSetText
;_GuiCtrlStatusBarGetText
;_GuiCtrlStatusBarGetTextLength
;_GuiCtrlStatusBarSetParts
;_GuiCtrlStatusBarGetParts
;_GuiCtrlStatusBarResize
;********** ToDo **************
;_GuiCtrlStatusBarGetBorders
;_GuiCtrlStatusBarSetMinHeight
;_GuiCtrlStatusBarGetRect
;_GUICtrlStatusBarSetExtendedStyle

;~ Private Declare Function GetAddrOf Lib "KERNEL32" Alias "MulDiv" (nNumber As Any, Optional ByVal nNumerator As Long = 1, Optional ByVal nDenominator As Long = 1) As Long
;~  ' This is the dummy function used to get the addres of a VB variable.
Func AddressOf($v_Variable)
;~   Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" _
;~ (Var() as Any) As Long
   Local $pointer
   $pointer = DllCall("KERNEL32.dll", "long", "MulDiv", "ptr", $v_Variable[0])
;$pointer =dllcall("msvbvm60.dll","long","VarPtr","long",$v_Variable[0])
   If @error Then
      If $debug Then MsgBox(0, "Error:", "Error:>" & @error & @CRLF)
      Return 0
   Else
      Return $pointer
   EndIf
   
EndFunc;==>AddressOf
;===============================================================================
;
; Description:          _GuiCtrlCreateStatusBar
; Parameter(s):     $h_Gui   Handle to parent window
;                   $i_Panels   Nubmer of panesl to create
;                   $i_PanelWidth
; Requirement:
; Return Value(s):  Returns hWhnd if successful, or 0 with error set to 1 otherwise.
; User CallTip:     _GuiCtrlCreateStatusBar($i_Panels,$a_PanelWidth, $s_PanelText) Creates Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlCreateStatusBar($h_Gui, $a_PanelWidth, $s_PanelText)
   If Not IsArray($a_PanelWidth) Then
      Local $temp_width = $a_PanelWidth
      Dim $a_PanelWidth[1] = [$temp_width]
   EndIf
   If Not IsArray($s_PanelText) Then
      Local $temp_string = $s_PanelText
      Dim $s_PanelText[1] = [$temp_string]
   EndIf
   If Not IsHWnd($h_Gui) Then $h_Gui = HWnd($h_Gui)
   Local $hwnd_Bar1, $sta, $ptr, $emsg[6], $x, $retcode
   $hwnd_Bar1 = DllCall("comctl32.dll", "long", "CreateStatusWindow", "long", BitOR($WS_CHILD, $WS_VISIBLE, $SBT_TOOLTIPS), "str", "", "hwnd", $h_Gui, "int", 0)
   
   If Not @error Then
      $retcode = _GuiCtrlStatusBarSetParts($hwnd_Bar1[0], UBound($a_PanelWidth), $a_PanelWidth)
      For $x = 0 To UBound($s_PanelText) - 1
         _GuiCtrlStatusBarSetText($hwnd_Bar1[0], $s_PanelText[$x], $x)
      Next
      
      Return $hwnd_Bar1[0]
   EndIf
   SetError(1)
   Return 0
EndFunc;==>   _GuiCtrlCreateStatusBar 

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetText
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $s_Data  The text to display in the panel
;                   $i_Panel  The panel to hold the text
; Requirement:
; Return Value(s):  DllCall return value
; User CallTip:     _GuiCtrlStatusBarSetText($h_Bar,$s_Data="",$i_Panel=0) Set Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetText($h_Bar, $s_Data = "", $i_Panel = 0)
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
   Return DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_SETTEXT, "int", $i_Panel, "str", $s_Data)
EndFunc;==>_GuiCtrlStatusBarSetText

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetText
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $i_Panel  The panel to retreive the text from
; Requirement:
; Return Value(s):  True on success
; User CallTip:     _GuiCtrlStatusBarGetText($h_Bar,$s_Data="",$i_Panel=0) Gets Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetText($h_Bar, $i_Panel = 0)
;== there is a built in function to use for this. See help documentation
   Local $v_Ret
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
   $v_Ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_GETTEXT, "int", $i_Panel, "strptr", "")
   Return $v_Ret[4]
EndFunc;==>_GuiCtrlStatusBarGetText

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetTextLength
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $i_Panels   Nubmer of the panesl to retrieve length from
;
; Requirement:
; Return Value(s):  Text Length
; User CallTip:     _GuiCtrlStatusBarGetTextLength ($h_Bar,$i_Panel). (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetTextLength($h_Bar, $i_Panel)
   Local $ret
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
;GetParts = SendMessage(hStatBar, SB_GETPARTS, 0, ByVal 0)
   $ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_GETTEXTLENGTH, "int", $i_Panel, "int", 0)
   Return $ret[0]
EndFunc;==>_GuiCtrlStatusBarGetTextLength

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetParts
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $i_Panels   Nubmer of panesl to create
;                   $i_PanelWidth
;
; Requirement:
; Return Value(s):
; User CallTip:     _GuiCtrlStatusBarSetParts ($h_Bar,$i_Panels,$i_PanelWidth = 100). (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetParts($h_Bar, $i_Panels, $a_PanelWidth = "")
   Local $sta, $emsg[6], $ptr, $dll_ret
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
;=== Set each panel to be same size and assign the last one the remainder
   If Not IsArray($a_PanelWidth) Then
      Dim $a_PanelWidth[$i_Panels], $panel, $size, $strPanel, $struct_Panel
      $size = WinGetClientSize("")
      For $panel = 0 To $i_Panels - 1
         $a_PanelWidth[$panel] = Int(($size[0] / $i_Panels) * $panel + 1)
      Next
      $a_PanelWidth[$i_Panels - 1] = -1
   EndIf
;== end set sizing
   
   $sta = _CreateStuctFromArray($a_PanelWidth, "int")
   If @error Then Return 0
   
   $emsg[0] = "No Error."
   $emsg[1] = "Struct not a correct struct returned by DllStructCreate."
   $emsg[2] = "Element is out of bounds."
   $emsg[3] = ""
   $emsg[4] = ""
   $emsg[5] = ""
   
;~   $ptr = DllStructGetPtr($sta, 1)
;~   If @error Then
;~       If $debug Then ConsoleWrite("ptr>" & $ptr & @CRLF & "Error:>" & $emsg[@error] & @CRLF)
;~       SetError(1)
;~       Return 0
;~   EndIf
   
   $emsg[0] = "No error."
   $emsg[1] = "Unable to use the DLL file."
   $emsg[2] = ' unknown "return type".'
   
   $dll_ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_SETPARTS, _
         "int", $i_Panels, "ptr", DllStructGetPtr($sta))
   If @error Then
      If $debug Then ConsoleWrite("DllCall Error:>" & $emsg[@error] & @CRLF)
      SetError(1)
      Return 0
   EndIf
;== Sometimes this needs to be called in order to update the status bar.
   _GuiCtrlStatusBarResize($h_Bar)
   $sta = ""
   Return -1
EndFunc;==>_GuiCtrlStatusBarSetParts

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetParts
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;
;
;
; Requirement:
; Return Value(s):
; User CallTip:     _GuiCtrlStatusBar($h_Bar). (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetParts($h_Bar)
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
;GetParts = SendMessage(hStatBar, SB_GETPARTS, 0, ByVal 0)
   Return DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_GETPARTS, "int", 0, "int", 0)
EndFunc;==>_GuiCtrlStatusBarGetParts

;===============================================================================
;
; Description:          _GuiCtrlStatusBarResize
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;
; Requirement:
; Return Value(s):
; User CallTip:     _GuiCtrlStatusBarResize($h_Bar)Resize Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarResize($h_Bar)
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
   Return DllCall("user32.dll", "long", "MoveWindow", "hwnd", $h_Bar, "int", 0, "int", 0, "int", 0, "int", 0)
EndFunc;==>_GuiCtrlStatusBarResize
;===============================================================================
;
; Description:          CreateStructFromArray
; Parameter(s):     $a_Variable array to create struct with
;                   $structType, the SINGLE type of struct to create.
; Requirement:
; Return Value(s):
; User CallTip:     _CreateStructFromArray
; Author(s):
; Note(s):
;===============================================================================

Func _CreateStuctFromArray($a_Variable, $structType)
   If Not IsArray($a_Variable) Then
      SetError(1)
      Return
   EndIf
   Local $a_ctr, $strVar, $struct, $emsg[6]
   For $a_ctr = 0 To UBound($a_Variable) - 1
      $strVar &= $structType & ";"
   Next
   $strVar = StringTrimRight($strVar, 1)
   $emsg[0] = "No Error."
   $emsg[1] = "Variable passed to DllStructCreate was not a string."
   $emsg[2] = "There is an unknown Data Type in the string passed. "
   $emsg[3] = "Failed to allocate the memory needed for the struct, or Pointer = 0."
   $emsg[4] = "Error allocating memory for the passed string."
   $emsg[5] = ""
   
   $struct = DllStructCreate($strVar)
   If @error Then
      If $debug Then MsgBox(0, "Error:", "Error:>" & $emsg[@error] & @CRLF)
      SetError(1)
      Return 0
   EndIf
   
   $emsg[0] = 'No Error. '
   $emsg[1] = 'Struct not a correct struct returned by DllStructCreate.'
   $emsg[2] = 'Element value out of range. '
   $emsg[3] = 'index would be outside of the struct.'
   $emsg[4] = 'Element data type is unknown'
   $emsg[5] = 'index < 0.'
   For $a_ctr = 0 To UBound($a_Variable) - 1
      DllStructSetData($struct, ($a_ctr) + 1, $a_Variable[$a_ctr])
      If @error Then
         If $debug Then ConsoleWrite("Set>" & $a_ctr & @CRLF & "Error:>" & $emsg[@error] & @CRLF)
         SetError(1)
         Return 0
      EndIf
   Next
   Return $struct
EndFunc;==>_CreateStuctFromArray
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

min height

opt("MustDeclareVars", 1)

#include-once
#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>


Local $gui, $StatusBar1, $ret0, $ret1, $msg, $ret2, $retl1, $retcode, $asize[1]
Local $a[3] = [100, 350, -1]
Local $s[3] = ["New Text", "How about music", "Even More Text"]
$gui = GUICreate("StatusBar GUI", 500, -1, -1, -1, $WS_SIZEBOX)
GUISetState(@SW_SHOW)

$StatusBar1 = _GuiCtrlCreateStatusBar ($gui, $a, "")
_GuiCtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar1, "int", $SB_SETBKCOLOR, "int", 0, "int", _ReverseColorOrder(0xffff00))
_GuiCtrlStatusBarSetTip($StatusBar1,0,"Part 1")
_GuiCtrlStatusBarSetTip($StatusBar1,1,"Part 2")
_GuiCtrlStatusBarSetTip($StatusBar1,2,"Part 3")
_GuiCtrlStatusBarSetMinHeight($StatusBar1, 50)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
   ;;;;;
    EndSelect
    
WEnd

Func _GuiCtrlStatusBarSetIcon($StatusBar, $i_part, $szIconFile, $iconID)
    Local $hIcon = DllStructCreate("int")
    Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", "shell32.dll", "int", $iconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1)
    $result = $result[0]
    If $result > 0 Then
        $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", DllStructGetData($hIcon, 1))
    EndIf
    DllCall("user32.dll", "int", "DestroyIcon", "hwnd", DllStructGetPtr($hIcon))
    $hIcon = 0
    Return $result[0]
EndFunc

Func _GuiCtrlStatusBarSetTip($StatusBar,$i_Part,$s_ToolTip)
 If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
 Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")
 DllStructSetData($struct,1,$s_ToolTip)
 if @error Then
  MsgBox(0,"","Error in DllStructCreate " & @error);
  SetError(-1)
  Return -1
 endif
 DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETTIPTEXT, "int", $i_Part, "int", DllStructGetPtr($struct))
 $struct = 0
EndFunc

Func _GuiCtrlStatusBarSetMinHeight($StatusBar, $i_MinHeight)
 DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETMINHEIGHT, "int", $i_MinHeight, "int", 0)
 _GuiCtrlStatusBarResize($StatusBar)
EndFunc

Func _ReverseColorOrder($v_color)
   Local $tc = Hex(String($v_color), 6)
   Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
EndFunc;==>_ReverseColorOrder

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Func _GuiCtrlStatusBarGetRect($StatusBar, $i_part)
;~  typedef struct _RECT {
;~    LONG left;
;~    LONG top;
;~    LONG right;
;~    LONG bottom;
;~  } RECT, *PRECT;
   Local $RECT = DllStructCreate("int;int;int;int")
   Local $p, $ret
   If @error Then
      Return @error
   EndIf
   If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETRECT, "int", $i_part, "ptr", DllStructGetPtr($RECT))
    If (Not $a_ret[0]) Then
        $RECT = 0
        Return 0
   Else
        Local $a_rect[5], $x
        $a_rect[0] = 4
        For $x = 1 To 4
            $a_rect[$x] = DllStructGetData($RECT,$x)
        Next
        $RECT = 0
        Return $a_rect
    EndIf
EndFunc

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

opt("MustDeclareVars", 1)

#include-once
#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $ret0, $ret1, $msg, $ret2, $retl1, $retcode, $asize[1]
Local $a[3] = [100, 350, -1]
Local $s[3] = ["New Text", "How about music", "Even More Text"]
$gui = GUICreate("StatusBar GUI", 500, -1, -1, -1, $WS_SIZEBOX)
GUISetState(@SW_SHOW)

$StatusBar1 = _GuiCtrlCreateStatusBar ($gui, $a, "")
_GuiCtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar1, "int", $SB_SETBKCOLOR, "int", 0, "int", _ReverseColorOrder(0xffff00))
_GuiCtrlStatusBarSetTip($StatusBar1, 0, "Part 1")
_GuiCtrlStatusBarSetTip($StatusBar1, 1, "Part 2")
_GuiCtrlStatusBarSetTip($StatusBar1, 2, "Part 3")
_GuiCtrlStatusBarSetMinHeight($StatusBar1, 50)

Local $a_rect = _GuiCtrlStatusBarGetRect($StatusBar1, 0)
If IsArray($a_rect) Then _
        MsgBox(0, "Rect", "Left: " & $a_rect[1] & @LF & _
        "Top: " & $a_rect[2] & @LF & _
        "Right: " & $a_rect[3] & @LF & _
        "Bottom: " & $a_rect[4])

Local $a_borders = _GuiCtrlStatusBarGetBorders($StatusBar1)
If IsArray($a_borders) Then _
        MsgBox(0, "Borders", "width of the horizontal border: " & $a_rect[0] & @LF & _
        "width of the vertical border: " & $a_rect[1] & @LF & _
        "width of the border between rectangles: " & $a_rect[2])

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
        ;;;;;
    EndSelect
    
WEnd

Func _GuiCtrlStatusBarSetIcon($StatusBar, $i_part, $szIconFile, $iconID)
    Local $hIcon = DllStructCreate("int")
    Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", "shell32.dll", "int", $iconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1)
    $result = $result[0]
    If $result > 0 Then
        $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", DllStructGetData($hIcon, 1))
    EndIf
    DllCall("user32.dll", "int", "DestroyIcon", "hwnd", DllStructGetPtr($hIcon))
    $hIcon = 0
    Return $result[0]
EndFunc  ;==>_GuiCtrlStatusBarSetIcon

Func _GuiCtrlStatusBarSetTip($StatusBar, $i_part, $s_ToolTip)
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")
    DllStructSetData($struct, 1, $s_ToolTip)
    If @error Then
        MsgBox(0, "", "Error in DllStructCreate " & @error);
        SetError(-1)
        Return -1
    EndIf
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETTIPTEXT, "int", $i_part, "int", DllStructGetPtr($struct))
    $struct = 0
EndFunc  ;==>_GuiCtrlStatusBarSetTip

Func _GuiCtrlStatusBarSetMinHeight($StatusBar, $i_MinHeight)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETMINHEIGHT, "int", $i_MinHeight, "int", 0)
    _GuiCtrlStatusBarResize ($StatusBar)
EndFunc  ;==>_GuiCtrlStatusBarSetMinHeight

Func _GuiCtrlStatusBarGetRect($StatusBar, $i_part)
;~  typedef struct _RECT {
;~    LONG left;
;~    LONG top;
;~    LONG right;
;~    LONG bottom;
;~  } RECT, *PRECT;
    Local $RECT = DllStructCreate("int;int;int;int")
    Local $p, $ret
    If @error Then
        Return @error
    EndIf
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETRECT, "int", $i_part, "ptr", DllStructGetPtr($RECT))
    If (Not $a_ret[0]) Then
        $RECT = 0
        Return 0
    Else
        Local $a_rect[5], $x
        $a_rect[0] = 4
        For $x = 1 To 4
            $a_rect[$x] = DllStructGetData($RECT, $x)
        Next
        $RECT = 0
        Return $a_rect
    EndIf
EndFunc  ;==>_GuiCtrlStatusBarGetRect

Func _GuiCtrlStatusBarGetBorders($StatusBar)
    Local $borders = DllStructCreate("int;int;int")
    Local $p, $ret
    If @error Then
        Return @error
    EndIf
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETBORDERS, "int", 0, "ptr", DllStructGetPtr($borders))
    If (Not $a_ret[0]) Then
        $borders = 0
        Return 0
    Else
        Local $a_borders[3], $x
        For $x = 0 To 2
            $a_borders[$x] = DllStructGetData($borders, $x + 1)
        Next
        $borders = 0
        Return $a_borders
    EndIf
EndFunc  ;==>_GuiCtrlStatusBarGetBorders

Func _ReverseColorOrder($v_color)
    Local $tc = Hex(String($v_color), 6)
    Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
EndFunc  ;==>_ReverseColorOrder

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

using unicode characters?

opt("MustDeclareVars", 1)

#include-once
#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $ret0, $ret1, $msg, $ret2, $retl1, $retcode, $asize[1]
Local $a[3] = [100, 350, -1]
Local $s[3] = ["New Text", "How about music", "Even More Text"]
$gui = GUICreate("StatusBar GUI", 500, -1, -1, -1, $WS_SIZEBOX)
GUISetState(@SW_SHOW)

$StatusBar1 = _GuiCtrlCreateStatusBar ($gui, $a, $s)
_GuiCtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar1, "int", $SB_SETBKCOLOR, "int", 0, "int", _ReverseColorOrder(0xffff00))
_GuiCtrlStatusBarSetTip($StatusBar1, 0, "Part 1")
_GuiCtrlStatusBarSetTip($StatusBar1, 1, "Part 2")
_GuiCtrlStatusBarSetTip($StatusBar1, 2, "Part 3")
_GuiCtrlStatusBarSetMinHeight($StatusBar1, 50)

Local $a_rect = _GuiCtrlStatusBarGetRect($StatusBar1, 0)
If IsArray($a_rect) Then _
        MsgBox(0, "Rect", "Left: " & $a_rect[1] & @LF & _
        "Top: " & $a_rect[2] & @LF & _
        "Right: " & $a_rect[3] & @LF & _
        "Bottom: " & $a_rect[4])

Local $a_borders = _GuiCtrlStatusBarGetBorders($StatusBar1)
If IsArray($a_borders) Then _
        MsgBox(0, "Borders", "width of the horizontal border: " & $a_rect[0] & @LF & _
        "width of the vertical border: " & $a_rect[1] & @LF & _
        "width of the border between rectangles: " & $a_rect[2])
If _GuiCtrlStatusBarGetUnicode($StatusBar1) Then
    _GuiCtrlStatusBarSetText($StatusBar1,"using Unicode characters", 1)
Else
    _GuiCtrlStatusBarSetText($StatusBar1,"NOT using Unicode characters", 1)
EndIf
    
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
    ;;;;;
    EndSelect
    
WEnd

Func _GuiCtrlStatusBarSetIcon($StatusBar, $i_part, $szIconFile, $iconID)
    Local $hIcon = DllStructCreate("int")
    Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", "shell32.dll", "int", $iconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1)
    $result = $result[0]
    If $result > 0 Then
        $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", DllStructGetData($hIcon, 1))
    EndIf
    DllCall("user32.dll", "int", "DestroyIcon", "hwnd", DllStructGetPtr($hIcon))
    $hIcon = 0
    Return $result[0]
EndFunc ;==>_GuiCtrlStatusBarSetIcon

Func _GuiCtrlStatusBarSetTip($StatusBar, $i_part, $s_ToolTip)
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")
    DllStructSetData($struct, 1, $s_ToolTip)
    If @error Then
        MsgBox(0, "", "Error in DllStructCreate " & @error);
        SetError(-1)
        Return -1
    EndIf
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETTIPTEXT, "int", $i_part, "int", DllStructGetPtr($struct))
    $struct = 0
EndFunc ;==>_GuiCtrlStatusBarSetTip

Func _GuiCtrlStatusBarSetMinHeight($StatusBar, $i_MinHeight)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETMINHEIGHT, "int", $i_MinHeight, "int", 0)
    _GuiCtrlStatusBarResize ($StatusBar)
EndFunc ;==>_GuiCtrlStatusBarSetMinHeight

Func _GuiCtrlStatusBarGetRect($StatusBar, $i_part)
;~  typedef struct _RECT {
;~    LONG left;
;~    LONG top;
;~    LONG right;
;~    LONG bottom;
;~  } RECT, *PRECT;
    Local $RECT = DllStructCreate("int;int;int;int")
    Local $p, $ret
    If @error Then
        Return @error
    EndIf
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETRECT, "int", $i_part, "ptr", DllStructGetPtr($RECT))
    If (Not $a_ret[0]) Then
        $RECT = 0
        Return 0
    Else
        Local $a_rect[5], $x
        $a_rect[0] = 4
        For $x = 1 To 4
            $a_rect[$x] = DllStructGetData($RECT, $x)
        Next
        $RECT = 0
        Return $a_rect
    EndIf
EndFunc ;==>_GuiCtrlStatusBarGetRect

Func _GuiCtrlStatusBarGetBorders($StatusBar)
    Local $borders = DllStructCreate("int;int;int")
    Local $p, $ret
    If @error Then
        Return @error
    EndIf
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETBORDERS, "int", 0, "ptr", DllStructGetPtr($borders))
    If (Not $a_ret[0]) Then
        $borders = 0
        Return 0
    Else
        Local $a_borders[3], $x
        For $x = 0 To 2
            $a_borders[$x] = DllStructGetData($borders, $x + 1)
        Next
        $borders = 0
        Return $a_borders
    EndIf
EndFunc ;==>_GuiCtrlStatusBarGetBorders

Func _GuiCtrlStatusBarGetUnicode($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETUNICODEFORMAT, "int", 0, "int", 0)
    Return $a_ret[0]
EndFunc

Func _ReverseColorOrder($v_color)
    Local $tc = Hex(String($v_color), 6)
    Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
EndFunc ;==>_ReverseColorOrder

#include-once
#include <Array.au3>
#include <guiconstants.au3>
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1++
; Language:    English
; Description:  Functions that assist with the Statusbar control
;
; ------------------------------------------------------------------------------
;=== Globals
Global $debug = True

Global Const $CCS_TOP = 0x1
Global Const $CCS_NOMOVEY = 0x2
Global Const $CCS_BOTTOM = 0x3
Global Const $CCS_NORESIZE = 0x4
Global Const $CCS_NOPARENTALIGN = 0x8
Global Const $CCS_NOHILITE = 0x10
Global Const $CCS_ADJUSTABLE = 0x20
Global Const $CCS_NODIVIDER = 0x40
;=== Status Bar Styles
Global Const $SBARS_SIZEGRIP = 0x100
;=== uFlags
Global Const $SBT_SUNKEN = 0x0;Default
Global Const $SBT_NOBORDERS = 0x100;The text is drawn without borders.
Global Const $SBT_POPOUT = 0x200; The text is drawn with a border to appear higher than the plane of the window.
Global Const $SBT_RTLREADING = 0x400;SB_SETTEXT, SB_SETTEXT, SB_GETTEXTLENGTH flags only: Displays text using right-to-left reading order on Hebrew or Arabic systems.
Global Const $SBT_OWNERDRAW = 0x1000;The text is drawn by the parent window.
;=== Messages to send to Statusbar
Local Const $WM_USER = 0x400
Global Const $SB_SETTEXT = 0x401
Global Const $SB_GETTEXT = 0x402
Global Const $SB_GETTEXTLENGTH = 0x403
Global Const $SB_SETPARTS = 0x404
Global Const $SB_GETPARTS = 0x406
;~ Global Const $SB_GETBORDERS = 0x407
Global Const $SB_GETBORDERS = ($WM_USER+7)
Global Const $SB_SETMINHEIGHT = 0x408
Global Const $SB_SIMPLE = 0x409
;~ Global Const $SB_GETRECT = 0x40A
Global Const $SB_GETRECT = ($WM_USER+10)
Global Const $SB_ISSIMPLE = 0x40E
Global Const $LowOrder = 0xFFFF
Global Const $SB_SETICON = ($WM_USER+15)
Local Const $CCM_FIRST = 0x2000
Local Const $CCM_SETBKCOLOR = ($CCM_FIRST + 1)
Global Const $SB_SETBKCOLOR = $CCM_SETBKCOLOR
Global Const $SB_SETTIPTEXT = ($WM_USER+16)
Global Const $SBT_TOOLTIPS = 0x800
Local Const $CCM_GETUNICODEFORMAT = ($CCM_FIRST + 6)
Global Const $SB_GETUNICODEFORMAT = $CCM_GETUNICODEFORMAT
;=== End Globals

;=== function list
;===============================================================================
;_GuiCtrlCreateStatusBar
;_GuiCtrlStatusBarSetText
;_GuiCtrlStatusBarGetText
;_GuiCtrlStatusBarGetTextLength
;_GuiCtrlStatusBarSetParts
;_GuiCtrlStatusBarGetParts
;_GuiCtrlStatusBarResize
;********** ToDo **************
;_GuiCtrlStatusBarGetBorders
;_GuiCtrlStatusBarSetMinHeight
;_GuiCtrlStatusBarGetRect
;_GUICtrlStatusBarSetExtendedStyle

;~ Private Declare Function GetAddrOf Lib "KERNEL32" Alias "MulDiv" (nNumber As Any, Optional ByVal nNumerator As Long = 1, Optional ByVal nDenominator As Long = 1) As Long
;~  ' This is the dummy function used to get the addres of a VB variable.
Func AddressOf($v_Variable)
;~   Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" _
;~ (Var() as Any) As Long
   Local $pointer
   $pointer = DllCall("KERNEL32.dll", "long", "MulDiv", "ptr", $v_Variable[0])
;$pointer =dllcall("msvbvm60.dll","long","VarPtr","long",$v_Variable[0])
   If @error Then
      If $debug Then MsgBox(0, "Error:", "Error:>" & @error & @CRLF)
      Return 0
   Else
      Return $pointer
   EndIf
   
EndFunc;==>AddressOf
;===============================================================================
;
; Description:          _GuiCtrlCreateStatusBar
; Parameter(s):     $h_Gui   Handle to parent window
;                   $i_Panels   Nubmer of panesl to create
;                   $i_PanelWidth
; Requirement:
; Return Value(s):  Returns hWhnd if successful, or 0 with error set to 1 otherwise.
; User CallTip:     _GuiCtrlCreateStatusBar($i_Panels,$a_PanelWidth, $s_PanelText) Creates Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlCreateStatusBar($h_Gui, $a_PanelWidth, $s_PanelText)
   If Not IsArray($a_PanelWidth) Then
      Local $temp_width = $a_PanelWidth
      Dim $a_PanelWidth[1] = [$temp_width]
   EndIf
   If Not IsArray($s_PanelText) Then
      Local $temp_string = $s_PanelText
      Dim $s_PanelText[1] = [$temp_string]
   EndIf
   If Not IsHWnd($h_Gui) Then $h_Gui = HWnd($h_Gui)
   Local $hwnd_Bar1, $sta, $ptr, $emsg[6], $x, $retcode
   $hwnd_Bar1 = DllCall("comctl32.dll", "long", "CreateStatusWindow", "long", BitOR($WS_CHILD, $WS_VISIBLE, $SBT_TOOLTIPS), "str", "", "hwnd", $h_Gui, "int", 0)
   
   If Not @error Then
      $retcode = _GuiCtrlStatusBarSetParts($hwnd_Bar1[0], UBound($a_PanelWidth), $a_PanelWidth)
      For $x = 0 To UBound($s_PanelText) - 1
         _GuiCtrlStatusBarSetText($hwnd_Bar1[0], $s_PanelText[$x], $x)
      Next
      
      Return $hwnd_Bar1[0]
   EndIf
   SetError(1)
   Return 0
EndFunc;==>   _GuiCtrlCreateStatusBar 

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetText
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $s_Data  The text to display in the panel
;                   $i_Panel  The panel to hold the text
; Requirement:
; Return Value(s):  DllCall return value
; User CallTip:     _GuiCtrlStatusBarSetText($h_Bar,$s_Data="",$i_Panel=0) Set Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetText($h_Bar, $s_Data = "", $i_Panel = 0)
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
   Return DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_SETTEXT, "int", $i_Panel, "str", $s_Data)
EndFunc;==>_GuiCtrlStatusBarSetText

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetText
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $i_Panel  The panel to retreive the text from
; Requirement:
; Return Value(s):  True on success
; User CallTip:     _GuiCtrlStatusBarGetText($h_Bar,$s_Data="",$i_Panel=0) Gets Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetText($h_Bar, $i_Panel = 0)
;== there is a built in function to use for this. See help documentation
   Local $v_Ret
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
   $v_Ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_GETTEXT, "int", $i_Panel, "strptr", "")
   Return $v_Ret[4]
EndFunc;==>_GuiCtrlStatusBarGetText

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetTextLength
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $i_Panels   Nubmer of the panesl to retrieve length from
;
; Requirement:
; Return Value(s):  Text Length
; User CallTip:     _GuiCtrlStatusBarGetTextLength ($h_Bar,$i_Panel). (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetTextLength($h_Bar, $i_Panel)
   Local $ret
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
;GetParts = SendMessage(hStatBar, SB_GETPARTS, 0, ByVal 0)
   $ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_GETTEXTLENGTH, "int", $i_Panel, "int", 0)
   Return $ret[0]
EndFunc;==>_GuiCtrlStatusBarGetTextLength

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetParts
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $i_Panels   Nubmer of panesl to create
;                   $i_PanelWidth
;
; Requirement:
; Return Value(s):
; User CallTip:     _GuiCtrlStatusBarSetParts ($h_Bar,$i_Panels,$i_PanelWidth = 100). (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetParts($h_Bar, $i_Panels, $a_PanelWidth = "")
   Local $sta, $emsg[6], $ptr, $dll_ret
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
;=== Set each panel to be same size and assign the last one the remainder
   If Not IsArray($a_PanelWidth) Then
      Dim $a_PanelWidth[$i_Panels], $panel, $size, $strPanel, $struct_Panel
      $size = WinGetClientSize("")
      For $panel = 0 To $i_Panels - 1
         $a_PanelWidth[$panel] = Int(($size[0] / $i_Panels) * $panel + 1)
      Next
      $a_PanelWidth[$i_Panels - 1] = -1
   EndIf
;== end set sizing
   
   $sta = _CreateStuctFromArray($a_PanelWidth, "int")
   If @error Then Return 0
   
   $emsg[0] = "No Error."
   $emsg[1] = "Struct not a correct struct returned by DllStructCreate."
   $emsg[2] = "Element is out of bounds."
   $emsg[3] = ""
   $emsg[4] = ""
   $emsg[5] = ""
   
;~   $ptr = DllStructGetPtr($sta, 1)
;~   If @error Then
;~       If $debug Then ConsoleWrite("ptr>" & $ptr & @CRLF & "Error:>" & $emsg[@error] & @CRLF)
;~       SetError(1)
;~       Return 0
;~   EndIf
   
   $emsg[0] = "No error."
   $emsg[1] = "Unable to use the DLL file."
   $emsg[2] = ' unknown "return type".'
   
   $dll_ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_SETPARTS, _
         "int", $i_Panels, "ptr", DllStructGetPtr($sta))
   If @error Then
      If $debug Then ConsoleWrite("DllCall Error:>" & $emsg[@error] & @CRLF)
      SetError(1)
      Return 0
   EndIf
;== Sometimes this needs to be called in order to update the status bar.
   _GuiCtrlStatusBarResize($h_Bar)
   $sta = ""
   Return -1
EndFunc;==>_GuiCtrlStatusBarSetParts

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetParts
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;
;
;
; Requirement:
; Return Value(s):
; User CallTip:     _GuiCtrlStatusBar($h_Bar). (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetParts($h_Bar)
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
;GetParts = SendMessage(hStatBar, SB_GETPARTS, 0, ByVal 0)
   Return DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_GETPARTS, "int", 0, "int", 0)
EndFunc;==>_GuiCtrlStatusBarGetParts

;===============================================================================
;
; Description:          _GuiCtrlStatusBarResize
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;
; Requirement:
; Return Value(s):
; User CallTip:     _GuiCtrlStatusBarResize($h_Bar)Resize Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):        rysiora, JdeB, tonedef,
;                   Gary Frost (custompcs@charter.net), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarResize($h_Bar)
   If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
   Return DllCall("user32.dll", "long", "MoveWindow", "hwnd", $h_Bar, "int", 0, "int", 0, "int", 0, "int", 0)
EndFunc;==>_GuiCtrlStatusBarResize
;===============================================================================
;
; Description:          CreateStructFromArray
; Parameter(s):     $a_Variable array to create struct with
;                   $structType, the SINGLE type of struct to create.
; Requirement:
; Return Value(s):
; User CallTip:     _CreateStructFromArray
; Author(s):
; Note(s):
;===============================================================================

Func _CreateStuctFromArray($a_Variable, $structType)
   If Not IsArray($a_Variable) Then
      SetError(1)
      Return
   EndIf
   Local $a_ctr, $strVar, $struct, $emsg[6]
   For $a_ctr = 0 To UBound($a_Variable) - 1
      $strVar &= $structType & ";"
   Next
   $strVar = StringTrimRight($strVar, 1)
   $emsg[0] = "No Error."
   $emsg[1] = "Variable passed to DllStructCreate was not a string."
   $emsg[2] = "There is an unknown Data Type in the string passed. "
   $emsg[3] = "Failed to allocate the memory needed for the struct, or Pointer = 0."
   $emsg[4] = "Error allocating memory for the passed string."
   $emsg[5] = ""
   
   $struct = DllStructCreate($strVar)
   If @error Then
      If $debug Then MsgBox(0, "Error:", "Error:>" & $emsg[@error] & @CRLF)
      SetError(1)
      Return 0
   EndIf
   
   $emsg[0] = 'No Error. '
   $emsg[1] = 'Struct not a correct struct returned by DllStructCreate.'
   $emsg[2] = 'Element value out of range. '
   $emsg[3] = 'index would be outside of the struct.'
   $emsg[4] = 'Element data type is unknown'
   $emsg[5] = 'index < 0.'
   For $a_ctr = 0 To UBound($a_Variable) - 1
      DllStructSetData($struct, ($a_ctr) + 1, $a_Variable[$a_ctr])
      If @error Then
         If $debug Then ConsoleWrite("Set>" & $a_ctr & @CRLF & "Error:>" & $emsg[@error] & @CRLF)
         SetError(1)
         Return 0
      EndIf
   Next
   Return $struct
EndFunc;==>_CreateStuctFromArray
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Local Const $CCM_SETUNICODEFORMAT = ($CCM_FIRST + 5)
Global Const $SB_SETUNICODEFORMAT = $CCM_SETUNICODEFORMAT


_GuiCtrlStatusBarSetUnicode($StatusBar1, False)
If _GuiCtrlStatusBarGetUnicode($StatusBar1) Then
 _GuiCtrlStatusBarSetText($StatusBar1,"using Unicode characters", 1)
Else
 _GuiCtrlStatusBarSetText($StatusBar1,"NOT using Unicode characters", 1)
EndIf

 

Func _GuiCtrlStatusBarSetUnicode($StatusBar, $b_Unicode=True)
 Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETUNICODEFORMAT, "int", $b_Unicode, "int", 0)
 Return $a_ret[0]
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

switching between multipart status and simple

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local Const $CCM_SETUNICODEFORMAT = ($CCM_FIRST + 5)
Global Const $SB_SETUNICODEFORMAT = $CCM_SETUNICODEFORMAT

Local $gui, $StatusBar1, $ret0, $ret1, $msg, $ret2, $retl1, $retcode, $asize[1]
Local $a[3] = [100, 350, -1]
Local $s[3] = ["New Text", "How about music", "Even More Text"]
$gui = GUICreate("StatusBar GUI", 500, -1, -1, -1, $WS_SIZEBOX)
GUISetState(@SW_SHOW)

$StatusBar1 = _GuiCtrlCreateStatusBar ($gui, $a, $s)
_GuiCtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar1, "int", $SB_SETBKCOLOR, "int", 0, "int", _ReverseColorOrder(0xffff00))
_GuiCtrlStatusBarSetTip($StatusBar1, 0, "Part 1")
_GuiCtrlStatusBarSetTip($StatusBar1, 1, "Part 2")
_GuiCtrlStatusBarSetTip($StatusBar1, 2, "Part 3")
_GuiCtrlStatusBarSetMinHeight($StatusBar1, 50)

Local $a_rect = _GuiCtrlStatusBarGetRect($StatusBar1, 0)
If IsArray($a_rect) Then _
        MsgBox(0, "Rect", "Left: " & $a_rect[1] & @LF & _
        "Top: " & $a_rect[2] & @LF & _
        "Right: " & $a_rect[3] & @LF & _
        "Bottom: " & $a_rect[4])

Local $a_borders = _GuiCtrlStatusBarGetBorders($StatusBar1)
If IsArray($a_borders) Then _
        MsgBox(0, "Borders", "width of the horizontal border: " & $a_rect[0] & @LF & _
        "width of the vertical border: " & $a_rect[1] & @LF & _
        "width of the border between rectangles: " & $a_rect[2])
_GuiCtrlStatusBarSetUnicode($StatusBar1, False)
If _GuiCtrlStatusBarGetUnicode($StatusBar1) Then
    _GuiCtrlStatusBarSetText ($StatusBar1, "using Unicode characters", 1)
Else
    _GuiCtrlStatusBarSetText ($StatusBar1, "NOT using Unicode characters", 1)
EndIf

_GuiCtrlStatusBarSetSimple($StatusBar1)
_GuiCtrlStatusBarSetText ($StatusBar1, "simple mode", 255)
_GuiCtrlStatusBarResize ($StatusBar1)
Sleep(3000)
_GuiCtrlStatusBarSetSimple($StatusBar1, False)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

Func _GuiCtrlStatusBarSetIcon($StatusBar, $i_part, $szIconFile, $iconID)
    Local $hIcon = DllStructCreate("int")
    Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", "shell32.dll", "int", $iconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1)
    $result = $result[0]
    If $result > 0 Then
        $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", DllStructGetData($hIcon, 1))
    EndIf
    DllCall("user32.dll", "int", "DestroyIcon", "hwnd", DllStructGetPtr($hIcon))
    $hIcon = 0
    Return $result[0]
EndFunc;==>_GuiCtrlStatusBarSetIcon

Func _GuiCtrlStatusBarSetTip($StatusBar, $i_part, $s_ToolTip)
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")
    DllStructSetData($struct, 1, $s_ToolTip)
    If @error Then
        MsgBox(0, "", "Error in DllStructCreate " & @error);
        SetError(-1)
        Return -1
    EndIf
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETTIPTEXT, "int", $i_part, "int", DllStructGetPtr($struct))
    $struct = 0
EndFunc;==>_GuiCtrlStatusBarSetTip

Func _GuiCtrlStatusBarSetMinHeight($StatusBar, $i_MinHeight)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETMINHEIGHT, "int", $i_MinHeight, "int", 0)
    _GuiCtrlStatusBarResize ($StatusBar)
EndFunc;==>_GuiCtrlStatusBarSetMinHeight

Func _GuiCtrlStatusBarGetRect($StatusBar, $i_part)
;~  typedef struct _RECT {
;~    LONG left;
;~    LONG top;
;~    LONG right;
;~    LONG bottom;
;~  } RECT, *PRECT;
    Local $RECT = DllStructCreate("int;int;int;int")
    Local $p, $ret
    If @error Then
        Return @error
    EndIf
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETRECT, "int", $i_part, "ptr", DllStructGetPtr($RECT))
    If (Not $a_ret[0]) Then
        $RECT = 0
        Return 0
    Else
        Local $a_rect[5], $x
        $a_rect[0] = 4
        For $x = 1 To 4
            $a_rect[$x] = DllStructGetData($RECT, $x)
        Next
        $RECT = 0
        Return $a_rect
    EndIf
EndFunc;==>_GuiCtrlStatusBarGetRect

Func _GuiCtrlStatusBarGetBorders($StatusBar)
    Local $borders = DllStructCreate("int;int;int")
    Local $p, $ret
    If @error Then
        Return @error
    EndIf
    If Not IsHWnd($StatusBar) Then $StatusBar = HWnd($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETBORDERS, "int", 0, "ptr", DllStructGetPtr($borders))
    If (Not $a_ret[0]) Then
        $borders = 0
        Return 0
    Else
        Local $a_borders[3], $x
        For $x = 0 To 2
            $a_borders[$x] = DllStructGetData($borders, $x + 1)
        Next
        $borders = 0
        Return $a_borders
    EndIf
EndFunc;==>_GuiCtrlStatusBarGetBorders

Func _GuiCtrlStatusBarGetUnicode($StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_GETUNICODEFORMAT, "int", 0, "int", 0)
    Return $a_ret[0]
EndFunc;==>_GuiCtrlStatusBarGetUnicode

Func _GuiCtrlStatusBarSetUnicode($StatusBar, $b_Unicode = True)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SETUNICODEFORMAT, "int", $b_Unicode, "int", 0)
    Return $a_ret[0]
EndFunc;==>_GuiCtrlStatusBarSetUnicode

Func _GuiCtrlStatusBarSetSimple($StatusBar, $b_Simple = True)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $StatusBar, "int", $SB_SIMPLE, "int", $b_Simple, "int", 0)
    Return $a_ret[0]
EndFunc;==>_GuiCtrlStatusBarSetSimple

Func _ReverseColorOrder($v_color)
    Local $tc = Hex(String($v_color), 6)
    Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
EndFunc;==>_ReverseColorOrder
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Need those involved to look over the include file, make sure I have the Author(s) correct

See and type-o's or bugs let me know.

Then I'll start creating the templates and examples for the help

#include-once
#include <Array.au3>
#include <guiconstants.au3>
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1++
; Language:    English
; Description:  Functions that assist with the Statusbar control
;
; ------------------------------------------------------------------------------
;=== Globals
Global $debug = True

Global Const $CCS_TOP = 0x1
Global Const $CCS_NOMOVEY = 0x2
Global Const $CCS_BOTTOM = 0x3
Global Const $CCS_NORESIZE = 0x4
Global Const $CCS_NOPARENTALIGN = 0x8
Global Const $CCS_NOHILITE = 0x10
Global Const $CCS_ADJUSTABLE = 0x20
Global Const $CCS_NODIVIDER = 0x40
;=== Status Bar Styles
Global Const $SBARS_SIZEGRIP = 0x100
;=== uFlags
Global Const $SBT_SUNKEN = 0x0;Default
Global Const $SBT_NOBORDERS = 0x100;The text is drawn without borders.
Global Const $SBT_POPOUT = 0x200; The text is drawn with a border to appear higher than the plane of the window.
Global Const $SBT_RTLREADING = 0x400;SB_SETTEXT, SB_SETTEXT, SB_GETTEXTLENGTH flags only: Displays text using right-to-left reading order on Hebrew or Arabic systems.
Global Const $SBT_OWNERDRAW = 0x1000;The text is drawn by the parent window.
;=== Messages to send to Statusbar
Global Const $SB_SETTEXT = 0x401
Global Const $SB_GETTEXT = 0x402
Global Const $SB_GETTEXTLENGTH = 0x403
Global Const $SB_SETPARTS = 0x404
Global Const $SB_GETPARTS = 0x406
Global Const $SB_GETBORDERS = (0x400 + 7)
Global Const $SB_SETMINHEIGHT = 0x408
Global Const $SB_SIMPLE = 0x409
Global Const $SB_GETRECT = (0x400 + 10)
Global Const $SB_ISSIMPLE = 0x40E
Global Const $LowOrder = 0xFFFF
Global Const $SB_SETICON = (0x400 + 15)
Global Const $SB_SETBKCOLOR = (0x2000 + 1)
Global Const $SB_SETTIPTEXT = (0x400 + 16)
Global Const $SBT_TOOLTIPS = 0x800
Global Const $SB_GETUNICODEFORMAT = (0x2000 + 6)
Global Const $SB_SETUNICODEFORMAT = (0x2000 + 5)
;=== End Globals

;=== function list
;===============================================================================
;_GuiCtrlStatusBarCreate
;_GuiCtrlStatusBarGetBorders
;_GuiCtrlStatusBarGetParts
;_GuiCtrlStatusBarGetRect
;_GuiCtrlStatusBarGetText
;_GuiCtrlStatusBarGetTextLength
;_GuiCtrlStatusBarGetUnicode
;_GuiCtrlStatusBarResize
;_GuiCtrlStatusBarSetIcon
;_GuiCtrlStatusBarSetMinHeight
;_GuiCtrlStatusBarSetParts
;_GuiCtrlStatusBarSetSimple
;_GuiCtrlStatusBarSetText
;_GuiCtrlStatusBarSetUnicode

;_GuiCtrlStatusBarSetTip
;********** ToDo **************
;_GUICtrlStatusBarSetExtendedStyle

;===============================================================================
;
; Description:          _GuiCtrlStatusBarCreate
; Parameter(s):     $h_Gui      -   Handle to parent window
;                   $i_PanelWidth   -   width of panel or panels (for more than 1 panel pass in zero based array)
;                   $s_PanelText    -   text of panel or panels (for more than 1 panel pass in zero based array)
; Requirement:
; Return Value(s):  Returns hWhnd if successful, or 0 with error set to 1 otherwise.
; User CallTip:     _GuiCtrlStatusBarCreate($h_Gui, $a_PanelWidth, $s_PanelText) Creates Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):            rysiora, JdeB, tonedef,
;                   gafrost (Gary Frost (custompcs@charter.net)), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarCreate($h_Gui, $a_PanelWidth, $s_PanelText)
   If Not IsArray($a_PanelWidth) Then
      Local $temp_width = $a_PanelWidth
      Dim $a_PanelWidth[1] = [$temp_width]
   EndIf
   If Not IsArray($s_PanelText) Then
      Local $temp_string = $s_PanelText
      Dim $s_PanelText[1] = [$temp_string]
   EndIf
   If Not IsHWnd($h_Gui) Then $h_Gui = HWnd($h_Gui)
   Local $hwnd_Bar1, $sta, $ptr, $emsg[6], $x, $retcode
   $hwnd_Bar1 = DllCall("comctl32.dll", "long", "CreateStatusWindow", "long", BitOR($WS_CHILD, $WS_VISIBLE, $SBT_TOOLTIPS), "str", "", "hwnd", $h_Gui, "int", 0)
   
   If Not @error Then
      $retcode = _GuiCtrlStatusBarSetParts($hwnd_Bar1[0], UBound($a_PanelWidth), $a_PanelWidth)
      For $x = 0 To UBound($s_PanelText) - 1
         _GuiCtrlStatusBarSetText($hwnd_Bar1[0], $s_PanelText[$x], $x)
      Next
      
      Return $hwnd_Bar1[0]
   EndIf
   SetError(1)
   Return 0
EndFunc ;==>_GuiCtrlStatusBarCreate

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetBorders
; Parameter(s):     $h_StatusBar    -   Handle to statusbar
; Requirement:
; Return Value(s):  Returns zero based array
;                               0 - width of the horizontal border
;                               1 - width of the vertical border
;                               2 - width of the border between rectangles
;                           or zero otherwise.
; User CallTip:     _GuiCtrlStatusBarGetBorders($h_StatusBar) Gets width of borders. (required: <GuiStatusBar.au3>)
; Author(s):            gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetBorders($h_StatusBar)
   Local $borders = DllStructCreate("int;int;int")
   Local $p, $ret
   If @error Then
      Return 0
   EndIf
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETBORDERS, "int", 0, "ptr", DllStructGetPtr($borders))
   If (Not $a_ret[0]) Then
      $borders = 0
      Return 0
   Else
      Local $a_borders[3], $x
      For $x = 0 To 2
         $a_borders[$x] = DllStructGetData($borders, $x + 1)
      Next
      $borders = 0
      Return $a_borders
   EndIf
EndFunc ;==>_GuiCtrlStatusBarGetBorders

;===============================================================================
;
; Description:              _GuiCtrlStatusBarGetParts
; Parameter(s):         $h_StatusBar The Control Id (will be converted to hWnd)
;
;
;
; Requirement:
; Return Value(s):  Returns the number of parts in the window.
; User CallTip:     _GuiCtrlStatusBar($h_StatusBar) Retrieves a count of the parts in a status window. (required: <GuiStatusBar.au3>)
; Author(s):            eltorro, gafrost (Gary Frost (custompcs@charter.net))
;
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetParts($h_StatusBar)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETPARTS, "int", 0, "int", 0)
   Return $ret[0]
EndFunc ;==>_GuiCtrlStatusBarGetParts

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetRect
; Parameter(s):     $h_StatusBar    -   Handle to statusbar
;                   $i_part         -   Nubmer of panesl
; Requirement:
; Return Value(s):  Returns zero based array
;                               0 - Left
;                               1 - Top
;                               2 - Right
;                               3 - Bottom
;                           zero otherwise.
; User CallTip:     _GuiCtrlStatusBarGetRect($StatusBar, $i_part) Retrieves the bounding rectangle of a part in a status window. (required: <GuiStatusBar.au3>)
; Author(s):            gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetRect($h_StatusBar, $i_part)
;~   typedef struct _RECT {
;~     LONG left;
;~     LONG top;
;~     LONG right;
;~     LONG bottom;
;~   } RECT, *PRECT;
   Local $RECT = DllStructCreate("int;int;int;int")
   If @error Then
      Return 0
   EndIf
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETRECT, "int", $i_part, "ptr", DllStructGetPtr($RECT))
   If (Not $a_ret[0]) Then
      $RECT = 0
      Return 0
   Else
      Local $a_rect[4], $x
      For $x = 0 To 3
         $a_rect[$x] = DllStructGetData($RECT, $x + 1)
      Next
      $RECT = 0
      Return $a_rect
   EndIf
EndFunc ;==>_GuiCtrlStatusBarGetRect

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetText
; Parameter(s):     $h_StatusBar    -   The Control Id (will be converted to hWnd)
;                           $i_Panel            -   The panel to retreive the text from
; Requirement:
; Return Value(s):  Text from panel
; User CallTip:     _GuiCtrlStatusBarGetText($h_StatusBar[,$i_Panel=0]) Gets Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):            tonedef, gafrost (Gary Frost (custompcs@charter.net)), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetText($h_StatusBar, $i_Panel = 0)
 ;== there is a built in function to use for this. See help documentation
   Local $v_Ret
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   $v_Ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETTEXT, "int", $i_Panel, "strptr", "")
   Return $v_Ret[4]
EndFunc ;==>_GuiCtrlStatusBarGetText

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetTextLength
; Parameter(s):     $h_StatusBar    -   The Control Id (will be converted to hWnd)
;                   $i_Panel            -   Nubmer of the panesl to retrieve length from
;
; Requirement:
; Return Value(s):  Text Length
; User CallTip:     _GuiCtrlStatusBarGetTextLength ($h_StatusBar, $i_Panel) Retrieves the length, in characters, of the text from the specified part of a status window. (required: <GuiStatusBar.au3>)
; Author(s):            Steve Podhajecki <gehossafats@netmdc.com>, gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetTextLength($h_StatusBar, $i_Panel)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETTEXTLENGTH, "int", $i_Panel, "int", 0)
   Return $ret[0]
EndFunc ;==>_GuiCtrlStatusBarGetTextLength

;===============================================================================
;
; Description:              _GuiCtrlStatusBarGetUnicode
; Parameter(s):         $h_StatusBar    -   The Control Id (will be converted to hWnd)
;
; Requirement:
; Return Value(s):      If this value is nonzero, the control is using Unicode characters.
;                               If this value is zero, the control is using ANSI characters
; User CallTip:         _GuiCtrlStatusBarGetUnicode ($h_StatusBar) Retrieves the Unicode character format flag for the control. (required: <GuiStatusBar.au3>)
; Author(s):                gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetUnicode($h_StatusBar)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETUNICODEFORMAT, "int", 0, "int", 0)
   Return $a_ret[0]
EndFunc ;==>_GuiCtrlStatusBarGetUnicode

;===============================================================================
;
; Description:          _GuiCtrlStatusBarResize
; Parameter(s):     $h_StatusBar    -   The Control Id (will be converted to hWnd)
;
; Requirement:
; Return Value(s):  If the function succeeds, the return value is nonzero, otherwise zero.
; User CallTip:     _GuiCtrlStatusBarResize($h_StatusBar)   Resize Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):            Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarResize($h_StatusBar)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $ret = DllCall("user32.dll", "int", "MoveWindow", "hwnd", $h_StatusBar, "int", 0, "int", 0, "int", 0, "int", 0)
   Return $ret[0]
EndFunc ;==>_GuiCtrlStatusBarResize

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetBKColor
; Parameter(s):     $h_StatusBar    -   Handle to statusbar
;                   $v_HexRGB       -   Hex RGB color to set Status Bar background
; Requirement:
; Return Value(s):  Returns the previous background color
; User CallTip:     _GuiCtrlStatusBarSetBKColor($h_StatusBar, $v_HexRGB) Sets the background color in a status bar. (required: <GuiStatusBar.au3>)
; Author(s):            gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetBKColor($h_StatusBar, $v_HexRGB)
   Local $tc = Hex(String($v_HexRGB), 6)
   Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETBKCOLOR, "int", 0, "int", '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2))
   $tc = Hex(String($ret[0]), 6)
   Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
EndFunc ;==>_GuiCtrlStatusBarSetBKColor

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetIcon
; Parameter(s):     $h_StatusBar    -   Handle to statusbar
;                   $i_part         -   Nubmer of panesl to add icon too
;                   $s_IconFile     -   file to extract icon from
;                   $i_iconID       -   id of the icon
; Requirement:
; Return Value(s):  Returns nonzero if successful, or zero otherwise.
; User CallTip:     _GuiCtrlStatusBarSetIcon($StatusBar, $i_part, $szIconFile, $iconID) Sets an Icon in the Panel. (required: <GuiStatusBar.au3>)
; Author(s):            gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetIcon($h_StatusBar, $i_part, $s_IconFile, $i_iconID)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $hIcon = DllStructCreate("int")
   Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", $s_IconFile, "int", $i_iconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1)
   $result = $result[0]
   If $result > 0 Then
      $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", DllStructGetData($hIcon, 1))
   EndIf
   DllCall("user32.dll", "int", "DestroyIcon", "hwnd", DllStructGetPtr($hIcon))
   $hIcon = 0
   Return $result[0]
EndFunc ;==>_GuiCtrlStatusBarSetIcon

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetMinHeight
; Parameter(s):     $h_StatusBar    -   Handle to statusbar
;                   $i_MinHeight    -   Minimum height, in pixels, of the window
; Requirement:
; Return Value(s):  None
; User CallTip:     _GuiCtrlStatusBarSetMinHeight($h_StatusBar, $i_MinHeight) Sets the minimum height of a status window's drawing area. (required: <GuiStatusBar.au3>)
; Author(s):            gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetMinHeight($h_StatusBar, $i_MinHeight)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETMINHEIGHT, "int", $i_MinHeight, "int", 0)
   _GuiCtrlStatusBarResize($h_StatusBar)
EndFunc ;==>_GuiCtrlStatusBarSetMinHeight

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetParts
; Parameter(s):     $h_StatusBar    -   The Control Id (will be converted to hWnd)
;                   $i_Panels       -   Nubmer of panesl to create
;                   $i_PanelWidth   -    width of panel(s) (Default: 100)
;
; Requirement:
; Return Value(s):  1 if successfull, otherwise zero
; User CallTip:   _GuiCtrlStatusBarSetParts ($h_StatusBar, $i_Panels[, $i_PanelWidth = 100]). (required: <GuiStatusBar.au3>)
; Author(s):            tonedef, gafrost (Gary Frost (custompcs@charter.net)), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetParts($h_StatusBar, $i_Panels, $a_PanelWidth = 100)
   Local $sta, $emsg[6], $dll_ret
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
 ;=== Set each panel to be same size and assign the last one the remainder
   If Not IsArray($a_PanelWidth) Then
      Dim $a_PanelWidth[$i_Panels], $panel, $size, $strPanel, $struct_Panel
      $size = WinGetClientSize("")
      For $panel = 0 To $i_Panels - 1
         $a_PanelWidth[$panel] = Int(($size[0] / $i_Panels) * $panel + 1)
      Next
      $a_PanelWidth[$i_Panels - 1] = -1
   EndIf
 ;== end set sizing
   
   $sta = _CreateStuctFromArray($a_PanelWidth, "int")
   If @error Then Return 0
   
   $emsg[0] = "No error."
   $emsg[1] = "Unable to use the DLL file."
   $emsg[2] = ' unknown "return type".'
   
   $dll_ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETPARTS, _
         "int", $i_Panels, "ptr", DllStructGetPtr($sta))
   If @error Then
      If $debug Then ConsoleWrite("DllCall Error:>" & $emsg[@error] & @CRLF)
      SetError(1)
      Return 0
   EndIf
 ;== Sometimes this needs to be called in order to update the status bar.
   _GuiCtrlStatusBarResize($h_StatusBar)
   $sta = ""
   Return 1
EndFunc ;==>_GuiCtrlStatusBarSetParts

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetSimple
; Parameter(s):     $h_StatusBar    -   Handle to statusbar
;                   $b_Simple       -   Display type flag.
;                                                       If this parameter is TRUE, the window displays simple text. (Default)
;                                                       If it is FALSE, it displays multiple parts
; Requirement:
; Return Value(s):  None
; User CallTip:     _GuiCtrlStatusBarSetMinHeight($h_StatusBar[, $b_Simple = True]) Specifies whether a status window displays simple text or displays all window parts. (required: <GuiStatusBar.au3>)
; Author(s):            gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetSimple($h_StatusBar, $b_Simple = True)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SIMPLE, "int", $b_Simple, "int", 0)
EndFunc ;==>_GuiCtrlStatusBarSetSimple

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetText
; Parameter(s):     $h_StatusBar    -   The Control Id (will be converted to hWnd)
;                   $s_Data         -   The text to display in the panel
;                   $i_Panel            -   The panel to hold the text (Default: 0)
; Requirement:
; Return Value(s):  Returns TRUE if successful, or FALSE otherwise.
; User CallTip:     _GuiCtrlStatusBarSetText($h_StatusBar[, $s_Data = ""[, $i_Panel = 0]]) Set Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):            rysiora, JdeB, tonedef,
;                   gafrost (Gary Frost (custompcs@charter.net))
; Note(s):              Set $i_Panel to 255 for simple statusbar
;===============================================================================
Func _GuiCtrlStatusBarSetText($h_StatusBar, $s_Data = "", $i_Panel = 0)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETTEXT, "int", $i_Panel, "str", $s_Data)
   Return $ret[0]
EndFunc ;==>_GuiCtrlStatusBarSetText

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetUnicode
; Parameter(s):     $h_StatusBar    -   Handle to statusbar
;                   $b_Unicode      -   Determines the character set that is used by the control.
;                                                       If this value is TRUE, the control will use Unicode characters. (Default)
;                                                       If this value is FALSE, the control will use ANSI characters.
; Requirement:
; Return Value(s):  Returns the previous Unicode format flag for the control
; User CallTip:     _GuiCtrlStatusBarSetUnicode($h_StatusBar[, $b_Unicode = True[) Sets the Unicode character format flag for the control. (required: <GuiStatusBar.au3>)
; Author(s):            gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetUnicode($h_StatusBar, $b_Unicode = True)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETUNICODEFORMAT, "int", $b_Unicode, "int", 0)
   Return $a_ret[0]
EndFunc ;==>_GuiCtrlStatusBarSetUnicode

;===============================================================================
;
; Description:          _GuiCtrlStatusBarSetTip
; Parameter(s):     $h_StatusBar    -   Handle to statusbar
;                   $i_part         -   Zero-based index of the part that will receive the ToolTip text
;                           $s_ToolTip      -   new ToolTip text
; Requirement:
; Return Value(s):  None
; User CallTip:     _GuiCtrlStatusBarSetTip($h_StatusBar, $i_part, $s_ToolTip) Sets the ToolTip text for a part in a status bar. (required: <GuiStatusBar.au3>)
; Author(s):            gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetTip($h_StatusBar, $i_part, $s_ToolTip)
   If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
   Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")
   DllStructSetData($struct, 1, $s_ToolTip)
   If @error Then
      SetError(-1)
      Return
   EndIf
   DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETTIPTEXT, "int", $i_part, "int", DllStructGetPtr($struct))
   $struct = 0
EndFunc ;==>_GuiCtrlStatusBarSetTip

;===============================================================================
; Helper functions
;===============================================================================

;===============================================================================
;
; Description:          CreateStructFromArray
; Parameter(s):     $a_Variable array to create struct with
;                   $structType, the SINGLE type of struct to create.
; Requirement:
; Return Value(s):
; User CallTip:     _CreateStructFromArray
; Author(s):
; Note(s):
;===============================================================================
Func _CreateStuctFromArray($a_Variable, $structType)
   If Not IsArray($a_Variable) Then
      SetError(1)
      Return
   EndIf
   Local $a_ctr, $strVar, $struct, $emsg[6]
   For $a_ctr = 0 To UBound($a_Variable) - 1
      $strVar &= $structType & ";"
   Next
   $strVar = StringTrimRight($strVar, 1)
   $emsg[0] = "No Error."
   $emsg[1] = "Variable passed to DllStructCreate was not a string."
   $emsg[2] = "There is an unknown Data Type in the string passed. "
   $emsg[3] = "Failed to allocate the memory needed for the struct, or Pointer = 0."
   $emsg[4] = "Error allocating memory for the passed string."
   $emsg[5] = ""
   
   $struct = DllStructCreate($strVar)
   If @error Then
      If $debug Then MsgBox(0, "Error:", "Error:>" & $emsg[@error] & @CRLF)
      SetError(1)
      Return 0
   EndIf
   
   $emsg[0] = 'No Error. '
   $emsg[1] = 'Struct not a correct struct returned by DllStructCreate.'
   $emsg[2] = 'Element value out of range. '
   $emsg[3] = 'index would be outside of the struct.'
   $emsg[4] = 'Element data type is unknown'
   $emsg[5] = 'index < 0.'
   For $a_ctr = 0 To UBound($a_Variable) - 1
      DllStructSetData($struct, ($a_ctr) + 1, $a_Variable[$a_ctr])
      If @error Then
         If $debug Then ConsoleWrite("Set>" & $a_ctr & @CRLF & "Error:>" & $emsg[@error] & @CRLF)
         SetError(1)
         Return 0
      EndIf
   Next
   Return $struct
EndFunc ;==>_CreateStuctFromArray
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hi. Just did a search and found this promising thread. Bit of a noobie Q... do I have this right?

1) Copy gafrost's latest posted UDF code and paste into new .au3 file

2) Save file into Includes folder (eg. GUIStatus.au3)

3) Call UDF from my script like any other include? (eg. #Include <GuiStatus.au3>

Thanks

LD

Link to comment
Share on other sites

Hi. Just did a search and found this promising thread. Bit of a noobie Q... do I have this right?

1) Copy gafrost's latest posted UDF code and paste into new .au3 file

2) Save file into Includes folder (eg. GUIStatus.au3)

3) Call UDF from my script like any other include? (eg. #Include <GuiStatus.au3>

Thanks

LD

1. Yes

2. Save it to GuiStatusBar.au3

3. #include <GuiStatusBar.au3>

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Here's another one. (func to add)

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetTipText
; Parameter(s):     $h_Bar The Control Id (will be converted to hWnd)
;                   $i_Panel  The panel to retreive the text from
; Requirement:
; Return Value(s):  True on success
; User CallTip:     _GuiCtrlStatusBarGetTipText($h_Bar,$i_Panel=0) Gets Statusbar TipText. (required: <GuiStatusBar.au3>)
; Author(s):       
;                   Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):          The status bar must be created with the SBT_TOOLTIPS style to enable ToolTips.
;===============================================================================
Func _GuiCtrlStatusBarGetTipText($h_Bar, $i_Panel = 0)
    Local $v_Ret,$strBuff, $wParam
    If Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
    $strBuff = DllStructCreate("char[255]")
    $wParam = ((DllStructGetSize($str) * 0x10000) + $i_Panel)
    $v_Ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_GETTIPTEXT, _
                                    "long", $wParam, "ptr", DllStructGetPtr($strBuff))
    Return StringStripWS(DllStructGetData($strBuff,1),7);strip leading, trailing, and double ws.
EndFunc ;==>_GuiCtrlStatusBarGetTipText

and this one.

;===============================================================================
;
; Description:          _GuiCtrlStatusBarGetIcon
; Parameter(s):   $h_Bar The Control Id (will be converted to hWnd)
;                   $i_Panel  The panel to hold the text
; Requirement:
; Return Value(s):  return hwnd or 0
; User CallTip:     _GuiCtrlStatusBarGetIcon($h_Bar,$i_Panel=0) Gets Statusbar panel Icon. (required: <GuiStatusBar.au3>)
; Author(s):         Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):          program is responsible for destroying icon.
;===============================================================================
Func _GuiCtrlStatusBarGetIcon($h_Bar, $i_Panel)
        if Not IsHWnd($h_Bar) Then $h_Bar = HWnd($h_Bar)
    Return DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_Bar, "int", $SB_GETICON, "int", $i_Panel, "int", 0)
EndFunc ;==>_GuiCtrlStatusBarGetIcon
Edited by eltorro
Link to comment
Share on other sites

Updated

#include-once
#include <Array.au3>
#include <guiconstants.au3>
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1++
; Language:    English
; Description:  Functions that assist with the Statusbar control
;
; ------------------------------------------------------------------------------
;=== Globals
Global $debug = True

Global Const $CCS_TOP = 0x1
Global Const $CCS_NOMOVEY = 0x2
Global Const $CCS_BOTTOM = 0x3
Global Const $CCS_NORESIZE = 0x4
Global Const $CCS_NOPARENTALIGN = 0x8
Global Const $CCS_NOHILITE = 0x10
Global Const $CCS_ADJUSTABLE = 0x20
Global Const $CCS_NODIVIDER = 0x40
;=== Status Bar Styles
Global Const $SBARS_SIZEGRIP = 0x100
Global Const $SBT_TOOLTIPS = 0x800
;=== uFlags
Global Const $SBT_SUNKEN = 0x0;Default
Global Const $SBT_NOBORDERS = 0x100;The text is drawn without borders.
Global Const $SBT_POPOUT = 0x200; The text is drawn with a border to appear higher than the plane of the window.
Global Const $SBT_RTLREADING = 0x400;SB_SETTEXT, SB_SETTEXT, SB_GETTEXTLENGTH flags only: Displays text using right-to-left reading order on Hebrew or Arabic systems.
Global Const $SBT_OWNERDRAW = 0x1000;The text is drawn by the parent window.
;=== Messages to send to Statusbar
Global Const $SB_GETPARTS = 0x406
Global Const $SB_GETBORDERS = (0x400 + 7)
Global Const $SB_GETICON = (0x400 + 20)
Global Const $SB_GETRECT = (0x400 + 10)
Global Const $SB_GETTEXT = 0x402
Global Const $SB_GETTEXTLENGTH = 0x403
Global Const $SB_GETTIPTEXT = (0x400 + 18)

Global Const $SB_GETUNICODEFORMAT = (0x2000 + 6)

Global Const $SB_SETBKCOLOR = (0x2000 + 1)
Global Const $SB_SETICON = (0x400 + 15)
Global Const $SB_SETMINHEIGHT = 0x408
Global Const $SB_SETPARTS = 0x404
Global Const $SB_SETTEXT = 0x401
Global Const $SB_SETTIPTEXT = (0x400 + 16)
Global Const $SB_SETUNICODEFORMAT = (0x2000 + 5)

Global Const $SB_SIMPLE = 0x409
Global Const $SB_ISSIMPLE = 0x40E
Global Const $LowOrder = 0xFFFF
;=== End Globals

;=== function list
;===============================================================================
;_GuiCtrlStatusBarCreate
;_GuiCtrlStatusBarGetBorders
;_GuiCtrlStatusBarGetIcon
;_GuiCtrlStatusBarGetParts
;_GuiCtrlStatusBarGetRect
;_GuiCtrlStatusBarGetText
;_GuiCtrlStatusBarGetTextLength
;_GuiCtrlStatusBarGetTipText
;_GuiCtrlStatusBarGetUnicode
;_GuiCtrlStatusBarResize
;_GuiCtrlStatusBarSetBKColor
;_GuiCtrlStatusBarSetIcon
;_GuiCtrlStatusBarSetMinHeight
;_GuiCtrlStatusBarSetParts
;_GuiCtrlStatusBarSetSimple
;_GuiCtrlStatusBarSetText
;_GuiCtrlStatusBarSetTip
;_GuiCtrlStatusBarSetUnicode
;**********Helper**************
;_CreateStructFromArray
;********** ToDo **************
;_GUICtrlStatusBarSetExtendedStyle

;===============================================================================
;
; Description:     _GuiCtrlStatusBarCreate
; Parameter(s):   $h_Gui            -   Handle to parent window
;                   $a_PanelWidth   -   width of panel or panels (for more than 1 panel pass in zero based array)
;                   $s_PanelText    -   text of panel or panels (for more than 1 panel pass in zero based array)
;                           $v_styles       -   styles to apply to the status bar (Optional) for multiple styles bitor them.
; Requirement:
; Return Value(s):   Returns hWhnd if successful, or 0 with error set to 1 otherwise.
; User CallTip:   _GuiCtrlStatusBarCreate($h_Gui, $a_PanelWidth, $s_PanelText[, $v_styles = ""]) Creates Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):         rysiora, JdeB, tonedef,
;                   gafrost (Gary Frost (custompcs@charter.net)), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarCreate($h_Gui, $a_PanelWidth, $s_PanelText, $v_styles = "")
    If Not IsArray($a_PanelWidth) Then
        Local $temp_width = $a_PanelWidth
        Dim $a_PanelWidth[1] = [$temp_width]
    EndIf
    If Not IsArray($s_PanelText) Then
        Local $temp_string = $s_PanelText
        Dim $s_PanelText[1] = [$temp_string]
    EndIf
    If Not IsHWnd($h_Gui) Then $h_Gui = HWnd($h_Gui)
    Local $hwnd_Bar1, $sta, $ptr, $emsg[6], $x, $retcode
    Local $style = BitOR($WS_CHILD, $WS_VISIBLE)
    If @NumParams = 4 Then $style = BitOR($style, $v_styles)
    $hwnd_Bar1 = DllCall("comctl32.dll", "long", "CreateStatusWindow", "long", $style, "str", "", "hwnd", $h_Gui, "int", 0)
    
    If Not @error Then
        $retcode = _GuiCtrlStatusBarSetParts($hwnd_Bar1[0], UBound($a_PanelWidth), $a_PanelWidth)
        For $x = 0 To UBound($s_PanelText) - 1
            _GuiCtrlStatusBarSetText($hwnd_Bar1[0], $s_PanelText[$x], $x)
        Next
        
        Return $hwnd_Bar1[0]
    EndIf
    SetError(1)
    Return 0
EndFunc ;==>_GuiCtrlStatusBarCreate

;===============================================================================
;
; Description:     _GuiCtrlStatusBarGetBorders
; Parameter(s):   $h_StatusBar  -   Handle to statusbar
; Requirement:
; Return Value(s):   Returns zero based array
;                      0 - width of the horizontal border
;                      1 - width of the vertical border
;                      2 - width of the border between rectangles
;                   or zero otherwise.
; User CallTip:   _GuiCtrlStatusBarGetBorders($h_StatusBar) Gets width of borders. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetBorders($h_StatusBar)
    Local $borders = DllStructCreate("int;int;int")
    Local $p, $ret
    If @error Then
        Return 0
    EndIf
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETBORDERS, "int", 0, "ptr", DllStructGetPtr($borders))
    If (Not $a_ret[0]) Then
        $borders = 0
        Return 0
    Else
        Local $a_borders[3], $x
        For $x = 0 To 2
            $a_borders[$x] = DllStructGetData($borders, $x + 1)
        Next
        $borders = 0
        Return $a_borders
    EndIf
EndFunc ;==>_GuiCtrlStatusBarGetBorders

;===============================================================================
;
; Description:     _GuiCtrlStatusBarGetIcon
; Parameter(s):   $h_StatusBar  -   The Control Id (will be converted to hWnd)
;                   $i_Panel            -   The panel to hold the text
; Requirement:
; Return Value(s):   return hwnd or 0
; User CallTip:   _GuiCtrlStatusBarGetIcon($h_StatusBar[, $i_Panel=0]) Gets Statusbar panel Icon. (required: <GuiStatusBar.au3>)
; Author(s):         Steve Podhajecki <gehossafats@netmdc.com>, gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetIcon($h_StatusBar, $i_Panel)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETICON, "int", $i_Panel, "int", 0)
    If IsArray($ret) Then Return $ret[0]
EndFunc  ;==>_GuiCtrlStatusBarGetIcon

;===============================================================================
;
; Description:     _GuiCtrlStatusBarGetParts
; Parameter(s):   $h_StatusBar  -   The Control Id (will be converted to hWnd)
;
; Requirement:
; Return Value(s):   Returns the number of parts in the window.
; User CallTip:   _GuiCtrlStatusBar($h_StatusBar) Retrieves a count of the parts in a status window. (required: <GuiStatusBar.au3>)
; Author(s):         Steve Podhajecki <gehossafats@netmdc.com>, gafrost (Gary Frost (custompcs@charter.net))
;
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetParts($h_StatusBar)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETPARTS, "int", 0, "int", 0)
    If IsArray($ret) Then Return $ret[0]
EndFunc ;==>_GuiCtrlStatusBarGetParts

;===============================================================================
;
; Description:     _GuiCtrlStatusBarGetRect
; Parameter(s):   $h_StatusBar  -   Handle to statusbar
;                   $i_part         -   Nubmer of panesl
; Requirement:
; Return Value(s):   Returns zero based array
;                      0 - Left
;                      1 - Top
;                      2 - Right
;                      3 - Bottom
;                   zero otherwise.
; User CallTip:   _GuiCtrlStatusBarGetRect($StatusBar, $i_part) Retrieves the bounding rectangle of a part in a status window. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetRect($h_StatusBar, $i_part)
;~   typedef struct _RECT {
;~     LONG left;
;~     LONG top;
;~     LONG right;
;~     LONG bottom;
;~   } RECT, *PRECT;
    Local $RECT = DllStructCreate("int;int;int;int")
    If @error Then
        Return 0
    EndIf
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETRECT, "int", $i_part, "ptr", DllStructGetPtr($RECT))
    If IsArray($a_ret) Then
        If (Not $a_ret[0]) Then
            $RECT = 0
            Return 0
        Else
            Local $a_rect[4], $x
            For $x = 0 To 3
                $a_rect[$x] = DllStructGetData($RECT, $x + 1)
            Next
            $RECT = 0
            Return $a_rect
        EndIf
    Else
        $RECT = 0
        Return 0
    EndIf
EndFunc ;==>_GuiCtrlStatusBarGetRect

;===============================================================================
;
; Description:     _GuiCtrlStatusBarGetText
; Parameter(s):   $h_StatusBar  -   The Control Id (will be converted to hWnd)
;                   $i_Panel            -   The panel to retreive the text from
; Requirement:
; Return Value(s):   Text from panel
; User CallTip:   _GuiCtrlStatusBarGetText($h_StatusBar[,$i_Panel=0]) Gets Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):         tonedef, gafrost (Gary Frost (custompcs@charter.net)), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetText($h_StatusBar, $i_Panel = 0)
;== there is a built in function to use for this. See help documentation
    Local $v_Ret
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    $v_Ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETTEXT, "int", $i_Panel, "strptr", "")
    If IsArray($v_Ret) Then
        Return $v_Ret[4]
    Else
        Return ""
    EndIf
EndFunc ;==>_GuiCtrlStatusBarGetText

;===============================================================================
;
; Description:     _GuiCtrlStatusBarGetTextLength
; Parameter(s):   $h_StatusBar  -   The Control Id (will be converted to hWnd)
;                   $i_Panel            -   Nubmer of the panesl to retrieve length from
;
; Requirement:
; Return Value(s):   Text Length
; User CallTip:   _GuiCtrlStatusBarGetTextLength ($h_StatusBar, $i_Panel) Retrieves the length, in characters, of the text from the specified part of a status window. (required: <GuiStatusBar.au3>)
; Author(s):         Steve Podhajecki <gehossafats@netmdc.com>, gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetTextLength($h_StatusBar, $i_Panel)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETTEXTLENGTH, "int", $i_Panel, "int", 0)
    If IsArray($ret) Then
        Return $ret[0]
    Else
        Return -1
    EndIf
EndFunc ;==>_GuiCtrlStatusBarGetTextLength

;===============================================================================
;
; Description:     _GuiCtrlStatusBarGetTipText
; Parameter(s):   $h_StatusBar The Control Id (will be converted to hWnd)
;                   $i_Panel  The panel to retreive the text from
; Requirement:
; Return Value(s):   Tip Text, on error empty string
; User CallTip:   _GuiCtrlStatusBarGetTipText($h_StatusBar[, $i_Panel=0]) Gets Statusbar TipText. (required: <GuiStatusBar.au3>)
; Author(s):         Steve Podhajecki <gehossafats@netmdc.com>, , gafrost (Gary Frost (custompcs@charter.net))
; Note(s):         The status bar must be created with the SBT_TOOLTIPS style to enable ToolTips.
;===============================================================================
Func _GuiCtrlStatusBarGetTipText($h_StatusBar, $i_Panel = 0)
    Local $v_Ret, $strBuff, $wParam
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    $strBuff = DllStructCreate("char[255]")
    $wParam = ((DllStructGetSize($strBuff) * 0x10000) + $i_Panel)
    $v_Ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETTIPTEXT, _
            "long", $wParam, "ptr", DllStructGetPtr($strBuff))
    If IsArray($v_Ret) Then
        Return StringStripWS(DllStructGetData($strBuff, 1), 7);strip leading, trailing, and double ws.
    Else
        SetError(1)
        Return ""
    EndIf
EndFunc ;==>_GuiCtrlStatusBarGetTipText

;===============================================================================
;
; Description:     _GuiCtrlStatusBarGetUnicode
; Parameter(s):   $h_StatusBar  -   The Control Id (will be converted to hWnd)
;
; Requirement:
; Return Value(s):   If this value is nonzero, the control is using Unicode characters.
;                   If this value is zero, the control is using ANSI characters
; User CallTip:   _GuiCtrlStatusBarGetUnicode ($h_StatusBar) Retrieves the Unicode character format flag for the control. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarGetUnicode($h_StatusBar)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETUNICODEFORMAT, "int", 0, "int", 0)
    If IsArray($a_ret) Then
        Return $a_ret[0]
    Else
        SetError(-1)
        Return 0
    EndIf
EndFunc ;==>_GuiCtrlStatusBarGetUnicode

;===============================================================================
;
; Description:     _GuiCtrlStatusBarResize
; Parameter(s):   $h_StatusBar  -   The Control Id (will be converted to hWnd)
;
; Requirement:
; Return Value(s):   If the function succeeds, the return value is nonzero, otherwise zero.
; User CallTip:   _GuiCtrlStatusBarResize($h_StatusBar) Resize Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):         Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarResize($h_StatusBar)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $ret = DllCall("user32.dll", "int", "MoveWindow", "hwnd", $h_StatusBar, "int", 0, "int", 0, "int", 0, "int", 0)
    If IsArray($ret) Then
        Return $ret[0]
    Else
        Return 0
    EndIf
EndFunc ;==>_GuiCtrlStatusBarResize

;===============================================================================
;
; Description:     _GuiCtrlStatusBarSetBKColor
; Parameter(s):   $h_StatusBar  -   Handle to statusbar
;                   $v_HexRGB       -   Hex RGB color to set Status Bar background
; Requirement:
; Return Value(s):   Returns the previous background color
; User CallTip:   _GuiCtrlStatusBarSetBKColor($h_StatusBar, $v_HexRGB) Sets the background color in a status bar. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetBKColor($h_StatusBar, $v_HexRGB)
    Local $tc = Hex(String($v_HexRGB), 6)
    Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETBKCOLOR, "int", 0, "int", '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2))
    If IsArray($ret) Then
        $tc = Hex(String($ret[0]), 6)
        Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)
    Else
        Return 0
    EndIf
EndFunc ;==>_GuiCtrlStatusBarSetBKColor

;===============================================================================
;
; Description:     _GuiCtrlStatusBarSetIcon
; Parameter(s):   $h_StatusBar  -   Handle to statusbar
;                   $i_part         -   Nubmer of panesl to add icon too
;                   $s_IconFile     -   file to extract icon from
;                   $i_iconID       -   id of the icon
; Requirement:
; Return Value(s):   Returns nonzero if successful, or zero otherwise.
; User CallTip:   _GuiCtrlStatusBarSetIcon($StatusBar, $i_part, $szIconFile, $iconID) Sets an Icon in the Panel. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetIcon($h_StatusBar, $i_part, $s_IconFile, $i_iconID)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $hIcon = DllStructCreate("int")
    Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", $s_IconFile, "int", $i_iconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1)
    $result = $result[0]
    If $result > 0 Then
        $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", DllStructGetData($hIcon, 1))
    EndIf
    DllCall("user32.dll", "int", "DestroyIcon", "hwnd", DllStructGetPtr($hIcon))
    $hIcon = 0
    Return $result[0]
EndFunc ;==>_GuiCtrlStatusBarSetIcon

;===============================================================================
;
; Description:     _GuiCtrlStatusBarSetMinHeight
; Parameter(s):   $h_StatusBar  -   Handle to statusbar
;                   $i_MinHeight    -   Minimum height, in pixels, of the window
; Requirement:
; Return Value(s):   None
; User CallTip:   _GuiCtrlStatusBarSetMinHeight($h_StatusBar, $i_MinHeight) Sets the minimum height of a status window's drawing area. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetMinHeight($h_StatusBar, $i_MinHeight)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETMINHEIGHT, "int", $i_MinHeight, "int", 0)
    _GuiCtrlStatusBarResize($h_StatusBar)
EndFunc ;==>_GuiCtrlStatusBarSetMinHeight

;===============================================================================
;
; Description:     _GuiCtrlStatusBarSetParts
; Parameter(s):   $h_StatusBar  -   The Control Id (will be converted to hWnd)
;                   $i_Panels       -   Nubmer of panesl to create
;                   $i_PanelWidth   -    width of panel(s) (Default: 100)
;
; Requirement:
; Return Value(s):   1 if successfull, otherwise zero
; User CallTip:   _GuiCtrlStatusBarSetParts ($h_StatusBar, $i_Panels[, $i_PanelWidth = 100]). (required: <GuiStatusBar.au3>)
; Author(s):         tonedef, gafrost (Gary Frost (custompcs@charter.net)), Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetParts($h_StatusBar, $i_Panels, $a_PanelWidth = 100)
    Local $sta, $emsg[6], $dll_ret
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
;=== Set each panel to be same size and assign the last one the remainder
    If Not IsArray($a_PanelWidth) Then
        Dim $a_PanelWidth[$i_Panels], $panel, $size, $strPanel, $struct_Panel
        $size = WinGetClientSize("")
        For $panel = 0 To $i_Panels - 1
            $a_PanelWidth[$panel] = Int(($size[0] / $i_Panels) * $panel + 1)
        Next
        $a_PanelWidth[$i_Panels - 1] = -1
    EndIf
;== end set sizing
    
    $sta = _CreateStuctFromArray($a_PanelWidth, "int")
    If @error Then Return 0
    
    $emsg[0] = "No error."
    $emsg[1] = "Unable to use the DLL file."
    $emsg[2] = ' unknown "return type".'
    
    $dll_ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETPARTS, _
            "int", $i_Panels, "ptr", DllStructGetPtr($sta))
    If @error Then
        If $debug Then ConsoleWrite("DllCall Error:>" & $emsg[@error] & @CRLF)
        SetError(1)
        Return 0
    EndIf
;== Sometimes this needs to be called in order to update the status bar.
    _GuiCtrlStatusBarResize($h_StatusBar)
    $sta = ""
    Return 1
EndFunc ;==>_GuiCtrlStatusBarSetParts

;===============================================================================
;
; Description:     _GuiCtrlStatusBarSetSimple
; Parameter(s):   $h_StatusBar  -   Handle to statusbar
;                   $b_Simple       -   Display type flag.
;                       If this parameter is TRUE, the window displays simple text. (Default)
;                       If it is FALSE, it displays multiple parts
; Requirement:
; Return Value(s):   None
; User CallTip:   _GuiCtrlStatusBarSetSimple($h_StatusBar[, $b_Simple = True]) Specifies whether a status window displays simple text or displays all window parts. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetSimple($h_StatusBar, $b_Simple = True)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SIMPLE, "int", $b_Simple, "int", 0)
EndFunc ;==>_GuiCtrlStatusBarSetSimple

;===============================================================================
;
; Description:     _GuiCtrlStatusBarSetText
; Parameter(s):   $h_StatusBar  -   The Control Id (will be converted to hWnd)
;                   $s_Data         -   The text to display in the panel
;                   $i_Panel            -   The panel to hold the text (Default: 0)
; Requirement:
; Return Value(s):   Returns TRUE if successful, or FALSE otherwise.
; User CallTip:   _GuiCtrlStatusBarSetText($h_StatusBar[, $s_Data = ""[, $i_Panel = 0]]) Set Statusbar Text. (required: <GuiStatusBar.au3>)
; Author(s):         rysiora, JdeB, tonedef,
;                   gafrost (Gary Frost (custompcs@charter.net))
; Note(s):         Set $i_Panel to 255 for simple statusbar
;===============================================================================
Func _GuiCtrlStatusBarSetText($h_StatusBar, $s_Data = "", $i_Panel = 0)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETTEXT, "int", $i_Panel, "str", $s_Data)
    If IsArray($ret) Then
        Return $ret[0]
    Else
        Return False
    EndIf
EndFunc ;==>_GuiCtrlStatusBarSetText

;===============================================================================
;
; Description:     _GuiCtrlStatusBarSetUnicode
; Parameter(s):   $h_StatusBar  -   Handle to statusbar
;                   $b_Unicode      -   Determines the character set that is used by the control.
;                       If this value is TRUE, the control will use Unicode characters. (Default)
;                       If this value is FALSE, the control will use ANSI characters.
; Requirement:
; Return Value(s):   Returns the previous Unicode format flag for the control
; User CallTip:   _GuiCtrlStatusBarSetUnicode($h_StatusBar[, $b_Unicode = True[) Sets the Unicode character format flag for the control. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetUnicode($h_StatusBar, $b_Unicode = True)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETUNICODEFORMAT, "int", $b_Unicode, "int", 0)
    If IsArray($a_ret) Then
        Return $a_ret[0]
    Else
        Return False
    EndIf
EndFunc ;==>_GuiCtrlStatusBarSetUnicode

;===============================================================================
;
; Description:     _GuiCtrlStatusBarSetTip
; Parameter(s):   $h_StatusBar  -   Handle to statusbar
;                   $i_part         -   Zero-based index of the part that will receive the ToolTip text
;                   $s_ToolTip      -   new ToolTip text
; Requirement:
; Return Value(s):   None
; User CallTip:   _GuiCtrlStatusBarSetTip($h_StatusBar, $i_part, $s_ToolTip) Sets the ToolTip text for a part in a status bar. (required: <GuiStatusBar.au3>)
; Author(s):         gafrost (Gary Frost (custompcs@charter.net))
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarSetTip($h_StatusBar, $i_part, $s_ToolTip)
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]")
    DllStructSetData($struct, 1, $s_ToolTip)
    If @error Then
        SetError(-1)
        Return
    EndIf
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETTIPTEXT, "int", $i_part, "int", DllStructGetPtr($struct))
    $struct = 0
EndFunc ;==>_GuiCtrlStatusBarSetTip

;===============================================================================
; Helper functions
;===============================================================================

;===============================================================================
;
; Description:     CreateStructFromArray
; Parameter(s):   $a_Variable array to create struct with
;                   $structType, the SINGLE type of struct to create.
; Requirement:
; Return Value(s):
; User CallTip:   _CreateStructFromArray
; Author(s):            Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _CreateStuctFromArray($a_Variable, $structType)
    If Not IsArray($a_Variable) Then
        SetError(1)
        Return
    EndIf
    Local $a_ctr, $strVar, $struct, $emsg[6]
    For $a_ctr = 0 To UBound($a_Variable) - 1
        $strVar &= $structType & ";"
    Next
    $strVar = StringTrimRight($strVar, 1)
    $emsg[0] = "No Error."
    $emsg[1] = "Variable passed to DllStructCreate was not a string."
    $emsg[2] = "There is an unknown Data Type in the string passed. "
    $emsg[3] = "Failed to allocate the memory needed for the struct, or Pointer = 0."
    $emsg[4] = "Error allocating memory for the passed string."
    $emsg[5] = ""
    
    $struct = DllStructCreate($strVar)
    If @error Then
        If $debug Then MsgBox(0, "Error:", "Error:>" & $emsg[@error] & @CRLF)
        SetError(1)
        Return 0
    EndIf
    
    $emsg[0] = 'No Error. '
    $emsg[1] = 'Struct not a correct struct returned by DllStructCreate.'
    $emsg[2] = 'Element value out of range. '
    $emsg[3] = 'index would be outside of the struct.'
    $emsg[4] = 'Element data type is unknown'
    $emsg[5] = 'index < 0.'
    For $a_ctr = 0 To UBound($a_Variable) - 1
        DllStructSetData($struct, ($a_ctr) + 1, $a_Variable[$a_ctr])
        If @error Then
            If $debug Then ConsoleWrite("Set>" & $a_ctr & @CRLF & "Error:>" & $emsg[@error] & @CRLF)
            SetError(1)
            Return 0
        EndIf
    Next
    Return $struct
EndFunc ;==>_CreateStuctFromArray
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Progress bar in Statusbar:

opt("MustDeclareVars", 1)
opt("GUICoordMode", 2)

#include-once
#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $Progress1, $msg,  $asize[1],$iProgress
Local $a[3] = [100,350,-1]
Local $s[3] = ["New Text","More Text","Even More Text"]

; Statusbar with progress bar
$gui = GUICreate("StatusBar GUI", 500, -1, -1, -1, $WS_SIZEBOX)
GUISetState(@SW_SHOW)

Dim $s[3] = ["Ready. ","","Even More Text"],$a_box
$StatusBar1 = _GuiCtrlStatusBarCreate($gui, $a, $s)

;=== add progress to statusbar
;Get panel size and shink a little for progressbar size.
$a_box = _SizePanel($StatusBar1,1)
;Create the progress bar with the proper size.
$Progress1 = GUICtrlCreateProgress($a_box[0],$a_box[1],$a_box[2],$a_box[3])
GUICtrlSetResizing($Progress1,802)
;change progressbars parent to statusbar
_SetParent($Progress1,$StatusBar1) 
; move progressbar to statusbar.
_CtrlMove($Progress1,$a_box)
; and ta da working

GUISetState()
While 1
   $msg = GUIGetMsg()
   Select
   Case $msg = $GUI_EVENT_RESIZED
       ;_ResizeHandler();needed to handle child????
         _GuiCtrlStatusBarResize ($StatusBar1)
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
     Case Else
         if $iProgress < 100 Then
             $iProgress = $iProgress +1
             GUICtrlSetData($Progress1,$iProgress)
         Else
             $iProgress = 0
         EndIf
        sleep(100) 
       ;;;;;
   EndSelect
 
WEnd
Exit
;===============================================================================
;Resize things here not handled by GuiCtrlSetResize
;===============================================================================
Func _ResizeHandler()
   _GuiCtrlStatusBarResize ($StatusBar1)
;  _CtrlMove($Progress1,_SizePanel($StatusBar1,1))
EndFunc ;==>_ResizeHandler

;===============================================================================
;GetPanel size and shrink them for progress size.
;===============================================================================
Func _SizePanel($id_control,$i_panel,$i_pad =2)
    Local $a_box = _GuiCtrlStatusBarGetRect($id_control,$i_panel)
;shrink the rect a little to fit inside panel
    $a_box[2] = $a_box[2]- $a_box[0]-$i_pad
    $a_box[3] = $a_box[3]- $a_box[1]-$i_pad
    $a_box[0] = $a_box[0] +$i_pad
    $a_box[1] = $a_box[1] +$i_pad
    Return $a_box
EndFunc

;===============================================================================
;Wrap SetParent Msg
;===============================================================================
Func _SetParent($id_child, $h_parent)
;   Local $h_parent,$h_child
    If Not IsHWnd($h_parent) Then $h_parent = HWnd($h_parent)
    If Not IsHWnd($id_child) Then $id_child = GUICtrlGetHandle($id_child)
    If DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $id_child, "hwnd", $h_parent) <> 0 Then
        Return
    Else
        seterror(1)
        Return 0
    EndIf
EndFunc  ;==>_SetParent

;===============================================================================
;Wrap MoveWindow Msg
;===============================================================================

Func _CtrlMove($id_control,$a_metric,$b_repaint =True)
    Local $h_control
    If Not IsHWnd($id_control) Then $h_control = GUICtrlGetHandle($id_control)
    if IsArray($a_metric) Then
        if DllCall("user32.dll", "long", "MoveWindow", "hwnd", $h_control, _
            "int", $a_metric[0], "int", $a_metric[1], _
            "int", $a_metric[2], "int", $a_metric[3], "int",$b_repaint) <> 0 Then
            Return
        Else
            seterror(1)
            Return 0
        EndIf
        
    Else
        seterror(1)
        Return 0        
    EndIf
EndFunc

Hope this is useful,

Steve.

Link to comment
Share on other sites

updated _GuiCtrlStatusBarCreate so that styles can be set ( see my previous post)

opt("MustDeclareVars", 1)

#include-once
#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $ret0, $ret1, $msg, $ret2, $retl1, $retcode, $asize[1]
Local $a[3] = [100, 350, -1]
Local $s[3] = ["New Text", "How about music", "Even More Text"]
$gui = GUICreate("StatusBar GUI", 500, -1, -1, -1, $WS_SIZEBOX)
GUISetState(@SW_SHOW)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a, "", BitOR($CCS_TOP,$SBT_TOOLTIPS))
;~ $StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a, $s)
_GuiCtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)
_GuiCtrlStatusBarSetBKColor($StatusBar1,0xffff00)
_GuiCtrlStatusBarSetTip($StatusBar1, 0, "Part 1")
_GuiCtrlStatusBarSetTip($StatusBar1, 1, "Part 2")
_GuiCtrlStatusBarSetTip($StatusBar1, 2, "Part 3")
_GuiCtrlStatusBarSetMinHeight($StatusBar1, 50)

Local $a_rect = _GuiCtrlStatusBarGetRect($StatusBar1, 0)
If IsArray($a_rect) Then _
  MsgBox(0, "Rect", "Left: " & $a_rect[0] & @LF & _
  "Top: " & $a_rect[1] & @LF & _
  "Right: " & $a_rect[2] & @LF & _
  "Bottom: " & $a_rect[3])

Local $a_borders = _GuiCtrlStatusBarGetBorders($StatusBar1)
If IsArray($a_borders) Then _
  MsgBox(0, "Borders", "width of the horizontal border: " & $a_rect[0] & @LF & _
  "width of the vertical border: " & $a_rect[1] & @LF & _
  "width of the border between rectangles: " & $a_rect[2])
_GuiCtrlStatusBarSetUnicode($StatusBar1, False)
If _GuiCtrlStatusBarGetUnicode($StatusBar1) Then
 _GuiCtrlStatusBarSetText ($StatusBar1, "using Unicode characters", 1)
Else
 _GuiCtrlStatusBarSetText ($StatusBar1, "NOT using Unicode characters", 1)
EndIf

_GuiCtrlStatusBarSetSimple($StatusBar1)
_GuiCtrlStatusBarSetText ($StatusBar1, "simple mode", 255)
_GuiCtrlStatusBarResize ($StatusBar1)
Sleep(3000)
_GuiCtrlStatusBarSetSimple($StatusBar1, False)

While 1
 $msg = GUIGetMsg()
 Select
  Case $msg = $GUI_EVENT_RESIZED
   _GuiCtrlStatusBarResize ($StatusBar1)
  Case $msg = $GUI_EVENT_CLOSE
   ExitLoop
  Case Else
  ;;;;;
 EndSelect
 
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Examples, I'll add them as I get them created, please check them for anything needing to be changed

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Create", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [150, 300, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Border Widths", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

Local $a_borders = _GuiCtrlStatusBarGetBorders($StatusBar1)
If IsArray($a_borders) Then
    _GuiCtrlStatusBarSetText($StatusBar1, "horizontal border: " & $a_borders[0], 0)
    _GuiCtrlStatusBarSetText($StatusBar1, "vertical border: " & $a_borders[1], 1)
    _GuiCtrlStatusBarSetText($StatusBar1, "between rectangles: " & $a_borders[2], 2)
EndIf

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Icon", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
_GuiCtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)

_GuiCtrlStatusBarSetText($StatusBar1, _GuiCtrlStatusBarGetIcon($StatusBar1, 0), 0)
_GuiCtrlStatusBarSetText($StatusBar1, _GuiCtrlStatusBarGetIcon($StatusBar1, 1), 1)
_GuiCtrlStatusBarSetText($StatusBar1, _GuiCtrlStatusBarGetIcon($StatusBar1, 2), 2)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Set Icon", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

_GuiCtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $lbl_Parts
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Parts", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
$lbl_Parts = GUICtrlCreateLabel("Number of Parts: " & _GuiCtrlStatusBarGetParts($StatusBar1),10,10,100,25,$SS_SUNKEN )

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[4] = [100, 200, 350, -1]
Local $a_PartsText[4] = ["New Text", "More Text", "Even More Text", "Hey some more"]

$gui = GUICreate("Status Bar Get Rect", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

Local $a_rect = _GuiCtrlStatusBarGetRect ($StatusBar1, 1)
If IsArray($a_rect) Then
    _GuiCtrlStatusBarSetText ($StatusBar1, "Left: " & $a_rect[0], 0)
    _GuiCtrlStatusBarSetText ($StatusBar1, "Top: " & $a_rect[1], 1)
    _GuiCtrlStatusBarSetText ($StatusBar1, "Right: " & $a_rect[2], 2)
    _GuiCtrlStatusBarSetText ($StatusBar1, "Bottom: " & $a_rect[3], 3)
EndIf

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $lbl_Info
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Text", 500, -1, -1, -1, $WS_SIZEBOX)
$lbl_Info = GUICtrlCreateLabel("", 10, 10, 150, 50, $SS_SUNKEN)
$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

GUICtrlSetData($lbl_Info, "1st Part: " & _GuiCtrlStatusBarGetText ($StatusBar1, 0) & @LF & _
        "2nd Part: " & _GuiCtrlStatusBarGetText ($StatusBar1, 1) & @LF & _
        "3rd Part: " & _GuiCtrlStatusBarGetText ($StatusBar1, 2))

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $lbl_Info
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Text Length", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
$lbl_Info = GUICtrlCreateLabel("Text Length of 3rd Part: " & _GuiCtrlStatusBarGetTextLength ($StatusBar1, 2), 10, 10, 150, 20)

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $lbl_Info
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Tip Text", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, "", $SBT_TOOLTIPS)

_GuiCtrlStatusBarSetIcon ($StatusBar1, 1, "shell32.dll", 168)
_GuiCtrlStatusBarSetIcon ($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetIcon ($StatusBar1, 2, "shell32.dll", 24)

_GuiCtrlStatusBarSetTip ($StatusBar1, 0, "Part 1")
_GuiCtrlStatusBarSetTip ($StatusBar1, 1, "This is a Tip for the status bar")
_GuiCtrlStatusBarSetTip ($StatusBar1, 2, "Part 3")

$lbl_Info = GUICtrlCreateLabel("Tip Text of 2nd Part: " & _GuiCtrlStatusBarGetTipText ($StatusBar1, 1), 10, 10, 250, 20)

GUISetState(@SW_SHOW)



While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Unicode", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

If _GuiCtrlStatusBarGetUnicode ($StatusBar1) Then
   _GuiCtrlStatusBarSetText ($StatusBar1, "Using Unicode characters", 1)
Else
   _GuiCtrlStatusBarSetText ($StatusBar1, "NOT using Unicode characters", 1)
EndIf

GUISetState(@SW_SHOW)

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_RESIZED
         _GuiCtrlStatusBarResize ($StatusBar1)
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case Else
    ;;;;;
   EndSelect
   
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Resize", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]
Local Const $Yellow = 0xffff00

$gui = GUICreate("Status Bar Set Back Color", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
_GuiCtrlStatusBarSetBKColor ($StatusBar1, $Yellow)

GUISetState(@SW_SHOW)

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_RESIZED
         _GuiCtrlStatusBarResize ($StatusBar1)
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case Else
;;;;;
   EndSelect
   
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Set Min Height", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
_GuiCtrlStatusBarSetMinHeight($StatusBar1, 30)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Set Simple", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

GUISetState(@SW_SHOW)

Sleep(3000)
_GuiCtrlStatusBarSetSimple($StatusBar1)
_GuiCtrlStatusBarSetText ($StatusBar1, "simple mode", 255)
_GuiCtrlStatusBarResize ($StatusBar1)
Sleep(3000)
_GuiCtrlStatusBarSetSimple($StatusBar1, False)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Set Text", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
_GuiCtrlStatusBarSetText ($StatusBar1, "Text has been set", 1)

GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Set Unicode", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

_GuiCtrlStatusBarSetUnicode($StatusBar1, False)
If _GuiCtrlStatusBarGetUnicode($StatusBar1) Then
    _GuiCtrlStatusBarSetText ($StatusBar1, "using Unicode characters", 1)
Else
    _GuiCtrlStatusBarSetText ($StatusBar1, "NOT using Unicode characters", 1)
EndIf

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
    ;;;;;
    EndSelect
    
WEnd

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 200, -1]
Local $a_PartsText[3] = ["", "Force tip to be shown when text is more than fits in the box", "Even More Text"]

$gui = GUICreate("Status Bar Set Tip", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GuiCtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText, $SBT_TOOLTIPS)
_GuiCtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GuiCtrlStatusBarSetTip($StatusBar1, 0, "Tip works when only icon in part or text exceeds part")
_GuiCtrlStatusBarSetTip($StatusBar1, 1, "Force tip to be shown when text is more than fits in the box")
_GuiCtrlStatusBarSetTip($StatusBar1, 2, "Part 3")

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GuiCtrlStatusBarResize ($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
        ;;;;;
    EndSelect
    
WEnd
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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...