Jump to content

Recommended Posts

Posted

Does anyone know of a method to remove the sizing grip (SBARS_SIZEGRIP) from a status bar?

Or, alternatively, a method to color the sizing grip?

My understanding is that it is automatically added by default when a GUI is made resizable. The problem is that the sizing grip (SBARS_SIZEGRIP) does not look good at all with any kind of theming.

From the help file for _GUICtrlStatusBar_Create for the 3rd option ($iStyles) it says:

Quote

[optional] Control styles:
    $SBARS_SIZEGRIP - The status bar control will include a sizing grip at the right end of the status bar
    $SBARS_TOOLTIPS - The status bar will have tooltips

Forced: $WS_CHILD, $WS_VISIBLE

So I was hoping that I could try setting 0 for that option instead of -1 (default) to cancel it out like with other functions. But that did not work. In the example code below, I still have 0 set like $g_hStatus = _GUICtrlStatusBar_Create($hGUI, -1, -1, 0) although it did not work.

Example:

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

Global $g_hStatus

Example()

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

        ; Set parts
        $g_hStatus = _GUICtrlStatusBar_Create($hGUI, -1, -1, 0)
        Local $aParts[3] = [75, 150, -1]
        _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
        _GUICtrlStatusBar_SetText($g_hStatus, "Part 0")
        _GUICtrlStatusBar_SetText($g_hStatus, "Part 1", 1)
        _GUICtrlStatusBar_SetText($g_hStatus, "Part 2", 2)

        ; to allow the setting of Bk Color at least under Windows 10
        _WinAPI_SetWindowTheme($g_hStatus, "", "")

        ; Set GUI background color
        GUISetBkColor(0x202020)

        ; Set status bar background color
        _GUICtrlStatusBar_SetBkColor($g_hStatus, 0x202020)

        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($g_hStatus)
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

 

Posted

I just had an adventure with the code from the other thread. I modified the code just slightly hoping to target the status bar sizing grip. What happened next was like a virus from the 80s or 90s. Somehow the example started spawning thousands of AutoIt processes and was moving everything around in on my desktop, start menu, within File Explorer, etc. I wasn't able to stop it with System Informer because everything was moving everywhere. So I ended up having to power down the laptop by holding down the Power button for 30 seconds or more.

Long story short, this is far too advanced for my skill level and I really need some help if possible, please.

The example in the other thread targets a similar looking sizing grip but not specifically status bar.

I appreciate any help. Thank you.

Posted (edited)

I'm not sure this is what you are asking for. But I'll give it a try.

I use the following function (written by Melba23) to remove style settings from controls:

; #INTERNAL_USE_ONLY#============================================================================================================
; Name ..........: __Remove_Style
; Description ...: Remove a style from a single or multiple GUI controls.
; Syntax ........: __Remove_Style($iStyleToRemove, $id1[, $id2 = 0[, $id3 = 0[, $id4 = 0[, $id5 = 0[, $id6 = 0[, $id7 = 0[, $id8 = 0[, $id9 = 0[, $id10 = 0]]]]]]]]])
; Parameters ....: $iStyleToRemove - integer value of the style to remove.
;                  $id1            - ControlID to remove the style from.
;                  $id2 to $id10   - [optional] additional ControlIDs to remove the style from.
; Return values .: Success - 0
;                  Failure - None
; Author ........: Melba23
; Modified ......:
; Remarks .......: Code taken from: https://www.autoitscript.com/forum/topic/209900-ignore-control-in-taborder/?tab=comments#comment-1515251
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func __Remove_Style($iStyleToRemove, $id1, $id2 = 0, $id3 = 0, $id4 = 0, $id5 = 0, $id6 = 0, $id7 = 0, $id8 = 0, $id9 = 0, $id10 = 0)
    #forceref $id1, $id2, $id3, $id4, $id5, $id6, $id7, $id8, $id9, $id10
    Local $hControl, $iStyle
    For $i = 1 To @NumParams - 1 ; @NumParams must be between 2 and 11. The 1st parameter will always be the style to remove.
        $hControl = GUICtrlGetHandle(Eval("id" & $i))
        $iStyle = _WinAPI_GetWindowLong($hControl, $GWL_STYLE)
        If BitAND($iStyle, $iStyleToRemove) = $iStyleToRemove Then _
                _WinAPI_SetWindowLong($hControl, $GWL_STYLE, BitXOR($iStyle, $iStyleToRemove))
    Next
EndFunc   ;==>__Remove_Style

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted
1 hour ago, water said:

I use the following function (written by Melba23) to remove style settings from controls:

Thank you. I won’t be able to try this until later this evening. But I’m trying to understand part of it at the moment.

Would 0x100 be the integer part that it is referring to as the style integer?

Posted

I would simply use the constant $SBARS_SIZEGRIP.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

Mixed some code from here & there, ended with this :

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WinAPIGdi.au3>
#include <WinAPISysWin.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)

Global $g_hGui, $g_hStatus, $g_hSizebox, $g_hOldProc, $g_hBrush

Example()

Func Example()
    Local Const $SBS_SIZEBOX = 0x08, $SBS_SIZEGRIP = 0x10
    Local $iW = 250, $iH = 100, $iBkColor = 0x00FF00

    $g_hGui = GUICreate("Resize corner", $iW, $iH, -1, -1, $WS_OVERLAPPEDWINDOW)

    $g_hStatus = _GUICtrlStatusBar_Create($g_hGui)
    Local $aParts[3] = [75, 150, -1]
    _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 0")
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 1", 1)
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 2", 2)

    ; to allow the setting of Bk Color at least under Windows 10
    _WinAPI_SetWindowTheme($g_hStatus, "", "")

    ; Set GUI background color
    GUISetBkColor($iBkColor)

    ; Set status bar background color
    _GUICtrlStatusBar_SetBkColor($g_hStatus, $iBkColor)

    ; Create a sizebox window (Scrollbar class)    
    $g_hSizebox = _WinAPI_CreateWindowEx(0, "Scrollbar", "", $WS_CHILD + $WS_VISIBLE + $SBS_SIZEBOX, $iW - 20, $iH - 20, 20, 20, $g_hGui) ; $SBS_SIZEBOX or $SBS_SIZEGRIP

    ; Subclass the sizebox (by changing the window procedure associated with the Scrollbar class)
    Local $hProc = DllCallbackRegister('ScrollbarProc', 'lresult', 'hwnd;uint;wparam;lparam')
    $g_hOldProc = _WinAPI_SetWindowLong($g_hSizebox, $GWL_WNDPROC, DllCallbackGetPtr($hProc))

    $g_hBrush = _WinAPI_CreateSolidBrush($iBkColor)

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    _WinAPI_DeleteObject($g_hBrush)
    _WinAPI_SetWindowLong($g_hSizebox, $GWL_WNDPROC, $g_hOldProc)
    DllCallbackFree($hProc)
    GUIDelete($g_hGui)
EndFunc   ;==>Example

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    Local $aSize = WinGetClientSize($g_hGui)
    WinMove($g_hStatus, "", 0, $aSize[1] - 20, $aSize[0])
    WinMove($g_hSizebox, "", $aSize[0] - 20, $aSize[1] - 20)
EndFunc   ;==>WM_SIZE

Func ScrollbarProc($hWnd, $iMsg, $wParam, $lParam) ; Andreik's
    If $hWnd = $g_hSizebox Then
        Switch $iMsg
            Case $WM_ERASEBKGND
                Local $tRect = _WinAPI_GetClientRect($hWnd)
                _WinAPI_FillRect($wParam, $tRect, $g_hBrush)
                Return True

            Case $WM_PAINT
                Local $tPAINTSTRUCT
                Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
                Local $tRect = _WinAPI_CreateRect($tPAINTSTRUCT.Left, $tPAINTSTRUCT.Top, $tPAINTSTRUCT.Right, $tPAINTSTRUCT.Bottom)
                _WinAPI_FillRect($hDC, $tRect, $g_hBrush)
                _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
                Return 0
        EndSwitch
    EndIf
    Return _WinAPI_CallWindowProc($g_hOldProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc

It got your custom StatusBar, it's resizable and background color is the same everywhere.
Parts of the status bar should probably grow while you resize the GUI (to be coded), the functional resize corner should show something... but at least it's a start :)

Edited by pixelsearch
all global variables start with $g_

"I think you are searching a bug where there is no bug... don't listen to bad advice."

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