Thread: can't disable ctrl-V on a rich edit control

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    49

    can't disable ctrl-V on a rich edit control

    Hi there,

    I am trying to disble the Ctrl-V key function for a rich edit control. I set the ENM_KEYEVENTS event mask filter and I handle my WM_NOTIFY message as follows...

    Code:
    case WM_NOTIFY:
             switch( ((LPNMHDR)lParam)->code ){
    							
    		      case EN_MSGFILTER:
    				if( ((MSGFILTER*)lParam)->wParam == 0x0016 ){
                                        MessageBox( hwnd, "Ctrl-V", NULL, MB_OK );
    				    return 1; //disables the key
    			        } 
                           break;
              }
    break;

    This code fails to prevent the Ctrl-V button from pasting into the rich edit control. I know that the if statement is being executed because I get a message but I still get the text pasted into the rich edit control. What am I doing wrong?

  2. #2
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Try adding this code to your script.
    Code:
    WNDPROC DefEditProc;
    
    LRESULT EditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
       if(uMsg == WM_KEYDOWN)
       {
          if(wParam == 'V' && GetAsyncKeyState(VK_CONTROL))
             return 0;
       }
       return CallWindowProc(DefEditProc, hwnd, uMsg, wParam, lParam);
    }
    And use this right after creating the rich-edit.
    Code:
    DefEditProc = (WNDPROC)SetWindowLong(hRichEdit, GWL_WNDPROC, (long)SpreadEditProc);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing from a Rich Edit control
    By JustMax in forum Windows Programming
    Replies: 10
    Last Post: 02-14-2009, 07:12 PM
  2. Change cursor on single edit control
    By Niara in forum Windows Programming
    Replies: 3
    Last Post: 01-11-2009, 09:52 AM
  3. Dialog Edit Control and Enter Key
    By Quantrizi in forum Windows Programming
    Replies: 2
    Last Post: 04-14-2004, 07:59 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Rich edit control example Win API
    By Echidna in forum Windows Programming
    Replies: 1
    Last Post: 09-17-2001, 02:12 AM