Gianni Posted January 20, 2020 Share Posted January 20, 2020 (edited) 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 January 20, 2020 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Danyfirex Posted January 20, 2020 Share Posted January 20, 2020 I'm not sure if you meant this. expandcollapse popup#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 pixelsearch and Gianni 2 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
mikell Posted January 20, 2020 Share Posted January 20, 2020 Maybe this ... ? expandcollapse popup#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 Danyfirex and Gianni 2 Link to comment Share on other sites More sharing options...
Gianni Posted January 20, 2020 Author Share Posted January 20, 2020 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 Danyfirex 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now