Thread: edit control???

  1. #1
    Brita
    Guest

    Unhappy edit control???

    1)in the edit box control... how can change colors of some words, and make some words bald... etc...

    like the IDE does for: reserved words.


    2) also, how do clear,cut,copy the content of the edit box?

    thank a milion guys.

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    1) You can't do that with an edit control, you'll have to either use a rich edit control or create your own control

    2)
    1. To clear the contents, you can either send SetWindowText with a pointer to a NULL, or select everything with EM_SETSEL then EM_REPLACESEL the selection with a pointer to a NULL (obviously use the first one).
    2. To cut, create a buffer that will persist beyond the termination of the current function, (ie, it should be part of the class you're using, or a global buffer), put the current selection in it by using EM_GETSELTEXT, then use EM_REPLACESEL with a pointer to a NULL.
    3. For copy, do the above except without the EM_REPLACESEL part.

    I hope that's clear enough, even though it's probably not, because it's late and I'm really drunk. Hee hee.

    EDIT: some crazy .......... I wrote and then edited out.
    Last edited by bennyandthejets; 01-20-2003 at 08:15 AM.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    fou
    Guest
    Hello,
    You can also use the clipboard.
    Code:
    	/* hEdit is the hwnd of the edit control */
    	case M_EDIT_UNDO:
    		SendMessage(hEdit,EM_UNDO,0,0);
    		break;
    
    	case M_EDIT_CUT:
    		SendMessage(hEdit,WM_CUT,0,0);
    		break;
    
    	case M_EDIT_COPY:
    		SendMessage(hEdit,WM_COPY,0,0);
    		break;
    
    	case M_EDIT_PASTE:
    		SendMessage(hEdit,WM_PASTE,0,0);
    		break;
    
    	case M_EDIT_DEL:
    		SendMessage(hEdit,WM_CLEAR,0,0);
    		break;
    
    	case M_EDIT_SELALL:
    		SendMessage(hEdit,EM_SETSEL,0,-1);
    		break;
    Have Fun!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I send a text string to an edit control
    By marc74 in forum Windows Programming
    Replies: 5
    Last Post: 01-06-2005, 10:14 PM
  2. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  3. Restricting input to an edit control
    By bennyandthejets in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2003, 01:10 AM
  4. endless edit control
    By ZerOrDie in forum Windows Programming
    Replies: 3
    Last Post: 03-21-2003, 02:51 AM
  5. Keeping focus on an edit control ...
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 02-19-2002, 02:12 AM