Jump to content

How to get SIZENWSE cursor to show on Statusbar sizegrip?


Go to solution Solved by MattyD,

Recommended Posts

Posted

I have noticed, by default, when you hover over the sizegrip ($SBARS_SIZEGRIP) on the statusbar of a resizable GUI that there is no change in cursor. Generally, it should show the SIZENWSE cursor to indicate that the GUI can be resized from the statusbar gripper.

Below, I will share an example from _GUICtrlStatusBar_Resize. The only change that I made was to add the $SBARS_SIZEGRIP style to _GUICtrlStatusBar_Create() in hopes that it might fix the problem.

It did not fix the problem. I am not sure if this is an AutoIt bug with statusbar or if there is just something that I am missing. Thank you for your time. :)

#include <WindowsStylesConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsNotifsConstants.au3>

Global $g_hStatus

Example()

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

    ; Set parts
    Local $hStatus = _GUICtrlStatusBar_Create($hGUI, -1, -1, $SBARS_SIZEGRIP)
    $g_hStatus = $hStatus

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

    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

Interestingly, I seem to get the cursor change when I add $WS_SIZEBOX during *StatusBar_Create().

Local $hStatus = _GUICtrlStatusBar_Create($hGUI, -1, -1, BitOR($SBARS_SIZEGRIP, $WS_SIZEBOX))

However, it causes some visual bugs.

  • Solution
Posted (edited)

Yeah, we probably need to handle WM_SETCURSOR.

So something like this:

Func WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    Local Static $hCursorSW = _WinAPI_LoadCursor(0, $OCR_SIZENWSE)

    If _WinAPI_LoWord($lParam) = $HTBOTTOMRIGHT Then
        If _WinAPI_GetCursor() <> $hCursorSW Then _WinAPI_SetCursor($hCursorSW)
        Return True
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Or even:

Func WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    
    If _WinAPI_LoWord($lParam) <> $HTCLIENT Then 
        Return _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc
Edited by MattyD
tidy
Posted

I just wanted to follow up with my original example from the first post combined with Matty's fix just in case anyone is curious about this or needs this sometime in the future.

#include <WindowsStylesConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsNotifsConstants.au3>
#include <WinAPISysWin.au3>

Global $g_hStatus

Example()

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

    ; Set parts
    Local $hStatus = _GUICtrlStatusBar_Create($hGUI, -1, -1, $SBARS_SIZEGRIP)
    $g_hStatus = $hStatus

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

    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR")

    ; 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

Func WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    
    If _WinAPI_LoWord($lParam) <> $HTCLIENT Then 
        Return _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SETCURSOR

 

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
×
×
  • Create New...