argumentum

Resize control

6 posts in this topic

uc?export=view&id=0B4wbNI5yp94SQTE0Mm5Ia

I'd like a way to load a control or something to show the resize corner as shown on a green circle on the pic.
All I know how to do is the status bar as shown in the red circle

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

On my PC it's dots but that probably depends on the theme. 

#include <GUIConstants.au3>
#include <WinAPI.au3>

Opt( "MustDeclareVars", 1 )

Global Const $SBS_SIZEBOX  = 0x08
Global Const $SBS_SIZEGRIP = 0x10

Global $hGui, $hSizebox

Example()


Func Example()
  $hGui = GUICreate( "Resize corner", 300, 200, -1, 300, $WS_OVERLAPPEDWINDOW )
  $hSizebox = _WinAPI_CreateWindowEx( 0, "Scrollbar", "", $WS_CHILD+$WS_VISIBLE+$SBS_SIZEBOX, 300-20, 200-20, 20, 20, $hGui ) ; $SBS_SIZEBOX or $SBS_SIZEGRIP

  GUIRegisterMsg( $WM_SIZE, "WM_SIZE" )

  GUISetState()

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

  GUIDelete( $hGui )
  Exit
EndFunc

Func WM_SIZE( $hWnd, $iMsg, $wParam, $lParam )
  Local $aSize = WinGetClientSize( $hGui )
  WinMove( $hSizebox, "", $aSize[0] - 20, $aSize[1] - 20 )
EndFunc

 

Edited by LarsJ
1 person likes this

Share this post


Link to post
Share on other sites

On my PC it's dots but that probably depends on the theme. 

that is exactly what I was asking for but for some reason I get a blinking cursor in top of the control ( as shown in the pic. ) uc?export=view&id=0B4wbNI5yp94Sb1RnQnA1b

Is there a way to avoid that ?, I'm on v3.3.14.2 Win7 x64

Thanks.

Share this post


Link to post
Share on other sites

that is exactly what I was asking for but for some reason I get a blinking cursor in top of the control ( as shown in the pic. ) uc?export=view&id=0B4wbNI5yp94Sb1RnQnA1b

Is there a way to avoid that ?, I'm on v3.3.14.2 Win7 x64

Thanks.

As soon as I added a button ( or any control I'd guess ), the blinking goes away. =)

Share this post


Link to post
Share on other sites

..and hello again.
I'd like to add the cursor corresponding to the function of the grip control, but I've failed to find a way. Help =/

#include <GUIConstants.au3>
#include <WinAPI.au3> ; for _WinAPI_CreateWindowEx()
#include <WinAPIRes.au3> ; for _WinAPI_LoadCursor()
#include <WinAPISys.au3> ; for _WinAPI_SetClassLongEx()

Opt("MustDeclareVars", 1)

Global Const $SBS_SIZEBOX = 0x08
Global Const $SBS_SIZEGRIP = 0x10

Global $hGui, $hSizebox

Example()

Func Example()
    $hGui = GUICreate("Resize corner", 300, 200, -1, 300, $WS_OVERLAPPEDWINDOW)

    ; this shows what I'd like to see,
    ; but obviously covers $hSizebox, making it non-functional.
    GUICtrlCreateLabel("", 300 - 20, 200 - 20, 20, 20)
    GUICtrlSetCursor(-1, 12)

    $hSizebox = _WinAPI_CreateWindowEx(0, "Scrollbar", "", $WS_CHILD + $WS_VISIBLE + $SBS_SIZEBOX, 300 - 20, 200 - 20, 20, 20, $hGui) ; $SBS_SIZEBOX or $SBS_SIZEGRIP

    Local $hCursor = _WinAPI_LoadCursor(0,$IDC_SIZENWSE) ; this is supposed to assing the cursor, but does not   =/
    _WinAPI_SetClassLongEx($hSizebox, $GCL_HCURSOR, $hCursor)

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

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

    GUIDelete($hGui)
    Exit
EndFunc   ;==>Example

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

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I'm ok with this way around. If a better way is found, please post it :)

#include <GUIConstants.au3>
#include <WinAPI.au3> ; for _WinAPI_CreateWindowEx()

Opt("MustDeclareVars", 1)

Global Const $SBS_SIZEBOX = 0x08
Global Const $SBS_SIZEGRIP = 0x10

Global $hGui, $hSizebox

Example()

Func Example()
    $hGui = GUICreate("Resize corner", 300, 200, -1, -1, $WS_OVERLAPPEDWINDOW)

    Local $idResizeLabel = GUICtrlCreateLabel("", 300 - 20, 200 - 20, 22, 22)
    GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    GUICtrlSetCursor(-1, 12)

    $hSizebox = _WinAPI_CreateWindowEx(0, "Scrollbar", "", $WS_CHILD + $WS_VISIBLE + $SBS_SIZEBOX, 300 - 20, 200 - 20, 20, 20, $hGui) ; $SBS_SIZEBOX or $SBS_SIZEGRIP

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUISetState()
    Local $iResize = 0
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $GUI_EVENT_PRIMARYUP
                If $iResize Then
                    $iResize = 0 ; restore the default mouse behaviour
                    GUISetCursor(2, 0, $hGui)
                    GUICtrlSetState($idResizeLabel, $GUI_SHOW)
                EndIf

            Case $idResizeLabel
                $iResize = 1
                GUICtrlSetState($idResizeLabel, $GUI_HIDE)
                GUISetCursor(12, 1, $hGui)
                MouseDown("MAIN") ; ..now that the Ctrl is hidden, nothing is held down, so we fake it ;)

        EndSwitch
    WEnd

    GUIDelete($hGui)
    Exit
EndFunc   ;==>Example

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

 

Edited by argumentum
found a better approach

Share this post


Link to post
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