Jump to content

Recommended Posts

Posted

IWantIt

Try this:

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

Global $LineCount = 1, $LineLen = 0
Global $lastdragIP = -1
Dim $hInput_GUI[50], $Input[50]

$hGUI = GUICreate("Test", 300, 200)

$button = GUICtrlCreateButton("", 50, 50, 50, 20)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $button
                If $lastdragIP < 49 Then
                    $lastdragIP += 1
                    createNextdragIP($lastdragIP)
                EndIf
    EndSwitch
    If _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input)) > $LineCount Then
        $LineCount = _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input))
        $aPos = ControlGetPos($hGUI, "", $input)
        GUICtrlSetPos($input, $aPos[0], $aPos[1], $aPos[2], $aPos[3] + 15)
    ElseIf _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input)) < $LineCount Then
        $LineCount = _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input))
        $aPos = ControlGetPos($hGUI, "", $input)
        GUICtrlSetPos($input, $aPos[0], $aPos[1], $aPos[2], $aPos[3] - 15)
    EndIf
WEnd

Func createNextdragIP($nw)
    $start = WinGetPos($hgui)
    $hInput_GUI[$nw] = GUICreate("", 120, 22, 100, 100, $WS_POPUP, $WS_EX_TOOLWINDOW)
    $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
    GUISetState()    
EndFunc

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iIDFrom = BitAND($wParam, 0xFFFF)
    Local $iCode = BitShift($wParam, 16)
   
    Switch $iCode
        Case $EN_UPDATE
            Local $iLen = _GUICtrlEdit_LineLength($iIDFrom)
            
            Local $aInputPos = ControlGetPos($hWnd, "", $iIDFrom)
            Local $aWinPos = WinGetPos($hWnd)
            
            If ($aInputPos[2] / $iLen) < 6.5 Then
                WinMove($hWnd, "", $aWinPos[0], $aWinPos[1], $aWinPos[2] + 10, $aWinPos[3])
                GUICtrlSetPos($iIDFrom, $aInputPos[0], $aInputPos[1], $aInputPos[2] + 10, $aInputPos[3])
            ElseIf ($aInputPos[2] / $iLen) > 6.5 Then
                WinMove($hWnd, "", $aWinPos[0], $aWinPos[1], $aWinPos[2] - 10, $aWinPos[3])
                GUICtrlSetPos($iIDFrom, $aInputPos[0], $aInputPos[1], $aInputPos[2] - 10, $aInputPos[3])
            EndIf
    EndSwitch

    Return $GUI_RUNDEFMSG   
EndFunc
Posted (edited)

Brilliant! Thank you very much.

While I'm studying your changes, how do I make it expand vertically as well?

Edit: Whenever I press enter it shrinks the edit eventually down to it dissappearing :P

Edited by IWantIt

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
  • Recently Browsing   0 members

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