Thread: Rich Edit

  1. #1
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346

    Rich Edit

    I have a few questions about using the rich edit control. I want the user to have the option of a word wrap mode. If word wrap is on I have been declaring the window without WS_HSCROLL and ES_AUTOHSCROLL. Is there a way to change the style after the window has been created? This way I can add or get rid of these styles as the word wrap option changes.

    I want to create a right click popup menu. I was thinking of subclassing the rich edit control, but I am not sure if this is the right way to go. If I do subclass, does the richedit recieve the WM_RBUTTONUP message? I tried this but it did not seem to work.

    Thanks

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  2. #2
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856

    Lightbulb

    As far as changing the word wrap stuff. That is quite simple, actually. It took me a bit of searching some months back and discovered that the m_nWordWrap member of a CRichEditView has 3 possible values:
    Code:
      WrapNone, WrapToWindow, WrapToTargetDevice
    Set the member variable m_nWordWrap to the new value then call:
    Code:
      WrapChanged();
    As far as the right click context menu, check out this function:
    Code:
      virtual HMENU GetContextMenu(WORD seltype, LPOLEOBJECT lpoleobj,CHARRANGE* lpchrg);
    Here is an example of this function overridden:
    Code:
    HMENU CLogViewView::GetContextMenu(WORD seltype, LPOLEOBJECT lpoleobj,CHARRANGE* lpchrg)
    {
      CRichEditCntrItem* pItem = GetSelectedItem();
      if (pItem == NULL || !pItem->IsInPlaceActive())
      {
        CMenu menuText;
        menuText.LoadMenu(IDR_EDIT_MENU);
        CMenu* pMenuPopup = menuText.GetSubMenu(0);
        menuText.RemoveMenu(0, MF_BYPOSITION);
        return pMenuPopup->Detach();
      }
      return NULL;
    }
    However, I just realized this is for a CRichEditView, but not a ctrl. Well, hope it helps somewhat.

    *LuckY*

  3. #3
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    Thanks for the reply. I forgot to tell you that I am using C and WinAPI. Thanks anyway. Does anyone else know how to do these things?

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. line number on a rich edit control
    By rakan in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2008, 07:58 AM
  2. rich edit 4.1 is giving me a head-ache
    By master5001 in forum Windows Programming
    Replies: 3
    Last Post: 07-01-2005, 01:21 PM
  3. How the rich get rich [Long]
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 05-05-2005, 10:36 PM
  4. newbie to rich edit, cant get it to work
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 03-24-2004, 10:54 PM
  5. Rich edit
    By Garfield in forum Windows Programming
    Replies: 10
    Last Post: 07-10-2002, 04:08 PM