IonicWind Software

IWBasic => GUI Central => Topic started by: billhsln on November 13, 2019, 11:49:19 PM

Title: Reset RichEdit to top
Post by: billhsln on November 13, 2019, 11:49:19 PM
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
Title: Re: Reset RichEdit to top
Post by: Brian on November 14, 2019, 04:10:39 AM
Can't you use SetScrollPos?

Although Microsoft are now saying you should use SetScrollInfo

Brian
Title: Re: Reset RichEdit to top
Post by: fasecero on November 14, 2019, 05:31:10 AM
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"
Title: Re: Reset RichEdit to top
Post by: billhsln on November 14, 2019, 09:47:33 AM
Fasecero, I tried your code and it didn't work for me.

Will look into SetScrollPos and SetScrollInfo.

Bill
Title: Re: Reset RichEdit to top
Post by: billhsln on November 14, 2019, 10:24:14 AM
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
Title: Re: Reset RichEdit to top
Post by: billhsln on November 14, 2019, 11:03:14 AM
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
Title: Re: Reset RichEdit to top
Post by: LarryMc on November 14, 2019, 11:06:51 AM
try this
ret = CONTROLCMD(win,EDIT, @RTGETFIRSTLINE)
CONTROLCMD win,EDIT, @RTSCROLL, 0, 0 - ret
Title: Re: Reset RichEdit to top
Post by: billhsln on November 14, 2019, 11:57:52 AM
Larry, that worked too.

Thanks,
Bill