Jump to content

_GUICtrlStatusBar_Resize_Equidistant()


Recommended Posts

..in the words of @Andreik: "nah, you do it".  So I posted :P

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_hStatus, $g_aParts

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("StatusBar Resize Equidistant (v" & @AutoItVersion & ")", 400, 300, -1, -1, $WS_OVERLAPPEDWINDOW)

    ; Set parts
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
    Dim $g_aParts[3] ; = [75, 150, -1] ; it no longer matters
    _GUICtrlStatusBar_SetParts($g_hStatus, $g_aParts)
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 0")
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 1", 1)
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 2", 2)
    _GUICtrlStatusBar_Resize_Equidistant($g_hStatus, $g_aParts, $hGUI)

    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Resize the status bar when GUI size changes
Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    _GUICtrlStatusBar_Resize_Equidistant($g_hStatus, $g_aParts, $hWnd)
    If @error Then _GUICtrlStatusBar_Resize($g_hStatus)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func _GUICtrlStatusBar_Resize_Equidistant($hStatus, ByRef $aParts, $hGUI)
    Local $aPos = WinGetPos($hGUI)
    If @error Then Return SetError(1, 0, 0)
    Local $iSize = Int(($aPos[2] - 24) / UBound($aParts))
    Local $aTemp[UBound($aParts)] ; the "- 24" makes it look more even
    For $n = 0 To UBound($aParts) - 2
        $aTemp[$n] = $iSize * ($n + 1)
    Next
    $aTemp[$n] = -1
    $aParts = $aTemp ; in case of WinGetPos() error.
    _GUICtrlStatusBar_SetParts($g_hStatus, $aTemp)
EndFunc   ;==>_GUICtrlStatusBar_Resize_Equidistant

Same as resize but proportional/equidistant.

Edited by argumentum
better code

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • argumentum changed the title to _GUICtrlStatusBar_Resize_Equidistant()

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