Thread: MFC CEdit: Could please somebody explain this ?

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    47

    Question MFC CEdit: Could please somebody explain this ?

    Hi all!

    while learing to code a CEdit box i encouterd something that i don't understand.

    The below code 1st pre-clears a string using ZeroMemory function.
    The TRACE statement always gives CEDITN: 0 in the debug
    window.

    When commenting out ZeroMemory then CEDITN returns
    suddenly the ammout of characters typed in.


    Code:
    /////////////////////////////////////////////////////////////////////////////
    // CDlgNewString
    
    void CDlgNewString::OnChangeEditNewString() 
    {
    	ZeroMemory(&m_cNewString[0], 14);
    
    	CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT_NEWSTRING);
    
    	int n = pEdit->GetLine (0, &m_cNewString[0]);
    	TRACE("CEDITN: %ld\n", n);
    
    	if (!n)
    		GetDlgItem(IDOK)->EnableWindow(false);
    
    	else
    		GetDlgItem(IDOK)->EnableWindow(true);
    }
    Can somebody please tell, why ZeroMemory influences a CEdit Control ??

    Regards,
    Robert

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Read the reference for CEdit::GetLine()
    Notice the lpszBuffer parameter.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  2. MFC Inclusion of Derived CEdit class
    By Dual-Catfish in forum Windows Programming
    Replies: 3
    Last Post: 05-19-2002, 08:57 AM
  3. Release MFC Programs & Dynamic MFC DLL :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-18-2002, 06:42 PM
  4. Focusing a CEdit Object in a Dialog On Startup :: MFC
    By kuphryn in forum Windows Programming
    Replies: 4
    Last Post: 04-21-2002, 02:39 AM
  5. Accessing CEdit Member Functions Inside CEditView ::MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 04-10-2002, 08:52 PM