Jump to content

Recommended Posts

Posted

Examples are done, unless someone has some changes, if no changes then I'll start on the templates for the help file tonight or tomorrow.

Gary

Nice work Gary and everyone else

noted

_GuiCtrlStatusBarSetBKColor ($StatusBar1, $Yellow)

doesn't work in winXP Theme

8)

NEWHeader1.png

Posted

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

Could someone do me a favor? I'm new to this thread & would like to know where the GuiStatusBar.au3 file is located.

Help much appreciated.

P.S. are the changes & additions from this thread in the file you are giving me the URL for?

Regards

Dragonrider

  • Developers
Posted

Could someone do me a favor? I'm new to this thread & would like to know where the GuiStatusBar.au3 file is located.

Help much appreciated.

P.S. are the changes & additions from this thread in the file you are giving me the URL for?

Regards

Dragonrider

This is the version of _GUIStatusbar.au3 that will be in the next BETA installer of AutoIt3...

:lmao:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

I've modified the create func to use extended styles.

;===============================================================================
;
; 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.
;                   $v_exstyles     - Set the extended style(s).  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 = "", $v_exstyles =""]) Creates Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):         rysiora, JdeB, tonedef,
;                   gafrost (Gary Frost (custompcs@charter.net)), eltorro -Steve Podhajecki <gehossafats@netmdc.com>
; Note(s):
;===============================================================================
Func _GuiCtrlStatusBarCreate($h_Gui, $a_PanelWidth, $s_PanelText, $v_styles = "",$v_exstyles = ""); Added extend style
    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, $x,$Class = "msctls_statusbar32"
    Local $style = BitOR($WS_CHILD, $WS_VISIBLE)
    If @NumParams > 3 and $v_styles <> "" then $style = BitOR($style, $v_styles)
;$hwnd_Bar1 = DllCall("comctl32.dll", "long", "CreateStatusWindow", "long", $style, "str", "", "hwnd", $h_Gui, "int", 0)

; use extended styles.
    $hwnd_Bar1 = dllcall("user32.dll", "long","CreateWindowEx", "long", $v_exstyles, _
                                        "str","msctls_statusbar32","str", "", _
                                        "long",$style,"long",0 ,"long",0,"long",0,"long",0, _
                                        "hwnd",$h_Gui,"long",0,"hwnd",$h_Gui,"long",0)
; end use extended styles.  
    If Not @error Then
        _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

Can we get this included in one of the next betas?

I'm still puzzled why the bar doesn't attach to the parent's re-size event like it should.

Posted

Using _GuiCtrlStatusBarSetBKColor with WinXP Theme:

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1) <- 0 doesn't use XP Theme

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1)

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
  • 8 months later...
Posted (edited)

New addition, _GUICtrlStatusBarCreateProgress

I pretty much took eltorros code, and turned it into a UDF... Easier to call that way.

;===============================================================================
;
; Description:     _GUICtrlStatusBarCreateProgress
; Parameter(s):   $h_StatusBar  -   Target status bar
;                   $i_Panel        -   Panel of the status bar to create the progress in
;                   $v_styles       -   Styles to apply to the progress 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:   _GUICtrlStatusBarCreateProgress($h_StatusBar, $i_Panel[, $i_pad = 2[, $v_styles = ""]]) Creates Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):         eltorro, RagnaroktA,
;                   gafrost (Gary Frost (custompcs at charter dot net))
; Note(s):
;===============================================================================
Func _GUICtrlStatusBarCreateProgress($h_StatusBar, $i_Panel, $v_styles = "")
    Local $i_pad = 2, $a_box = _GuiCtrlStatusBarGetRect($h_StatusBar, $i_Panel)
; Shrink the rect a little to fit inside panel
        $a_box[0] = $a_box[0] + $i_pad; left
        $a_box[1] = $a_box[1] + $i_pad; top
        $a_box[2] = $a_box[2] - $a_box[0] - $i_pad*3; width
        $a_box[3] = $a_box[3] - $a_box[1] - $i_pad; height

; Create the progress bar with the proper size.
        $h_Progress = GUICtrlCreateProgress($a_box[0], $a_box[1], $a_box[2], $a_box[3], $v_styles)
        GUICtrlSetResizing($h_Progress, 802)

; Change progressbars parent to statusbar
        If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
        If Not IsHWnd($h_Progress) Then $h_Progress = GUICtrlGetHandle($h_Progress)
        If DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $h_Progress, "hwnd", $h_StatusBar) <> 0 Then
            Return
        Else
            SetError(1)
            Return 0
        EndIf

; Move progressbar to statusbar.
        Local $h_control, $b_repaint = True
        If Not IsHWnd($h_Progress) Then $h_control = GUICtrlGetHandle($h_Progress)
        if IsArray($a_box) Then
            if DllCall("user32.dll", "long", "MoveWindow", "hwnd", $h_control, _
                "int", $a_box[0], "int", $a_box[1], _
                "int", $a_box[2], "int", $a_box[3], "int", $b_repaint) <> 0 Then
                Return
            Else
                SetError(1)
                Return 0
            EndIf
            
        Else
            SetError(1)
            Return 0        
        EndIf
    Return $h_Progress
EndFunc ;==>_GUICtrlStatusBarCreateProgress
Edited by RagnaroktA
Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki
Posted

New addition, _GUICtrlStatusBarCreateProgress

I pretty much took eltorros code, and turned it into a UDF... Easier to call that way.

;===============================================================================
;
; Description:     _GUICtrlStatusBarCreateProgress
; Parameter(s):   $h_StatusBar  -   Target status bar
;                   $i_Panel        -   Panel of the status bar to create the progress in
;                   $v_styles       -   Styles to apply to the progress 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:   _GUICtrlStatusBarCreateProgress($h_StatusBar, $i_Panel[, $i_pad = 2[, $v_styles = ""]]) Creates Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):         eltorro, RagnaroktA,
;                   gafrost (Gary Frost (custompcs at charter dot net))
; Note(s):
;===============================================================================
Func _GUICtrlStatusBarCreateProgress($h_StatusBar, $i_Panel, $v_styles = "")
    Local $i_pad = 2, $a_box = _GuiCtrlStatusBarGetRect($h_StatusBar, $i_Panel)
; Shrink the rect a little to fit inside panel
        $a_box[0] = $a_box[0] + $i_pad; left
        $a_box[1] = $a_box[1] + $i_pad; top
        $a_box[2] = $a_box[2] - $a_box[0] - $i_pad*3; width
        $a_box[3] = $a_box[3] - $a_box[1] - $i_pad; height

; Create the progress bar with the proper size.
        $h_Progress = GUICtrlCreateProgress($a_box[0], $a_box[1], $a_box[2], $a_box[3], $v_styles)
        GUICtrlSetResizing($h_Progress, 802)

; Change progressbars parent to statusbar
        If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
        If Not IsHWnd($h_Progress) Then $h_Progress = GUICtrlGetHandle($h_Progress)
        If DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $h_Progress, "hwnd", $h_StatusBar) <> 0 Then
            Return
        Else
            SetError(1)
            Return 0
        EndIf

; Move progressbar to statusbar.
        Local $h_control, $b_repaint = True
        If Not IsHWnd($h_Progress) Then $h_control = GUICtrlGetHandle($h_Progress)
        if IsArray($a_box) Then
            if DllCall("user32.dll", "long", "MoveWindow", "hwnd", $h_control, _
                "int", $a_box[0], "int", $a_box[1], _
                "int", $a_box[2], "int", $a_box[3], "int", $b_repaint) <> 0 Then
                Return
            Else
                SetError(1)
                Return 0
            EndIf
            
        Else
            SetError(1)
            Return 0        
        EndIf
    Return $h_Progress
EndFunc;==>_GUICtrlStatusBarCreateProgress
Nice try, didn't work tho

Here's a working version

Opt("MustDeclareVars", 1)

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

Local $gui, $StatusBar1, $msg, $ProgressBar1, $iProgress = 0
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)
$ProgressBar1 = _GUICtrlStatusBarCreateProgress($StatusBar1, 1)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_RESIZED
            _GUICtrlStatusBarResize($StatusBar1)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If $ProgressBar1 <> -1 Then
                If $iProgress < 100 Then
                    $iProgress = $iProgress + 1
                    GUICtrlSetData($ProgressBar1, $iProgress)
                Else
                    $iProgress = 0
                EndIf
                Sleep(100)
            EndIf
    EndSelect
    
WEnd

;===============================================================================
;
; Description:       _GUICtrlStatusBarCreateProgress
; Parameter(s):      $h_StatusBar    -    Target status bar
;                    $i_Panel        -    Panel of the status bar to create the progress in
;                    $v_styles        -    Styles to apply to the progress 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:      _GUICtrlStatusBarCreateProgress($h_StatusBar, $i_Panel[, $i_pad = 2[, $v_styles = ""]]) Creates Statusbar. (required: <GuiStatusBar.au3>)
; Author(s):         eltorro, RagnaroktA,
;                    gafrost (Gary Frost (custompcs at charter dot net))
; Note(s):
;===============================================================================
Func _GUICtrlStatusBarCreateProgress($h_StatusBar, $i_Panel, $v_styles = "")
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    Local $i_pad = 2, $a_box = _GUICtrlStatusBarGetRect($h_StatusBar, $i_Panel), $v_ret
    ; Shrink the rect a little to fit inside panel
    $a_box[0] = $a_box[0] + $i_pad; left
    $a_box[1] = $a_box[1] + $i_pad; top
    $a_box[2] = $a_box[2] - $a_box[0] - $i_pad; width
    $a_box[3] = $a_box[3] - $a_box[1] - $i_pad; height

    ; Create the progress bar with the proper size.
    Local $Progress1 = GUICtrlCreateProgress($a_box[0], $a_box[1], $a_box[2], $a_box[3], $v_styles)
    GUICtrlSetResizing($Progress1, 802)

    ; Change progressbars parent to statusbar
    If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar)
    Local $h_Progress = GUICtrlGetHandle($Progress1)
    $v_ret = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $h_Progress, "hwnd", $h_StatusBar)
    If Not IsHWnd($v_ret[0]) Then Return SetError(-1, -1, -1)

    Return $Progress1
EndFunc   ;==>_GUICtrlStatusBarCreateProgress

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

  • 2 years later...
Posted (edited)

Question:

Is there way to add "new line" in _GUICtrlStatusBar_SetTipText()?

I tried 

_GUICtrlStatusBar_SetTipText($StatusBar1, 0, 'line 1' & @CRLF & 'line 2')
_GUICtrlStatusBar_SetTipText($StatusBar1, 0, 'line 1\nline 2')

but no success :-(

EDIT:

This works fine

$label1 = GUICtrlCreateLabel(...)
GUICtrlSetTip($label1, 'line 1' & @CRLF & 'line 2')
Edited by Zedna
Posted (edited)

Question:

Is there way to add "new line" in _GUICtrlStatusBar_SetTipText()?

I tried 

_GUICtrlStatusBar_SetTipText($StatusBar1, 0, 'line 1' & @CRLF & 'line 2')
_GUICtrlStatusBar_SetTipText($StatusBar1, 0, 'line 1\nline 2')

but no success :-(

EDIT:

This works fine

$label1 = GUICtrlCreateLabel(...)
GUICtrlSetTip($label1, 'line 1' & @CRLF & 'line 2')
Zedna

subclass the statusbar, get WM_NOTIFY message

create NMTTDISPINFO struct

get TTN_GETDISPINFO message from struct 'Code' element

send _GUIToolTip_SetMaxTipWidth($hWndFrom, 100) to struct 'hWndFrom' element - tooltip handle

set maxtipwidth to maximum length of tooltip and any text longer than that will wrap or use carriage return/line feed

you can set a global var to the tooltip handle and change colors etc with the tooltip UDFs

MSDN multiline tooltips

http://msdn.microsoft.com/en-us/library/bb...ample_multiline

Edit: I should add you could subclass initially until first tooltip is triggered, set maxwidth, then return to original wndproc, unless you need a subclassed

statusbar for embedded buttons etc.

perhaps there is a better way to get the damn statusbar tooltip handle

Edit 2: example script

#include <GUIConstantsEX.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
#include <GuiToolTip.au3>

Global $hStatusBarTooltip, $fFlag = True
Global $aParts[3] = [60, 120]

$hGUI = GUICreate("StatusBar Embed Control", 200, 150, -1, -1, -1, $WS_EX_TOPMOST)
$hStatus = _GUICtrlStatusBar_Create ($hGUI, -1, "", $SBARS_TOOLTIPS)
_GUICtrlStatusBar_SetParts($hStatus, $aParts)

_GUICtrlStatusBar_SetText($hStatus, 'line 1    line 2', 0)
_GUICtrlStatusBar_SetText($hStatus, 'line 1    line 2', 1)
_GUICtrlStatusBar_SetText($hStatus, 'line 1           line 2', 2)

_GUICtrlStatusBar_SetTipText($hStatus, 0, 'line 1' & @CRLF & 'line 2')
_GUICtrlStatusBar_SetTipText($hStatus, 1, 'line 1' & @CRLF & 'line 2')
_GUICtrlStatusBar_SetTipText($hStatus, 2, 'line 1' & @CRLF & 'line 2')

; subclass StatusBar
$wProcNew = DllCallbackRegister("_StatusBarWndProc", "int", "hwnd;uint;wparam;lparam")
$wProcOld = _WinAPI_SetWindowLong($hStatus, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew))
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func OnAutoItExit()
    _WinAPI_SetWindowLong($hStatus, $GWL_WNDPROC, $wProcOld)
    DllCallbackFree($wProcNew)
    GUIDelete($hGUI)
EndFunc   ;==>OnAutoItExit



Func _StatusBarWndProc($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg, $wParam, $lParam

    Switch $Msg
        Case $WM_NOTIFY
            Local $tNMHDR, $tInfo, $hWndFrom, $iIDFrom, $iCode
            $tInfo = DllStructCreate($tagNMHDR, $lParam)
            ;$tInfo = DllStructCreate($tagNMTTDISPINFO, $lParam) ;if tooltip params not needed use tagNMHDR
            $iCode = DllStructGetData($tInfo, "Code")
            ;$iIDFrom = DllStructGetData($tInfo, "IDFrom")
            $hWndFrom = DllStructGetData($tInfo, "hWndFrom")
            
            Switch $iCode
                Case $TTN_GETDISPINFO, $TTN_GETDISPINFOW ;Sent to retrieve information needed to display a ToolTip
                    ;one time only, get handle and set maxwiidth
                    If $fFlag Then
                        $fFlag = False
                        _GUIToolTip_SetMaxTipWidth($hWndFrom, 100)
                        $hStatusBarTooltip = $hWndFrom
                    EndIf
                    ;set part tooltip colours
                    Local $aTool = _GUIToolTip_GetCurrentTool($hWndFrom)
                    Switch $aTool[2]
                        Case 0
                            _GUIToolTip_SetTipBkColor($hWndFrom, 0xffffff)
                        Case 1
                            _GUIToolTip_SetTipBkColor($hWndFrom, 0x00ffff)
                        Case 2
                            _GUIToolTip_SetTipBkColor($hWndFrom, 0x00ff00)
                    EndSwitch
                    
                Case $TTN_SHOW ; Notifies the owner window that a ToolTip control is about to be displayed
                Case $TTN_POP  ; Notifies the owner window that a ToolTip is about to be hidden
            EndSwitch
    EndSwitch
    ; pass the unhandled messages to default WndProc
    Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam)
EndFunc
Edited by rover

I see fascists...

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
  • Recently Browsing   0 members

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