 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
mAdDoG
Joined: 29 Dec 2004 Posts: 75
|
Posted: Sun Nov 29, 2009 9:48 pm Post subject: Scroll to line in edit control |
|
|
How would you scroll to a specific line in an edit control using "SendMessage"?
| Code: | text = 1`n2`n3`n4`n5`n6`n7`n8`n9`n10
Gui Add, Button,,Go
Gui Add, Edit, w100 vLine, enter line #...
Gui Add, Edit, w100 r3 vEdit, %text%
Gui Show,, test
WinGet ID, ID, test
return |
_________________ -buttons, buttons,...
I like to push all the buttons!!! |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Sun Nov 29, 2009 11:54 pm Post subject: |
|
|
You don't need sendmessage.
you can use ControGet
| Quote: |
ControlGet, OutputVar, Cmd [, Value, Control, WinTitle... ]
Line, N: Sets OutputVar to be the text of line N in an Edit control. Line 1 is the first line. Depending on the nature of the control, OutputVar might end in a carriage return (`r) or a carriage return + linefeed (`r`n). If the specified line number is blank or does not exist, ErrorLevel is set to 1 and OutputVar is made blank.
|
| Code: |
ControlGet, OutputVar, Line, 1, Edit1, Some Window Title
|
Change thevalue in Red to go to the specified line number _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
mAdDoG
Joined: 29 Dec 2004 Posts: 75
|
Posted: Mon Nov 30, 2009 12:07 am Post subject: |
|
|
Thanks, but that will only return the line's contents in "OutputVar".
What I need to find out is how to actually scroll/navagate to a specific line. _________________ -buttons, buttons,...
I like to push all the buttons!!! |
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 460
|
Posted: Mon Nov 30, 2009 12:34 am Post subject: |
|
|
This should do ya.
| Code: | text = 1`n2`n3`n4`n5`n6`n7`n8`n9`n10
Gui Add, Button,,Go
Gui Add, Edit, w100 vLine, enter line #...
Gui Add, Edit, w100 r3 vEdit, %text%
Gui Show,, test
WinGet winID, ID, test
return
ButtonGo:
Gui, Submit, NoHide
scrollTo(winID, "Edit2", Line)
Return
scrollTo(winID, editCNN, lineSel) ;window ID, Control class name+number, line to scroll to
{
SendMessage, 0xCE, 0, 0, %editCNN%, ahk_id %winID% ; EM_GETFIRSTVISIBLELINE to get first line shown (results stored in ErrorLevel)
lineSet := lineSel - ErrorLevel -1 ;get difference between current line and zeroth line, subtract one
PostMessage, 0xB6, 0, %lineSet%, %editCNN%, ahk_id %winID% ; EM_LINESCROLL to scroll target to top
GuiControl, Focus, %editCNN% ;set focus to the edit ctrl
lineSel-- ;EM_LINEINDEX is 0-based, so sub one
SendMessage, 0xBB, %lineSel%, 0, %editCNN%, ahk_id %winID% ; EM_LINEINDEX to get first char from line (results stored in ErrorLevel)
PostMessage, 0xB1, %ErrorLevel%, %ErrorLevel%, %editCNN%, ahk_id %winID% ; EM_SETSEL to change caret to first character position of line 'lineSel'
}
|
_________________
 |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Mon Nov 30, 2009 12:50 am Post subject: |
|
|
This doesn't use SendMessage, but it works
| Code: | controlsend, Edit2, {home}{Down 3} ,test
|
|
|
| Back to top |
|
 |
mAdDoG
Joined: 29 Dec 2004 Posts: 75
|
Posted: Mon Nov 30, 2009 1:47 pm Post subject: |
|
|
Thanks alot everyone! _________________ -buttons, buttons,...
I like to push all the buttons!!! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|