Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: RichEdit AutoScroll?

  1. #1

    RichEdit AutoScroll?

    Hi Eros,

    I found these snippets doing a search about 'richedit scrolling' on Powerbasic forums:


    -----------------------
    When the RichText box is filled, I want it to
    automatically scroll so that the last line entered into it is
    always visible rather than the first line of text entered (in
    other words, I want the box to auto-scroll to the bottom).

    I have no doubt there's a faily easy way to do this but my head
    hurts from beating it against the wall to find it. Any
    assistance would be VERY greatly appreciated.

    ----------------------

    The easy way is by using EM_REPLACESEL to set text. Works like paste - RichEdit
    will scroll to end of inserted text. Can use EM_EXSETSEL to control position
    and if something should be replaced. But if text only is added to end, no need
    to do anything, since input pos then always will be at the end with this message.

    And in case you didn't know: to avoid auto-selection of all when RichEdit gets
    focus one can simply include %ES_SAVESEL style at creation.

    ---------------------------

    Thanks much for pointing me in the right direction
    ***** %EM_SCROLLCARET solved the problem. *****

    ------------------------------

    ' replace selected text with result string
    CONTROL SEND CBHNDL, %txt_richedit, %EM_REPLACESEL, 1, STRPTR( pString )

    ' scroll to the carrot cursor
    CONTROL SEND CBHNDL, %txt_richedit, %EM_SCROLLCARET, 0, 0

    ------------------------------

    Try EM_SETSEL to place the cursor at the end of the contents of the edit control, followed by a EM_SCROLLCARET to bring the cursor into view.
    -------------------------------

    Maybe this info will provide a solution, Eros??
    %EM_REPLACESEL with %EM_SCROLLCARET
    What do you think? I dunno how to write these in thinBASIC.

    Regards,
    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732

    RichEdit AutoScroll?

    Hi Catventure,

    If you need the value of equates, here they are ( just paste into code ):
    [code=thinbasic]
    %EM_REPLACESEL = &HC2
    %EM_SCROLLCARET = &HB7
    [/code]

    I'm now on computer with no thinBASIC installed, so I can't help you more at this time


    Psch
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3

    RichEdit AutoScroll?

    Thanks , Psch.

    Don't know how useful they will be..

    Today, I tried to do the scrolling using the eventmask (as in richedit example) to capture changes in richedit via window handler and tried to manipulate scrolling from there using %em_scrollcaret and others - but didn't work

    Anyone else got any good ideas?
    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732

    RichEdit AutoScroll?

    Hi Catventure,

    I'v got solution !
    Replace "ShowText" function in your T.A.B. project with this one:

    [code=thinbasic]
    function showtext() as long
    dim a as string

    control append text hwnd,%id_RICHEDIT2,sprint

    control get text hwnd,%id_RICHEDIT2 to a
    CONTROL SEND hwnd, %id_RICHEDIT2, %EM_SETSEL , len(a),len(a)
    CONTROL SEND hwnd, %id_RICHEDIT2, %EM_SCROLLCARET, 0, 0
    end function

    [/code]

    It really works, at least on WinME. Hope on your box too.
    Let me know !

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #5

    RichEdit AutoScroll?

    Hi Psch,

    Well done, Psch.
    Yes that code *should* work. I have seen it as a poss solution on other forums so believe it will work.
    But it does NOT on my Win98

    I've tried it with control post, control send and sendmessage. It will not scroll. I also tried other similar ways earlier today and yesterday.

    What richedit dll is being used by you?

    Mine is using riched32.dll (which is actually version 2 of microsoft richedit)
    but I also have riched20.dll (which despite its number is actually version 3!)

    If I could get it to use riched20.dll maybe your fantastic solution will work for me??

    Maybe there's a way in Tb that will allow me to use this later riched library?

    Many thanks,
    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  6. #6

    RichEdit AutoScroll?

    Hi,

    Well it appears that riched32.dll is just a stub for loading riched20.dll - so it IS using that dll! Maybe its a Win98 problem as Eros thought? I did it using IBasic (and that must have used the same dll? )so maybe it will still be possible...

    How I wish that microsoft had come up with a more standardised and compatible control.

    catventure
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732

    RichEdit AutoScroll?

    Hi Catventure,

    Yes I have mayor version of RichEd20.DLL - version 3.
    But I agree it must be possible to do it other way, for example
    if it works in thinAIR on your box ( during search ), then there must be a way.

    Maybe there is technique to send PageDown press to the richedit ?
    I'v seen "SendKeys" function in thinBASIC help file, but I'm not sure how it works


    Psch
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  8. #8

    RichEdit AutoScroll?

    Hi Psch,

    I think we both have same dll.

    Now I have tried below code and it sort of works except when TAB has finished outputting text I have to "click" (not scroll at all) on the vert scrollbar and the text appears and looks to have scrolled properly....! I am not 'moving' the scrollbar but merely clicking it and presto text appears! The question is how to make it do it without clicking scrollbar???
    Can you please try and let me know?

    '---rem define these at top of program
    %SB_BOTTOM=7
    %SB_PAGEUP=2


    [code=thinbasic]
    function showtext() as long

    control append text hwnd,%ID_RICHEDIT2,sprint

    control send hwnd,%ID_RICHEDIT2,%EM_linescroll,0,%SB_bottom

    control send hwnd,%ID_RICHEDIT2,%EM_linescroll,0,%SB_pageup

    end function
    [/code]


    If you can help at all please reply. I need a break from it for time being.


    Best wishes,
    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,779
    Rep Power
    10

    RichEdit AutoScroll?

    Catventure,

    I've tested again Petr suggestion under WIN98 and it should work. The only difference is that in my testing WIN98 machine I've IE 6.x version installed while you have an early version and this can make the difference.

    Anyhow, on my WIN98 box this function seems to do the job:
    [code=thinbasic] function ShowText() as long
    dim sBuffer as string

    control append text hwnd, %id_RICHEDIT2, sprint

    '---Scroll RichEdit at its bottom
    '---Get the full richedit text buffer
    control get text hwnd, %id_RICHEDIT2 to sBuffer

    '---Select the last char of the buffer. wParam is starting point, lParam is ending point
    CONTROL SEND hwnd, %id_RICHEDIT2, %EM_SETSEL , len(sBuffer ), len(sBuffer )

    '---Tell edit control to scroll at the caret position
    CONTROL SEND hwnd, %id_RICHEDIT2, %EM_SCROLLCARET, 0, 0

    end function[/code]

    Please try again and let me know.
    Do you have the option to try TAB under a different machine with WIN98?
    Also, if you do not have already installed, please install thinBasic preview version 1.0.9.0

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  10. #10
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732

    RichEdit AutoScroll?

    Hi Eros,

    just a little correction in your example:

    [code=thinbasic]
    CONTROL SEND hwnd, %id_RICHEDIT2, %EM_SETSEL , len(a), len(a)
    [/code]

    ... should be replaced with ...

    [code=thinbasic]
    CONTROL SEND hwnd, %id_RICHEDIT2, %EM_SETSEL , len(sBuffer), len(sBuffer)
    [/code]

    It's just little detail. I hope I could perform some tests on brothers computer with Win98 FE ( first edition )

    Bye,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Page 1 of 2 12 LastLast

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •