Jump to content

creating a multiline input control


Recommended Posts

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?
Link to comment
Share on other sites

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]

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

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

  • 3 weeks later...

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
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...