July 17, 2024, 09:02:53 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Reset RichEdit to top

Started by billhsln, November 13, 2019, 11:49:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

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
When all else fails, get a bigger hammer.

Brian

Can't you use SetScrollPos?

Although Microsoft are now saying you should use SetScrollInfo

Brian

fasecero

November 14, 2019, 05:31:10 AM #2 Last Edit: November 14, 2019, 05:35:25 AM by fasecero
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"

billhsln

Fasecero, I tried your code and it didn't work for me.

Will look into SetScrollPos and SetScrollInfo.

Bill
When all else fails, get a bigger hammer.

billhsln

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
When all else fails, get a bigger hammer.

billhsln

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
When all else fails, get a bigger hammer.

LarryMc

try this
ret = CONTROLCMD(win,EDIT, @RTGETFIRSTLINE)
CONTROLCMD win,EDIT, @RTSCROLL, 0, 0 - ret
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

Larry, that worked too.

Thanks,
Bill
When all else fails, get a bigger hammer.