in reply to Cursor at end of Richedit control

From memory, try setting a null selection at the end of the text:

my $last = $win-> reReport-> TextLength(); $win-> reReport-> SetSel( $last, $last );

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Cursor at end of Richedit control
by briannz556 (Beadle) on Aug 18, 2007 at 12:58 UTC
    Hmmm, see what you are getting at but no joy.
    I'm using
    use Win32::GUI(); use Win32(); use Win32::GUI::Loft::Design(); use Cwd;
    but not even variations on the line $win-> reReport-> SetSel( $start, $finish ); places the cursor in the richedit control, nevermind at the end. Nor even highlights any of the text.

    Do I have to place the cursor in the control first and then position it at the end?

      Sorry, there may be a terminology misunderstanding here. When you said "position the cursor", I assumed you meant moce the insertion point for the edit control. Ie. Change the position where text would be inserted, if the user starts typing, assuming the control has focus.

      If that is what you want, you will probably have to call update() afterwards in order for the effects to be reflected on the screen.

      However, there are other possible interpretation of "position the cursor".

      You might mean: move the mouse cursor over the richedit control window.

      Or you might mean: Give the richedit control the focus, so that the text cursor (otherwise known as the insertion point), appears with the richedit control.

      So, 1) you are going to have to clarify your problem (and terminology).

      2) it would be much easier for people to assist you if you would post a minimal, working example of your code. It is always a good idea to have a small test app that omits the bulk of your program logic when learning a new library or control.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      I finally dug out the one use I made of a RichEdit control, and I forgot a bit.

      The final piece of the puzzle is that you need to scroll the window to make the appropriate part of the buffer visible:

      $win-> reReport-> SetSel( $re->TextLength, $re_>TextLength ); $win-> reReport-> Scroll( 'bottom' ); ## Now the selection is off the top $win-> reReport-> Scroll( -10 ); ## Adjust for the size of window ## and the size of the font.

      See also GetFirstVisibleLine() which can be useful if you are not moving all the way to one extremity or the other.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Sorry about being terse. On selecting an entry in a combobox called 'Parameter' I use the following code to populate a Richedit control:
        sub ::cbParameter_Change{defined(my $win = $Win32::GUI::Loft::window{H +allblacks} ) or return(1); my $fh; # general filehandle my $list = $win-> cbParameter-> GetLBText($win-> cbParameter-> Get +CurSel()); my $path = getdcwd()."\\Lists\\$list.txt"; if (!(-e $path)) { open($fh, ">$path"); close $fh; }; $win-> reReport-> Load($path, 1); }
        and I now wish - using your terminology - to "Give the richedit control the focus, so that the text cursor (otherwise known as the insertion point), appears with the richedit control" AND at the end of it. Hope that helps?