Jump to content

partially resizable window, how? [Solved (by Danyfirex 👍)]


Gianni
 Share

Recommended Posts

is there a way that allows you to use only the right and bottom sides as "handles" to resize a window?
that is, the "SIZENS" and "SIZEWE" cursors should only appear when the pointer is positioned on the right and bottom edges of the window, allowing only these two to resize the window accordingly.
I'm trying to resize a window not linearly, but in steps of 50 in width / height.
Resizing the right and bottom edges the effect is quite ugly but still acceptable, but if the resizing is done from the left and top edges, the resulting effect is too ugly
Thanks for any tip

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

GUIRegisterMsg($WM_SIZE, 'onResize')
Global $hGUI = GUICreate('Test', 100, 100, Default, Default, $WS_THICKFRAME, $WS_EX_TOOLWINDOW)
Global $iStep = 50
GUISetState()

Do
Until GUIGetMsg() = -3

Func onResize($hwnd, $iMsg, $iwParam, $ilParam)
    Local $aSize = WinGetPos($hwnd)
    Local $width = Round($aSize[2] / $iStep) * $iStep
    Local $height = Round($aSize[3] / $iStep) * $iStep
    WinMove($hwnd, '', Default, Default, $width, $height)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>onResize

 

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

I'm not sure if you meant this.

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

GUIRegisterMsg($WM_SIZE, 'onResize')
Global $GUI = GUICreate('Test', 200, 200, Default, Default, $WS_THICKFRAME, $WS_EX_TOOLWINDOW)
Global $iStep = 50
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case Else

    EndSwitch
WEnd

Func onResize($hwnd, $iMsg, $iwParam, $ilParam)
    Local $aSize = WinGetPos($hwnd)
    Local $width = Round($aSize[2] / $iStep) * $iStep
    Local $height = Round($aSize[3] / $iStep) * $iStep
    WinMove($hwnd, '', Default, Default, $width, $height)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>onResize

Func WM_NCHITTEST($hwnd, $iMsg, $iwParam, $ilParam)
    If $hwnd = $GUI Then
        Local $iRet = _WinAPI_DefWindowProc($hwnd, $iMsg, $iwParam, $ilParam)
        If $iRet = $HTBOTTOM Or $iRet = $HTRIGHT Then
            Return $iRet
        Else
            Return $HTCLIENT
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCHITTEST

Saludos

Link to comment
Share on other sites

Maybe this ... ?

#include <WindowsConstants.au3>

Global Const $WMSZ_LEFT = 1
Global Const $WMSZ_RIGHT = 2
Global Const $WMSZ_TOP = 3
Global Const $WMSZ_TOPLEFT  = 4
Global Const $WMSZ_TOPRIGHT     = 5
Global Const $WMSZ_BOTTOM         = 6
Global Const $WMSZ_BOTTOMLEFT     = 7
Global Const $WMSZ_BOTTOMRIGHT     = 8

Global  $width = 400, $iStep = 50
$Form1 = GUICreate("test", $width, 237, -1, -1, $WS_SIZEBOX)
GUISetState()

GUIRegisterMsg(0x0214, "WM_SIZING")

While GUIGetMsg() <> -3
WEnd


Func WM_SIZING($hWnd, $iMsg, $wparam, $lparam)
    $pos = WinGetPos($Form1)
    Local $sRect = DllStructCreate("Int[4]", $lparam)
    Local $left = DllStructGetData($sRect, 1, 1)
    Local $top = DllStructGetData($sRect, 1, 2)
    Local $Right = DllStructGetData($sRect, 1, 3)
    Local $bottom = DllStructGetData($sRect, 1, 4)

    Switch $wparam
        Case $WMSZ_LEFT, $WMSZ_TOP, $WMSZ_TOPLEFT, $WMSZ_BOTTOMLEFT
            DllStructSetData($sRect, 1, $pos[0], 1)
            DllStructSetData($sRect, 1, $pos[1], 2)
        Case $WMSZ_RIGHT
            If  $pos[2] < $width+50 Then
                 DllStructSetData($sRect, 1, $right+50, 3)
                 $width += 50
            EndIf
    EndSwitch
    Return 'GUI_RUNDEFMSG'
EndFunc

 

Link to comment
Share on other sites

1 hour ago, Danyfirex said:

I'm not sure if you meant this.

exactly that!  Interesting.
Many thanks @Danyfirex
P.S. Thanks a lot also for your high knowledge of windows APIs ... :)

 

6 minutes ago, mikell said:

Maybe this ... ?

Thanks @mikell,

also interesting scipt, (even if with little issues on the "resizing by steps" that should be retouched a bit)
Much appreciated, Thanks

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
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
 Share

  • Recently Browsing   0 members

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