AutoHotkey Community

It is currently May 27th, 2012, 2:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: November 29th, 2009, 10:48 pm 
Offline

Joined: December 29th, 2004, 8:22 pm
Posts: 75
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!!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 12:54 am 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
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

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 1:07 am 
Offline

Joined: December 29th, 2004, 8:22 pm
Posts: 75
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!!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 1:34 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
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'
}

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 1:50 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
This doesn't use SendMessage, but it works

Code:
controlsend, Edit2, {home}{Down 3} ,test


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 2:47 pm 
Offline

Joined: December 29th, 2004, 8:22 pm
Posts: 75
Thanks alot everyone!

_________________
-buttons, buttons,...
I like to push all the buttons!!!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], rbrtryn and 31 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group