endless edit control

This is a discussion on endless edit control within the Windows Programming forums, part of the Platform Specific Boards category; 1).well as the topic says im trying to create an edit control where when the edit box reaches a length ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    254

    endless edit control

    1).well as the topic says im trying to create an edit control where when the edit box reaches a length of 50 lines it removes the top line and shifts the text up and therefore always has 50 lines in it

    Code:
    int boxlength=SendMessage(hedit,EM_GETLINECOUNT,0,0);
    	int linelength=SendMessage(hedit,EM_LINELENGTH,0,0);	
    	if(boxlength>49)
    	{
    		SendMessage (hedit, EM_SETSEL, 0, linelength);//select all of the first line
    		SendMessage (hedit, EM_REPLACESEL, 0, (LPARAM) ((LPSTR) ""));//replace with nothing so i can move this line up
    	}
    	int ndx = GetWindowTextLength (hedit);
    	message+="\r\n";	
    	SendMessage (hedit, EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx);
    	SendMessage (hedit, EM_REPLACESEL, 0, (LPARAM) ((LPSTR) message.c_str()));
    any ideas or suggestions? i think i may be going about this a little backwards... im guessing that by replacing the top line with a "" i can clear the \r\n so it will move... up i seem to be having some trouble doing this

    2). how would i go about having a data entry box that clears after each enter? is this a special type of control or do i have to check my input and if i get a return clear the edit control?

    i await your help and insight
    Last edited by ZerOrDie; 03-20-2003 at 12:05 AM.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    1. See if the attached helps you...
    2. You can subclass the edit control to catch the return then use SetWindowText() to blank the control.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    254
    the attached?

    i manadged to implement the subclass though and its working well
    Last edited by ZerOrDie; 03-20-2003 at 09:17 PM.

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Don't you just hate that when that happens!
    Attached Files Attached Files
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. edit control text buffer
    By scurvydog in forum Windows Programming
    Replies: 4
    Last Post: 12-11-2008, 10:13 AM
  2. 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
  3. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 10:52 PM
  4. Restricting input to an edit control
    By bennyandthejets in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2003, 02:10 AM
  5. Keeping focus on an edit control ...
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 02-19-2002, 02:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21