I have a RichEdit which has 4,000 lines. I can't seem to find the command to reset it to show starting at the 1st line.
I hope this is simple, since I have looked thru all my programs and the forum, but have had no luck finding what I need to do.
Thanks,
Bill
Can't you use SetScrollPos?
Although Microsoft are now saying you should use SetScrollInfo
Brian
SetScrollInfo is supposedly the standard way to do it but didn't work for me. The code below seems to work, I just got there by trial and error
ScrollRichEditToTop(w1.hwnd, RICHEDIT_1)
SUB ScrollRichEditToTop(INT handle, INT id)
_SendMessage(GetDlgItem(handle, id), WM_VSCROLL , MAKELPARAM(SB_TOP, 0), 0) ' scroll position
_SetFocus(GetDlgItem(handle, id)) ' focus
_SendMessage(GetDlgItem(handle, id), EM_SETSEL , 0, 0) ' caret position
ENDSUB
Edit. Don't forget $INCLUDE "windowssdk.inc"
Fasecero, I tried your code and it didn't work for me.
Will look into SetScrollPos and SetScrollInfo.
Bill
Tried SetScrollInfo and SetScrollPos, neither seemed to work or I don't have the right parameters.
Tried: SETSCROLLPOS w1,EDIT,-500
WINDOW w1, EDIT is a RICHEDIT, thought it might move 500 lines up.
Tried: SetScrollInfo(EDIT,SB_VERT,0,TRUE)
Hoping that the 0 would move it ot the top of the richedit.
Obviously no idea what I am doing.
Thanks,
Bill
Found this:
http://www.ionicwind.com/forums/index.php?topic=6240.msg45804#msg45804
From h3kt0r:
Sub Edit_Scroll_2bottom()
lcount = CONTROLCMD ( MyDlg, EDIT_1, @EDGETLINECOUNT)
SendMessage(MyDlg, EM_LINESCROLL, 0, lcount, EDIT_1)
return
EndSub
Sub Edit_Scroll_2Top()
Int top
lcount = CONTROLCMD ( MyDlg, EDIT_1, @EDGETLINECOUNT)
top = lcount - 1
SendMessage(MyDlg, EM_LINESCROLL, 0, -top, EDIT_1)
return
EndSub
Works on EDIT and RICHEDIT controls. At least it works on my code.
Bill
try this
ret = CONTROLCMD(win,EDIT, @RTGETFIRSTLINE)
CONTROLCMD win,EDIT, @RTSCROLL, 0, 0 - ret
Larry, that worked too.
Thanks,
Bill