CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Location
    Vienna, Austria
    Posts
    47

    Undo without Redo (CRichEditCtrl)

    Hi !

    When I call CRichEditCtrl's Undo() method; my last change is undone and I get the chance to "Redo" that modification.

    Does anybody know, how to prevent from "Redo" ?

    In other words: I (my programm) want to make an Undo without giving the user the possibility to "Redo"

    Thanx

  2. #2
    Join Date
    May 2001
    Posts
    112
    Here's a few ideas depending on how your program works. If you want to disable Redo from the menu then create an update handler for it so it's never enabled. If you want to disable the Ctrl-Y redo key combination then catch that key combination and don't send it along. Some people don't agree but I do this in PretranslateMessage. Here's an example:

    BOOL CSourceRichEditView::PreTranslateMessage(MSG* pMsg)
    {
    // TODO: Add your specialized code here and/or call the base class
    BOOL bCtrl = (GetKeyState(VK_CONTROL) & 0x8000);
    BOOL bShift = (GetKeyState(VK_SHIFT) & 0x8000);

    if (pMsg->message == WM_KEYDOWN && bCtrl)
    {
    if (bShift)
    {
    switch ((int)pMsg->wParam)
    {
    case 74:// VK_J + SHIFT Left justified
    case 76:// VK_L + SHIFT Toggels through list types
    case 77:// VK_M + SHIFT Tab I think
    case 187:// +/= + SHIFT Superscript Toggle
    case VK_BACK:// + SHIFT Deletes text until start of word
    return TRUE;
    }
    }
    }

    return CRichEditView::PreTranslateMessage(pMsg);
    }


    This should be about the same for a CRichEditCtrl.

    I hope this helps.
    -Ben

  3. #3
    Join Date
    Jun 2002
    Location
    Vienna, Austria
    Posts
    47
    Good idea, but I only want to prevent from one single, specific Redo (the one, I generate myself by calling Undo())

  4. #4
    Join Date
    May 2001
    Posts
    112
    What about creating a boolean member variable that you set to TRUE when you do the undo. It would be set to FALSE when any other change is made to the CRichEditCtrl. That way the redo is only enabled when the boolean is FALSE. I don't know that you could cover all the ways that a user could make a change though. That's about all I can think of. Hopefully someone else out there has an idea that would work. Good Luck.

    -Ben

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