Jump to content

GUICtrlSetOnResize UDF!


MrCreatoR
 Share

Recommended Posts

Hi,

Here is a simple(?) UDF that will allow you to resize ("on the fly") GUI controls by dragging them (the edges).

Usage Syntax: _GUICtrl_Setonresize($hWnd [, $nCtrlID = -1 [, $iWait = 10 [, $iCtrlMinSize = 20 [, $iResizeEdgeFlags = -1]]]])

$hWnd -> Window Handle (returned by GUICreate()).

$nCtrlID -> [Optional] Control Identifier to set the resizing (can be -1 as last control id).

$iWait -> [Optional] Time to wait between each resize attempts (in milliseconds).

$iCtrlMinSize -> [Optional] Control resizing limit (the minimum size).

$iResizeEdgeFlags -> [Optional] Flags for the resizing mode, see the flags constants (default -1, resize all).

Available flags:

Spoiler

$iGCSOR_RESIZE_LEFT - Left resizing mode

$iGCSOR_RESIZE_RIGHT - Right resizing mode

$iGCSOR_RESIZE_TOP - Top resizing mode

$iGCSOR_RESIZE_BOTTOM - Bottom resizing mode

$iGCSOR_RESIZE_LEFTTOPCORNER - Left-Top corner resizing mode

$iGCSOR_RESIZE_LEFTBOTTOMCORNER - Left-Bottom resizing mode

$iGCSOR_RESIZE_RIGHTTOPCORNER - Right-Top resizing mode

$iGCSOR_RESIZE_RIGHTBOTTOMCORNER - Right-Bottom resizing mode

$iGCSOR_RESIZE_ALLCORNERS - All Corners resizing mode

$iGCSOR_RESIZE_ALL - All sides resizing mode

To unset resizing for specific control, just call the function like this:

_GUICtrl_Setonresize(-1, $iCtrlID)

Example:

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

$hGUI = GUICreate("_GUICtrl_Setonresize - Example", 700, 480) ;, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))

$Edit = GUICtrlCreateEdit("Resize only Left edge", 40, 40, 280, 200)
_GUICtrl_Setonresize($hGUI, $Edit, 10, $iGCSOR_DefCtrlMinSize, $iGCSOR_RESIZE_LEFT) ;Resize only Left edge (-1 or $iGCSOR_RESIZE_ALL to resize all)

$ListView = GUICtrlCreateListView("ListView Column", 340, 40, 300, 200)
GUICtrlCreateListViewItem("Item (Top + Bottom)", $ListView)
_GUICtrl_Setonresize($hGUI, $ListView, 10, $iGCSOR_DefCtrlMinSize, BitOR($iGCSOR_RESIZE_TOP, $iGCSOR_RESIZE_BOTTOM)) ;Resize Top + Bottom

$Checkbox = GUICtrlCreateCheckbox("Some Checkbox (Left + Right)", 40, 270)
GUICtrlSetBkColor(-1, 0xFFFFFF)
_GUICtrl_Setonresize($hGUI, $Checkbox, 10, $iGCSOR_DefCtrlMinSize, BitOR($iGCSOR_RESIZE_LEFT, $iGCSOR_RESIZE_RIGHT)) ;Resize Left + Right

$Label = GUICtrlCreateLabel("Some Label (Top + Right)", 40, 320, -1, 15)
GUICtrlSetBkColor(-1, 0x0000FF)
GUICtrlSetColor(-1, 0xFFFFFF)
_GUICtrl_Setonresize($hGUI, $Label, 10, 15, BitOR($iGCSOR_RESIZE_TOP, $iGCSOR_RESIZE_RIGHT)) ;Resize Top + Right

$Button = GUICtrlCreateButton("Some Button (All corners)", 40, 370, 160, 40)
_GUICtrl_Setonresize($hGUI, $Button, 10, $iGCSOR_DefCtrlMinSize, $iGCSOR_RESIZE_ALLCORNERS) ;Resize All Corners

GUISetState(@SW_SHOW, $hGUI)

While 1
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Attachments:

GUICtrl_SetResizing_UDF_1.2.zip

GUICtrl_SetResizing_UDF_1.1.zip

GUICtrl_SetResizing_UDF.zip

Inspired by this thread.

P.S

It is a beta version, so please give a feedback, ideas, etc. muttley

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Good UDF MrCreatoR. I think I will try to use this idea for a Popup Window because it looks better than the way I have been doing it.

One small wish though. I would prefer that you used a timer instead of AdlibEnable so that people can use AdlibEnable in their own script.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@MrCreatoR

Great thing !! muttley

Someone else did a simular thing though. Not as good in performance as yours but it might inspire you.

You first need to drag the control and then resize it ?!

;§+++++++++++++++++++++++++++++++++++§;
;§  Project Based on The Gorganizer  §;
;§  Draggable and Resizable Controls §;
;§  Author: Kurt a.k.a. _Kurt        §;
;§+++++++++++++++++++++++++++++++++++§;

;~REGULAR GUI SECTION
#include <GUIConstants.au3>
$GUI = GUICreate("..Drag Test..")
GUISetBkColor(0x0000ff)
$item1 = GUICtrlCreateButton("         Drag Me", 100, 100, 200, 50)
;~DRAG CONTROLS
Local $LastClick, $SquareResizers[7], $Hover = -1337
$DragOverlay = GUICtrlCreateLabel("", -99, -99, 1, 1, $SS_BLACKFRAME)
$SquareResizers[1] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 12)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[2] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 10)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[3] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 10)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[4] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 12)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[5] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 11)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[6] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 11)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
GUISetState()

While 1
    Sleep(15)
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $SquareResizers[1]
            _GUICtrlResizeNE()
        Case $msg = $SquareResizers[2]
            _GUICtrlResizeNW()
        Case $msg = $SquareResizers[3]
            _GUICtrlResizeSE()
        Case $msg = $SquareResizers[4]
            _GUICtrlResizeSW()
        Case $msg = $SquareResizers[5]
            _GUICtrlResizeN()
        Case $msg = $SquareResizers[6]
            _GUICtrlResizeS()
    EndSelect
    _GUICtrlDrag($Hover)
    _GUICtrlDragOverlay()
WEnd

Func _GUICtrlDragOverlay()
    $cursor = GUIGetCursorInfo()
    If IsArray($cursor) Then
        If $cursor[4] <> 0 Then
            If $cursor[4] <> $SquareResizers[1] AND $cursor[4] <> $SquareResizers[2] AND $cursor[4] <> $SquareResizers[3] AND $cursor[4] <> $SquareResizers[4] AND $cursor[4] <> $SquareResizers[5] AND $cursor[4] <> $SquareResizers[6] Then
                $pos = ControlGetPos($GUI, "", $cursor[4])
                $pos2 = ControlGetPos($GUI, "", $DragOverlay)
                If $pos[0] <> $pos2[0]+1 AND $pos[1] <> $pos2[1]+1 AND $pos[2] <> $pos2[2]-2 AND $pos[3] <> $pos2[3]-2 Then
                    GUICtrlSetPos($DragOverlay, $pos[0]-1, $pos[1]-1, $pos[2]+2, $pos[3]+2)
                    GUICtrlSetState($DragOverlay, $GUI_SHOW)
                    GUICtrlSetState($cursor[4], $GUI_DISABLE)
                    $Hover = $cursor[4]
                EndIf
            EndIf
        Else
            GUICtrlSetState($Hover, $GUI_ENABLE)
            $Hover = -1337
            GUICtrlSetPos($DragOverlay, -99, -99, 1, 1)
        EndIf
    EndIf
EndFunc

Func _GUICtrlResizeS()
    GUISetCursor(11)
    GUICtrlSetCursor($LastClick, 10)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0], $pos[1], $pos[2], ($cursor[1]-$pos[1]))
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[4], ($pos[0]+$pos[2])-2, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0 
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc

Func _GUICtrlResizeN()
    GUISetCursor(11)
    GUICtrlSetCursor($LastClick, 11)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0], $pos[1]-($pos[1]-$cursor[1]), $pos[2], $pos[3]+($pos[1]-$cursor[1]))
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[1], $pos[0]-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[2], ($pos[0]+$pos[2])-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
    Until $cursor[2] = 0 
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc

Func _GUICtrlResizeSE()
    GUISetCursor(10)
    GUICtrlSetCursor($LastClick, 10)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0]-($pos[0]-$cursor[0]), $pos[1], ($pos[0]-$cursor[0])+$pos[2], ($cursor[1]-$pos[1]))
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[1], $pos[0]-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[4], ($pos[0]+$pos[2])-2, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0 
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc

Func _GUICtrlResizeNW()
    GUISetCursor(10)
    GUICtrlSetCursor($LastClick, 10)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0], $pos[1]-($pos[1]-$cursor[1]), $cursor[0]-$pos[0], $pos[3]+($pos[1]-$cursor[1]))
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[1], $pos[0]-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[2], ($pos[0]+$pos[2])-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[4], ($pos[0]+$pos[2])-2, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0 
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc

Func _GUICtrlResizeNE()
    GUISetCursor(12)
    GUICtrlSetCursor($LastClick, 12)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    $XStayPos = $pos[0]+$pos[2]
    $YStayPos = $pos[1]+$pos[3]
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        If $cursor[0] > $XStayPos Then $cursor[0] = $XStayPos
        If $cursor[1] > $YStayPos Then $cursor[1] = $YStayPos
        GUICtrlSetPos($LastClick, $cursor[0], $cursor[1], $XStayPos-$cursor[0], $YStayPos-$cursor[1])
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[1], $pos[0]-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[2], ($pos[0]+$pos[2])-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc

Func _GUICtrlResizeSW()
    GUISetCursor(12)
    GUICtrlSetCursor($LastClick, 12)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0], $pos[1], $cursor[0]-$pos[0], $cursor[1]-$pos[1])
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[4], ($pos[0]+$pos[2])-2, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[2], ($pos[0]+$pos[2])-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc

Func _GUICtrlDrag($Control, $GridScale = 0)
    Select
        Case $msg = $DragOverlay
            For $i = 0 To UBound($SquareResizers)-1
                GUICtrlSetState($SquareResizers[$i], $GUI_HIDE)
            Next
            GUICtrlSetState($DragOverlay, $GUI_HIDE)
            GUICtrlSetCursor($Control, 9)
            $pos = ControlGetPos($GUI, "", $Control)
            $cursor = GUIGetCursorInfo()
            $XStayPos = $cursor[0]-$pos[0]
            $YStayPos = $cursor[1]-$pos[1]
            Do
                Sleep(5)
                $cursor = GUIGetCursorInfo()
                $sX = $cursor[0]-$XStayPos
                $sY = $cursor[1]-$YStayPos
                If $GridScale <> 0 Then
                    $sX = Round($sX/$GridScale)*$GridScale
                    $sY = Round($sY/$GridScale)*$GridScale
                EndIf
                GUICtrlSetPos($Control, $sX, $sY)
            Until $cursor[2] = 0
            GUICtrlSetCursor($Control, 2)
            GUICtrlSetPos($SquareResizers[1], $sX-3, $sY-5)
            GUICtrlSetPos($SquareResizers[2], ($sX+$pos[2])-2, $sY-5)
            GUICtrlSetPos($SquareResizers[3], $sX-3, $sY+$pos[3])
            GUICtrlSetPos($SquareResizers[4], ($sX+$pos[2])-2, $sY+$pos[3])
            GUICtrlSetPos($SquareResizers[5], (($sX+$pos[2])-($pos[2]/2)), $sY-5)
            GUICtrlSetPos($SquareResizers[6], (($sX+$pos[2])-($pos[2]/2)), $sY+$pos[3])
            For $i = 0 To UBound($SquareResizers)-1
                GUICtrlSetState($SquareResizers[$i], $GUI_SHOW)
            Next
            $pos = ControlGetPos($GUI, "", $cursor[4])
            GUICtrlSetPos($DragOverlay, $pos[0]-1, $pos[1]-1, $pos[2]+2, $pos[3]+2)
            GUICtrlSetState($DragOverlay, $GUI_SHOW)
            $LastClick = $Control
    EndSelect
EndFunc

Enjoy

regards

ptrex

Link to comment
Share on other sites

@MrCreatoR:

I tried your example using the code below and it seems I run into a problem of it not re-sizing at all in this example. I have been troubleshooting for the past few hours and cannot understand why this is not working. Do you know why this could be? I would really like to get this example working if you could please help I'd greatly appreciate it.

Here is the code.

#include <GuiConstantsEx.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>

Dim $hInput_GUI[6], $Input[6]

Global $lastdragIP = -1

$GUI = GUICreate("Test", 300, 300)

$button5 = GUICtrlCreateButton("", 100, 200, 40, 25)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $button5
            If $lastdragIP < 5 Then
                $lastdragIP += 1
                createNextdragIP($lastdragIP)
            EndIf
        Case $GUI_EVENT_PRIMARYDOWN
            
            $aMouse_Pos = MouseGetPos()
            $sel = -1
            For $n = 0 To $lastdragIP
                GUISwitch($hInput_GUI[$n])
                $aCursorInfo = GUIGetCursorInfo()
                
                If Not IsArray($aCursorInfo) Then ContinueLoop
                If $aCursorInfo[4] = $Input[$n] Then
                    $sel = $n
                    ExitLoop
                EndIf
                
            Next
            
            If $sel = -1 Then ContinueLoop
            $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel])
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()

                WinMove($hInput_GUI[$sel], "", _
                $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
        Case Else
            _GUICtrl_SetResize($Input, 5, 20, $hInput_GUI)
        EndSelect
WEnd

Func createNextdragIP($nw)
    $start = WinGetPos($GUI)
    $hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0]+30, $start[1]+200, $WS_POPUP, $WS_EX_TOOLWINDOW)
    $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
    GUISetState()

    WinSetOnTop($hInput_GUI, "", 1)
    
EndFunc  ;==>createNextdragIP

Func _GUICtrl_SetResize($nCtrlID, $iDefaultCurID, $iWait=10, $hWnd=0)
    Local $aCurInfo = GUIGetCursorInfo($GUI)
    If @error Then Return
   
    Local $aCtrlInfo = ControlGetPos($GUI, "", $nCtrlID)
    If @error Then Return
   
    Local $iCursorID, $iCheckFlag = -1
   
    If ($aCurInfo[0] > $aCtrlInfo[0]-2 And $aCurInfo[0] < $aCtrlInfo[0]+2) And _
        ($aCurInfo[1] >= $aCtrlInfo[1] And $aCurInfo[1] <= $aCtrlInfo[1]+$aCtrlInfo[3]) Then ;Left
       
        $iCheckFlag = 1
        $iCursorID = 13
    EndIf
   
    If ($aCurInfo[0] > ($aCtrlInfo[0]+$aCtrlInfo[2])-2 And $aCurInfo[0] < ($aCtrlInfo[0]+$aCtrlInfo[2])+2) And _
        ($aCurInfo[1] >= $aCtrlInfo[1] And $aCurInfo[1] <= $aCtrlInfo[1]+$aCtrlInfo[3]) Then ;Right
       
        $iCheckFlag = 2
        $iCursorID = 13
    EndIf
   
    If ($aCurInfo[1] > $aCtrlInfo[1]-2 And $aCurInfo[1] < $aCtrlInfo[1]+2) And _
        ($aCurInfo[0] >= $aCtrlInfo[0] And $aCurInfo[0] <= $aCtrlInfo[0]+$aCtrlInfo[2]) Then ;Top
       
        If $iCheckFlag = 1 Then ;Left+Top
            $iCheckFlag = 5
            $iCursorID = 12
        ElseIf $iCheckFlag = 2 Then ;Right+Top
            $iCheckFlag = 7
            $iCursorID = 10
        Else ;Just Top
            $iCheckFlag = 3
            $iCursorID = 11
        EndIf
    EndIf
   
    If ($aCurInfo[1] > ($aCtrlInfo[1]+$aCtrlInfo[3])-2 And $aCurInfo[1] < ($aCtrlInfo[1]+$aCtrlInfo[3])+2) And _
        ($aCurInfo[0] >= $aCtrlInfo[0] And $aCurInfo[0] <= $aCtrlInfo[0]+$aCtrlInfo[2]) Then ;Bottom
       
        If $iCheckFlag = 1 Then ;Left+Bottom
            $iCheckFlag = 6
            $iCursorID = 10
        ElseIf $iCheckFlag = 2 Then ;Right+Bottom
            $iCheckFlag = 8
            $iCursorID = 12
        Else ;Just Bottom
            $iCheckFlag = 4
            $iCursorID = 11
        EndIf
    EndIf
   
    If $iCheckFlag = -1 Then
        GUICtrlSetCursor($nCtrlID, $iDefaultCurID)
        GUISetCursor(-1, 1, $GUI)
       
        Return
    Else
        GUICtrlSetCursor($nCtrlID, $iCursorID)
        GUISetCursor($iCursorID, 1, $GUI)
    EndIf
   
    While $aCurInfo[2] = 1
        $aCurInfo = GUIGetCursorInfo($GUI)
        If @error Then ExitLoop
       
        $aCtrlInfo = ControlGetPos($GUI, "", $nCtrlID)
        If @error Then ExitLoop
       
        GUISetState(@SW_LOCK)
       
        If $iCheckFlag = 1 Or $iCheckFlag = 5 Or $iCheckFlag = 6 Then ;Left
            If $aCtrlInfo[2] - ($aCurInfo[0]-$aCtrlInfo[0]) > 20 Then _
                GUICtrlSetPos($nCtrlID, $aCurInfo[0], -1, $aCtrlInfo[2] - ($aCurInfo[0]-$aCtrlInfo[0]))
        EndIf
       
        If $iCheckFlag = 2 Or $iCheckFlag = 7 Or $iCheckFlag = 8 Then ;Right
            If $aCurInfo[0] - $aCtrlInfo[0] > 20 Then _
                GUICtrlSetPos($nCtrlID, -1, -1, $aCurInfo[0]-$aCtrlInfo[0])
        EndIf
       
        If $iCheckFlag = 3 Or $iCheckFlag = 5 Or $iCheckFlag = 7 Then ;Top
            If $aCtrlInfo[3] - ($aCurInfo[1]-$aCtrlInfo[1]) > 20 Then _
                GUICtrlSetPos($nCtrlID, -1, $aCurInfo[1], -1, $aCtrlInfo[3] - ($aCurInfo[1]-$aCtrlInfo[1]))
        EndIf
       
        If $iCheckFlag = 4 Or $iCheckFlag = 6 Or $iCheckFlag = 8 Then ;Bottom
            If $aCurInfo[1] - $aCtrlInfo[1] > 20 Then _
                GUICtrlSetPos($nCtrlID, -1, -1, -1, $aCurInfo[1]-$aCtrlInfo[1])
        EndIf
       
        GUISetState(@SW_UNLOCK)
       
        Sleep($iWait)
    WEnd
EndFunc
Link to comment
Share on other sites

Thanks to all for the feedbacks, appreciated muttley

@nowagain

I tried your example using the code below and it seems I run into a problem of it not re-sizing at all in this example

You have issues in this example :) - Case $GUI_EVENT_PRIMARYDOWN should be Case $msg = $GUI_EVENT_PRIMARYDOWN, $Input is an array, you are using it as variable, the same with $hInput_GUI...

I used the UDF from my first post, here is a changed example:

#include <GuiConstantsEx.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <GUICtrl_SetResizing.au3>

Dim $hInput_GUI[6], $Input[6]

Global $lastdragIP = -1

$GUI = GUICreate("Test", 300, 300)

$button5 = GUICtrlCreateButton("", 100, 200, 40, 25)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $button5
            If $lastdragIP < 5 Then
                $lastdragIP += 1
                createNextdragIP($lastdragIP)
            EndIf
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            $aMouse_Pos = MouseGetPos()
            $sel = -1
            
            For $n = 0 To $lastdragIP
                GUISwitch($hInput_GUI[$n])
                $aCursorInfo = GUIGetCursorInfo()
                
                If Not IsArray($aCursorInfo) Then ContinueLoop
                If $aCursorInfo[4] = $Input[$n] Then
                    $sel = $n
                    ExitLoop
                EndIf
            Next
            
            If $sel = -1 Then ContinueLoop
            $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel])
           
           While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()

                WinMove($hInput_GUI[$sel], "", _
                $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
        EndSelect
WEnd

Func createNextdragIP($nw)
    $start = WinGetPos($GUI)
    $hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0]+30, $start[1]+200, $WS_POPUP, $WS_EX_TOOLWINDOW)
    $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
    _GUICtrl_Setonresize($hInput_GUI[$nw], $Input[$nw], 10)
    
    GUISetState()
    WinSetOnTop($hInput_GUI[$nw], "", 1)
EndFunc  ;==>createNextdragIP

But in your case you need different sort of resizing, try to use $WS_SIZEBOX style on the host GUI (the gui that holds the input)...

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

you need different sort of resizing, try to use $WS_SIZEBOX style on the host GUI (the gui that holds the input)...

Like this:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

Dim $hInput_GUI[6], $Input[6]

Global $lastdragIP = -1

$GUI = GUICreate("Test", 300, 300)

$button5 = GUICtrlCreateButton("Create", 20, 270, 70, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $button5
            If $lastdragIP < 5 Then
                $lastdragIP += 1
                createNextdragIP($lastdragIP)
            EndIf
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            $aMouse_Pos = MouseGetPos()
            $sel = -1
            
            For $n = 0 To $lastdragIP
                GUISwitch($hInput_GUI[$n])
                $aCursorInfo = GUIGetCursorInfo()
                
                If Not IsArray($aCursorInfo) Then ContinueLoop
                If $aCursorInfo[4] = $Input[$n] Then
                    $sel = $n
                    ExitLoop
                EndIf
            Next
            
            If $sel = -1 Then ContinueLoop
            $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel])
           
           While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo()
                $aCurrent_Mouse_Pos = MouseGetPos()

                WinMove($hInput_GUI[$sel], "", _
                $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
            WEnd
    EndSelect
WEnd

Func createNextdragIP($nw)
    $start = WinGetPos($GUI)
    
    $hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0]+10, $start[1]+30, $WS_POPUP+$WS_SIZEBOX, $WS_EX_TOOLWINDOW)
    $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    
    GUISetState()
    WinSetOnTop($hInput_GUI[$nw], "", 1)
EndFunc  ;==>createNextdragIP

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

OMG, what a waste Posted Image

It seems that we can just set $WS_SIZEBOX for the control as well, and it will be resizable (but with visible border)...

#include <GUIConstants.au3>

$hGUI = GUICreate("Resizable Control - Demo", 680, 480)

GUICtrlCreateEdit("", 40, 40, 280, 200, BitOr($GUI_SS_DEFAULT_EDIT, $WS_SIZEBOX))
GUICtrlCreateListView("Some Column", 340, 40, 300, 200, BitOr($GUI_SS_DEFAULT_LISTVIEW, $WS_SIZEBOX))
GUICtrlCreateListViewItem("Some Item", -1)
GUICtrlCreateCheckbox("Some Checkbox", 40, 260, 280, 20, BitOr($GUI_SS_DEFAULT_CHECKBOX, $WS_SIZEBOX))
GUICtrlCreateSlider(40, 300, 280, 50, BitOr($GUI_SS_DEFAULT_SLIDER, $WS_SIZEBOX))
GUICtrlCreateButton("Some Button", 40, 370, 280, 50, BitOr($GUI_SS_DEFAULT_BUTTON, $WS_SIZEBOX))
GUICtrlCreateDate("Some Date", 340, 260, 300, 160, BitOr($GUI_SS_DEFAULT_DATE, $WS_SIZEBOX))
GUICtrlCreateProgress(40, 435, 600, 20, BitOr($GUI_SS_DEFAULT_PROGRESS, $WS_SIZEBOX))

GUISetState(@SW_SHOW, $hGUI)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Just the label control from some reason is not resizable muttley

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

thanks for pointing those problems out but when I try to actually "drag" my edits around it locks up most of the time and then when I go tore-size them to a certain point it start to get cut off muttley

whats the reason for this?

Link to comment
Share on other sites

when I try to actually "drag" my edits around it locks up most of the time and then when I go tore-size them to a certain point it start to get cut off

As i mentioned after the example...

But in your case you need different sort of resizing, try to use $WS_SIZEBOX style on the host GUI (the gui that holds the input)...

And later i posted a working example with $WS_SIZEBOX. Just check my last two posts here muttley

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 1 month later...

@MrCreatoR

You might find a use for the messages I discovered for resizing windows. These also work for resizing controls although my example here only demonstrates their use for a window.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 2 months later...

Genius !!!

but why isn't there restricting abilities ?!

suggestions:

-. resize limit: maximum hight/width [seperately]

-. resize only to the left \ right \ up \ down...

-. setting dependency controls, like if you pull A 100px down, B will be pulled with it.

could be very very very useful !!!

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

  • 2 years later...

Update!

v1.1

* 3.3.6.1 compatibility.

+ Added ability to set resize mode.

* General improvements.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

One more update...

[1.2]

* Flags constants renamed from $iGCSOR_*_EDGE to $iGCSOR_RESIZE_*.

+ Added flags to set corners resizing mode:

$iGCSOR_RESIZE_LEFTTOPCORNER, $iGCSOR_RESIZE_LEFTBOTTOMCORNER

$iGCSOR_RESIZE_RIGHTTOPCORNER, $iGCSOR_RESIZE_RIGHTBOTTOMCORNER

- To include all corners modes, use $iGCSOR_RESIZE_ALLCORNERS.

+ Added $iGCSOR_RESIZE_ALL flag (the same as -1).

* Fixed an issue when controls was resized to they original size after the parent window resized (with $WS_SIZEBOX style).

* Now the controls are stricted to the parent window size (they can't be resized/dragged out of the window).

* Example updated.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 1 year later...

hi guy i like so much this udf is very good

i tryed to use

but have little problem , i use like undergroud of gui a foto , but i dont wanna , move a foto only label over foto like a tag

but i dont know how can do this i past code

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1
Author:      myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
;§+++++++++++++++++++++++++++++++++++§;
;§  Project Based on The Gorganizer  §;
;§  Draggable and Resizable Controls §;
;§  Author: Kurt a.k.a. _Kurt      §;
;§+++++++++++++++++++++++++++++++++++§;
;~REGULAR GUI SECTION
#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <Date.au3>
#include <editconstants.au3>
#include <listviewconstants.au3>
#include <staticconstants.au3>
#include <windowsconstants.au3>
#include <guilistview.au3>
#include <Word.au3>
#include <GuiImageList.au3>
#include <Timers.au3>
#include <GuiListBox.au3>
#include <GuiButton.au3>
#include <ComboConstants.au3>
#include <misc.au3>
#include <Word.au3>
#include <MPDF_UDF.au3>
#include <GUIComboBox.au3>
#include <Constants.au3>
#include <DateTimeConstants.au3>
#include <file.au3>
#include <array.au3>
#include <INet.au3>
#include <Process.au3>
#include <ColorPicker.au3>
#include <WinAPI.au3>
#Include <IE.au3>
Local $GUI ;= GUICreate("..Drag Test..")
$Form1  = GUICreate("Form1", 1273, 454, -36, 17, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_MAXIMIZE,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
$Pic1 = GUICtrlCreatePic("C:UsersstefanoPicturesdeIMG.jpg", 24, 56, 980, 620); BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$item1 = GUICtrlCreateLabel("Label1", 920, 224, 124, 17)
;$item2 = GUICtrlCreateLabel("Label1", 920, 24, 124, 17)
GUICtrlSetBkColor(-1, 0x00FF00)
;$item1 = GUICtrlCreateLabel("my moving label", 10, 20);GUICtrlCreateButton("        Drag Me", 100, 100, 200, 50)
;~DRAG CONTROLS
Local $LastClick, $SquareResizers[7], $Hover = -1337
$DragOverlay = GUICtrlCreateLabel("", -99, -99, 1, 1, $SS_BLACKFRAME)
$SquareResizers[1] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 12)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[2] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 10)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[3] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 10)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[4] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 12)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[5] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 11)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
$SquareResizers[6] = GUICtrlCreateLabel("", 0, 0, 5, 5)
GUICtrlSetCursor(-1, 11)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1,$GUI_HIDE)
GUISetState()
While 1
    Sleep(15)
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $SquareResizers[1]
            _GUICtrlResizeNE()
        Case $msg = $SquareResizers[2]
            _GUICtrlResizeNW()
        Case $msg = $SquareResizers[3]
            _GUICtrlResizeSE()
        Case $msg = $SquareResizers[4]
            _GUICtrlResizeSW()
        Case $msg = $SquareResizers[5]
            _GUICtrlResizeN()
        Case $msg = $SquareResizers[6]
            _GUICtrlResizeS()
    EndSelect
    _GUICtrlDrag($Hover)
    _GUICtrlDragOverlay()
WEnd
Func _GUICtrlDragOverlay()
    $cursor = GUIGetCursorInfo()
    If IsArray($cursor) Then
        If $cursor[4] <> 0 Then
            If $cursor[4] <> $SquareResizers[1] AND $cursor[4] <> $SquareResizers[2] AND $cursor[4] <> $SquareResizers[3] AND $cursor[4] <> $SquareResizers[4] AND $cursor[4] <> $SquareResizers[5] AND $cursor[4] <> $SquareResizers[6] Then
                $pos = ControlGetPos($GUI, "", $cursor[4])
                $pos2 = ControlGetPos($GUI, "", $DragOverlay)
                If $pos[0] <> $pos2[0]+1 AND $pos[1] <> $pos2[1]+1 AND $pos[2] <> $pos2[2]-2 AND $pos[3] <> $pos2[3]-2 Then
                    GUICtrlSetPos($DragOverlay, $pos[0]-1, $pos[1]-1, $pos[2]+2, $pos[3]+2)
                    GUICtrlSetState($DragOverlay, $GUI_SHOW)
                    GUICtrlSetState($cursor[4], $GUI_DISABLE)
                    $Hover = $cursor[4]
                EndIf
            EndIf
        Else
            GUICtrlSetState($Hover, $GUI_ENABLE)
            $Hover = -1337
            GUICtrlSetPos($DragOverlay, -99, -99, 1, 1)
        EndIf
    EndIf
EndFunc
Func _GUICtrlResizeS()
    GUISetCursor(11)
    GUICtrlSetCursor($LastClick, 10)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0], $pos[1], $pos[2], ($cursor[1]-$pos[1]))
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[4], ($pos[0]+$pos[2])-2, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc
Func _GUICtrlResizeN()
    GUISetCursor(11)
    GUICtrlSetCursor($LastClick, 11)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0], $pos[1]-($pos[1]-$cursor[1]), $pos[2], $pos[3]+($pos[1]-$cursor[1]))
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[1], $pos[0]-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[2], ($pos[0]+$pos[2])-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
    Until $cursor[2] = 0
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc
Func _GUICtrlResizeSE()
    GUISetCursor(10)
    GUICtrlSetCursor($LastClick, 10)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0]-($pos[0]-$cursor[0]), $pos[1], ($pos[0]-$cursor[0])+$pos[2], ($cursor[1]-$pos[1]))
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[1], $pos[0]-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[4], ($pos[0]+$pos[2])-2, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc
Func _GUICtrlResizeNW()
    GUISetCursor(10)
    GUICtrlSetCursor($LastClick, 10)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0], $pos[1]-($pos[1]-$cursor[1]), $cursor[0]-$pos[0], $pos[3]+($pos[1]-$cursor[1]))
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[1], $pos[0]-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[2], ($pos[0]+$pos[2])-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[4], ($pos[0]+$pos[2])-2, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc
Func _GUICtrlResizeNE()
    GUISetCursor(12)
    GUICtrlSetCursor($LastClick, 12)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    $XStayPos = $pos[0]+$pos[2]
    $YStayPos = $pos[1]+$pos[3]
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        If $cursor[0] > $XStayPos Then $cursor[0] = $XStayPos
        If $cursor[1] > $YStayPos Then $cursor[1] = $YStayPos
        GUICtrlSetPos($LastClick, $cursor[0], $cursor[1], $XStayPos-$cursor[0], $YStayPos-$cursor[1])
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[1], $pos[0]-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[2], ($pos[0]+$pos[2])-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc
Func _GUICtrlResizeSW()
    GUISetCursor(12)
    GUICtrlSetCursor($LastClick, 12)
    GUICtrlSetState($DragOverlay, $GUI_HIDE)
    $pos = ControlGetPos($GUI, "", $LastClick)
    Do
        Sleep(5)
        $cursor = GUIGetCursorInfo()
        GUICtrlSetPos($LastClick, $pos[0], $pos[1], $cursor[0]-$pos[0], $cursor[1]-$pos[1])
        $pos = ControlGetPos($GUI, "", $LastClick)
        GUICtrlSetPos($SquareResizers[4], ($pos[0]+$pos[2])-2, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[2], ($pos[0]+$pos[2])-2, $pos[1]-5)
        GUICtrlSetPos($SquareResizers[3], $pos[0]-3, $pos[1]+$pos[3])
        GUICtrlSetPos($SquareResizers[5], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]-5)
        GUICtrlSetPos($SquareResizers[6], (($pos[0]+$pos[2])-($pos[2]/2)), $pos[1]+$pos[3])
    Until $cursor[2] = 0
    GUICtrlSetCursor($LastClick, 2)
    GUISetCursor(2)
EndFunc
Func _GUICtrlDrag($Control, $GridScale = 0)
    Select
        Case $msg = $DragOverlay
            For $i = 0 To UBound($SquareResizers)-1
                GUICtrlSetState($SquareResizers[$i], $GUI_HIDE)
            Next
            GUICtrlSetState($DragOverlay, $GUI_HIDE)
            GUICtrlSetCursor($Control, 9)
            $pos = ControlGetPos($GUI, "", $Control)
            $cursor = GUIGetCursorInfo()
            $XStayPos = $cursor[0]-$pos[0]
            $YStayPos = $cursor[1]-$pos[1]
            Do
                Sleep(5)
                $cursor = GUIGetCursorInfo()
                $sX = $cursor[0]-$XStayPos
                $sY = $cursor[1]-$YStayPos
                If $GridScale <> 0 Then
                    $sX = Round($sX/$GridScale)*$GridScale
                    $sY = Round($sY/$GridScale)*$GridScale
                EndIf
                GUICtrlSetPos($Control, $sX, $sY)
            Until $cursor[2] = 0
            GUICtrlSetCursor($Control, 2)
            GUICtrlSetPos($SquareResizers[1], $sX-3, $sY-5)
            GUICtrlSetPos($SquareResizers[2], ($sX+$pos[2])-2, $sY-5)
            GUICtrlSetPos($SquareResizers[3], $sX-3, $sY+$pos[3])
            GUICtrlSetPos($SquareResizers[4], ($sX+$pos[2])-2, $sY+$pos[3])
            GUICtrlSetPos($SquareResizers[5], (($sX+$pos[2])-($pos[2]/2)), $sY-5)
            GUICtrlSetPos($SquareResizers[6], (($sX+$pos[2])-($pos[2]/2)), $sY+$pos[3])
            For $i = 0 To UBound($SquareResizers)-1
                GUICtrlSetState($SquareResizers[$i], $GUI_SHOW)
            Next
            $pos = ControlGetPos($GUI, "", $cursor[4])
            GUICtrlSetPos($DragOverlay, $pos[0]-1, $pos[1]-1, $pos[2]+2, $pos[3]+2)
            GUICtrlSetState($DragOverlay, $GUI_SHOW)
            $LastClick = $Control
    EndSelect
EndFunc
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...