Jump to content

Recommended Posts

Posted

I found one topic that kind of regarded this, but it was a bit vague. What I need is for the program to follow the lines in the EditBox as they are executed. So for example the first line in the EditBox would be highlighted at the start and then when the user either clicks on the 2nd line or the first line is executed, it would move the highlighting to the 2nd line. (Like in the List view)... But in ListView you can't type in it yourself which is the problem :S.

I'd offer some code, but my question is kind of blatant I suppose. Here is that I am doing to read each line:

$line += 1
$text = _GUICtrlEdit_GetLine($Edit1, $line)
Posted (edited)

Try this ($i is line index, zero-based):

Func SelectLine($edit,$i)
    $cStart = _GUICtrlEdit_LineIndex($edit,$i)
    $cEnd = _GUICtrlEdit_LineIndex($edit,$i+1)
    
    _GUICtrlEdit_SetSel($edit,$cStart,$cEnd-1)
EndFunc

$line += 1

SelectLine($edit1,$line)

And one function more:

Func GetCurLineIndex($edit)
    $curPos = _GUICtrlEdit_GetSel($edit)
    Return _GUICtrlEdit_LineFromChar($edit,$curPos[0])
EndFunc

To select current selected line in edit:

SelectLine($edit1,GetCurLineIndex($edit1))

Edited by Yuraj

ShellExecute("http://www.yuraj.ucoz.com")ProcessClose(@AutoItPID)

Posted (edited)

Try this ($i is line index, zero-based):

Func SelectLine($edit,$i)
    $cStart = _GUICtrlEdit_LineIndex($edit,$i)
    $cEnd = _GUICtrlEdit_LineIndex($edit,$i+1)
    
    _GUICtrlEdit_SetSel($edit,$cStart,$cEnd-1)
EndFunc

$line += 1

SelectLine($edit1,$line)

And one function more:

Func GetCurLineIndex($edit)
    $curPos = _GUICtrlEdit_GetSel($edit)
    Return _GUICtrlEdit_LineFromChar($edit,$curPos[0])
EndFunc

To select current selected line in edit:

SelectLine($edit1,GetCurLineIndex($edit1))

EDIT:

It's not working... ><

Func Pause()
    $Stepstart = 0
    SelectLine($Edit1, $line)
    
EndFunc

Func SelectLine($edit,$i)
    $cStart = _GUICtrlEdit_LineIndex($edit,$i)
    $cEnd = _GUICtrlEdit_LineIndex($edit,$i+1)
    MsgBox(0,"", $cStart & "     " & $cEnd)
    
    _GUICtrlEdit_SetSel($edit,$cStart,$cEnd-1)
EndFunc

Func GetCurLineIndex($edit)     
    $curPos = _GUICtrlEdit_GetSel($edit)
    Return _GUICtrlEdit_LineFromChar($edit,$curPos[0])
EndFunc

I tried SelectLine with both ways you put... neither worked o.o

Edited by UnknownWarrior
Posted

OK, this works for me:

#include <GUIConstants.au3>
#include <GUIEdit.au3>

Dim $line = 0

GUICreate("SelLine",320,240)
$Edit1 = GUICtrlCreateEdit("test" & @CRLF & "blaa"& @CRLF & "blaa"& @CRLF & "blaa",0,30,320,210)
$Btn1 = GUICtrlCreateButton("Select line",0,0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $Btn1
            OnBtnClick()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
    
Func OnBtnClick()
    If $line > (_GUICtrlEdit_GetLineCount($Edit1)-1) Then $line = 0
    GUICtrlSetState($Edit1,$GUI_FOCUS)
    SelectLine($Edit1,$line)
    
    $line += 1
EndFunc

Func SelectLine($edit,$i)
    $cStart = _GUICtrlEdit_LineIndex($edit,$i)
    $cEnd = _GUICtrlEdit_LineIndex($edit,$i+1)

    _GUICtrlEdit_SetSel($edit,$cStart,$cEnd-1)
EndFunc

Func GetCurLineIndex($edit)
    $curPos = _GUICtrlEdit_GetSel($edit)
    Return _GUICtrlEdit_LineFromChar($edit,$curPos[0])
EndFunc

ShellExecute("http://www.yuraj.ucoz.com")ProcessClose(@AutoItPID)

Posted

OK, this works for me:

#include <GUIConstants.au3>
#include <GUIEdit.au3>

Dim $line = 0

GUICreate("SelLine",320,240)
$Edit1 = GUICtrlCreateEdit("test" & @CRLF & "blaa"& @CRLF & "blaa"& @CRLF & "blaa",0,30,320,210)
$Btn1 = GUICtrlCreateButton("Select line",0,0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $Btn1
            OnBtnClick()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
    
Func OnBtnClick()
    If $line > (_GUICtrlEdit_GetLineCount($Edit1)-1) Then $line = 0
    GUICtrlSetState($Edit1,$GUI_FOCUS)
    SelectLine($Edit1,$line)
    
    $line += 1
EndFunc

Func SelectLine($edit,$i)
    $cStart = _GUICtrlEdit_LineIndex($edit,$i)
    $cEnd = _GUICtrlEdit_LineIndex($edit,$i+1)

    _GUICtrlEdit_SetSel($edit,$cStart,$cEnd-1)
EndFunc

Func GetCurLineIndex($edit)
    $curPos = _GUICtrlEdit_GetSel($edit)
    Return _GUICtrlEdit_LineFromChar($edit,$curPos[0])
EndFunc

Aha... for some reason it was the GUICtrlSetState($Edit1,$GUI_FOCUS) .... Working fine and dandy now... thanks! :)

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