CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 1999
    Location
    CA,USA
    Posts
    22

    Rich Edit text always selected when page becomes active

    I have a Property Sheet that contains four instances of a Property Page - which has a RichEdit Control, PushButton (Save) and a checkbox.

    Problem is, whenever any Property Page is displayed, all of the text in the Richedit Control is always selected.

    In the RichEdit control, I did not set NoHide. Nor do I call SetOptions() or HideSelection() within the code.

    (Actually, I tried calling HideSelection() but it had no effect).

    I also reset the selection by calling SetSel(0,1) at every possible place e.g. OnInitDialog(), OnSetActive().

    So, is there a way to prevent the text in the control from always being Selected when the Page becomes Active?

    Thanks,

    Bryan.





  2. #2
    Join Date
    Oct 1999
    Location
    Broomfield, CO
    Posts
    3,382

    Re: Rich Edit text always selected when page becomes active

    I suspect that the rich edit control is first in the tab order, which is causing this behavior.

    Create an OnSetFocus() handler for the control, and in that handler, use SetSel(-1,0).


  3. #3
    Join Date
    Oct 1999
    Location
    CA,USA
    Posts
    22

    Re: Rich Edit text always selected when page becomes active

    Nope, that didn't get it.

    I already had a handler for SetFocus, but changed the SetSel to (-1, 0) as you suggested.

    I also added another Page ahead of the ones with RichEdit, but all of the RichEdit pages still have all of their text selected every time they become active.

    Thanks,

    Bryan.



  4. #4
    Join Date
    Oct 1999
    Location
    CA,USA
    Posts
    22

    Re: Rich Edit text always selected when page becomes active

    FYI...

    The answer lies in the Paint handler, for some reason when it is entered the RichEditCtrl is always set to select all of the text.

    By resetting the selection in OnPaint, it will always come up as not-selected.

    Thanks,
    Bryan.



Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured