Sign in to follow this  
Followers 0
AustrianOak

creating a multiline input control

22 posts in this topic

#1 ·  Posted (edited)

GUICtrlCreateInput("", 25, 25, 40, 40, $ES_MULTILINE)

thats what i did in an attempt to make my input multiline but when i press enter nothing happens?

Edited by nowagain

Share this post


Link to post
Share on other sites



GUICtrlCreateInput("", 25, 25, 40, 40, $ES_MULTILINE)

thats what i did in an attempt to make my input multiline but when i press enter nothing happens?

Why not just use an Edit control, which is multiline anyway?

Share this post


Link to post
Share on other sites

how can i hide the scrollbars on an edit?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

this should work muttley

$Edit = GUICtrlCreateEdit("", 135, 141, 241, 196, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
Edited by Marcuzzo18

[font="Century Gothic"]quisnam est quantum stultus , balatro vel balatro quisnam insistovolubilis in solum rideo risi risum----------------------------------------------------------------------------------------------------------------------------Portable Command Line Tool[/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

it gives me an error point to $ES_AUTOVSCROLL saying variable used without being declared...

Edited by nowagain

Share this post


Link to post
Share on other sites

does anyone know why its giving me this error.

im pretty sure i included the right files...

Share this post


Link to post
Share on other sites

bump.

is this only possible with an input control...?

Share this post


Link to post
Share on other sites

#include <EditConstants.au3>


Regards,Josh

Share this post


Link to post
Share on other sites

i included that already

Share this post


Link to post
Share on other sites

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
GUICreate("blah", 100, 100)
GUICtrlCreateEdit("", 10, 10, 80, 80, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUISetState()
Sleep(3000)

... that works fine for me


Regards,Josh

Share this post


Link to post
Share on other sites

Maybe I badly missaid what I wanted. My fault.

I actually want it to "expand" whenever I press enter so it gets larger.

Is this still possible?

Share this post


Link to post
Share on other sites

nowagain

This?

#include <GuiEdit.au3>

Global $LineCount = 1

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

$input = GUICtrlCreateEdit("", 50, 50, 200, 20, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            ExitLoop
        Case $input
            
    EndSwitch
    
    If _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input)) > $LineCount Then
        $LineCount = _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input))
        ConsoleWrite("Enter pressed" & @LF)
        $aPos = ControlGetPos($hGUI, "", $input)
        GUICtrlSetPos($input, $aPos[0], $aPos[1], $aPos[2], $aPos[3] + 15)
    EndIf
WEnd

Share this post


Link to post
Share on other sites

Precisely.

thank you so much rasim. Not to be greedy, but is there a way I can do this horizontally too?

muttley

Share this post


Link to post
Share on other sites

I tried this code so when I backspaced onto the previously line the edit would return to a smaller size than before. Well,

its returning to a smaller size but its like 3 pixels high and isn't the right size.

Can someone help me with this code

#include <GuiEdit.au3>

Global $LineCount = 1

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

$input = GUICtrlCreateEdit("", 50, 50, 200, 20, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            ExitLoop
        Case $input
           
    EndSwitch
   
    If _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input)) > $LineCount Then
        $LineCount = _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input))
        ConsoleWrite("Enter pressed" & @LF)
        $aPos = ControlGetPos($hGUI, "", $input)
        GUICtrlSetPos($input, $aPos[0], $aPos[1], $aPos[2], $aPos[3] + 15)
    ElseIf _GUICtrlEdit_GetLineCount(GUICtrlGetHandle($input)) < $LineCount Then
            $sPos = ControlGetPos($hGUI, "", $input)
            GUICtrlSetPos($input, $sPos[0], $sPos[1], $sPos[2], $sPos[3] - 15)
    EndIf
WEnd

Share this post


Link to post
Share on other sites

nowagain

I tried this code so when I backspaced onto the previously line the edit would return to a smaller size than before. Well,

its returning to a smaller size but its like 3 pixels high and isn't the right size.

Try this:

#include <GuiEdit.au3>

Global $LineCount = 1, $LineLen = 0

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

$input = GUICtrlCreateEdit("", 50, 50, 200, 20, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            ExitLoop
    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

Share this post


Link to post
Share on other sites

nowagain

Not to be greedy, but is there a way I can do this horizontally too?

Example:

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

Global $LineCount = 1, $LineLen = 0

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

$input = GUICtrlCreateEdit("", 50, 50, 50, 20, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            ExitLoop
    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 WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iIDFrom = BitAND($wParam, 0xFFFF)
    Local $iCode = BitShift($wParam, 16)
    
    Switch $iIDFrom
        Case $input
            Switch $iCode
                Case $EN_UPDATE
                    Local $iLen = _GUICtrlEdit_LineLength($input)
                    Local $aInputPos = ControlGetPos($hGUI, "", $input)
                    If ($aInputPos[2] / $iLen) < 6.5 Then
                        GUICtrlSetPos($input, $aInputPos[0], $aInputPos[1], $aInputPos[2] + 10, $aInputPos[3])
                    ElseIf ($aInputPos[2] / $iLen) > 30 Then
                        GUICtrlSetPos($input, $aInputPos[0], $aInputPos[1], $aInputPos[2] - 10, $aInputPos[3])
                    EndIf
                    
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG   
EndFunc

Share this post


Link to post
Share on other sites

this is great. i could have never done this.

btw: every time i press enter it shrinks the width of the input and eventually to like 5 pixels?

is it supposed to be like that?

muttley

Share this post


Link to post
Share on other sites

Hmm...

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

Global $LineCount = 1, $LineLen = 0, $MaxLen = 0

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

$input = GUICtrlCreateEdit("", 50, 50, 50, 20, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            ExitLoop
    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 WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iIDFrom = BitAND($wParam, 0xFFFF)
    Local $iCode = BitShift($wParam, 16)
    
    Switch $iIDFrom
        Case $input
            Switch $iCode
                Case $EN_UPDATE
                    Local $iLen = _GUICtrlEdit_LineLength($input)
                    If $iLen > $MaxLen Then $MaxLen = $iLen
                    Local $aInputPos = ControlGetPos($hGUI, "", $input)
                    If ($aInputPos[2] / $MaxLen) < 6.5 Then
                        GUICtrlSetPos($input, $aInputPos[0], $aInputPos[1], $aInputPos[2] + 10, $aInputPos[3])
                    ElseIf ($aInputPos[2] / $MaxLen) > 100 Then
                        GUICtrlSetPos($input, $aInputPos[0], $aInputPos[1], $aInputPos[2] - 10, $aInputPos[3])
                    EndIf
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG   
EndFunc

Share this post


Link to post
Share on other sites

thanks!

Share this post


Link to post
Share on other sites

hi rasim, can you check out this code for me? it is supposed to create a multiline edit for every edit control but when i try to simulate in this example what ive seen in yours and it doesn't work. can you help?

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

Global $LineCount = 1, $LineLen = 0, $MaxLen = 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 $iIDFrom
        Case $input
            Switch $iCode
                Case $EN_UPDATE
                    Local $iLen = _GUICtrlEdit_LineLength($input)
                    If $iLen > $MaxLen Then $MaxLen = $iLen
                    Local $aInputPos = ControlGetPos($hGUI, "", $input)
                    If ($aInputPos[2] / $MaxLen) < 6.5 Then
                        GUICtrlSetPos($input, $aInputPos[0], $aInputPos[1], $aInputPos[2] + 10, $aInputPos[3])
                    ElseIf ($aInputPos[2] / $MaxLen) > 100 Then
                        GUICtrlSetPos($input, $aInputPos[0], $aInputPos[1], $aInputPos[2] - 10, $aInputPos[3])
                    EndIf
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG   
EndFunc

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
Sign in to follow this  
Followers 0