CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123

    Question Deselecting text in CEdit

    I have a dialog with a CEdit and a CSpinButtonCtrl.
    This is my code:
    void CInformDlg::OnDeltaposSpinLog(NMHDR* pNMHDR, LRESULT* pResult)
    {
    NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
    if (pNMUpDown->iDelta == -1) //Arriba
    m_strLog = sText1;
    else //Abajo
    m_strLog = sText2;
    m_editLog.SetSel(-1,-1);
    UpdateData (FALSE);
    *pResult = 0;
    }
    Where m_editLog is the edit and m_strLog is a CString variable associated with the edit. With this code, the text in CEdit is always selected, and I don't want this. What am I doing bad?
    Thank you in advance.
    I am Miss Maiden... Miss Iron Maiden :-D

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Update your edit control manually...
    Code:
    void CInformDlg::OnDeltaposSpinLog(NMHDR* pNMHDR, LRESULT* pResult)
    {
      NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
      if (pNMUpDown->iDelta == -1) //Arriba
        m_strLog = sText1;
      else //Abajo
        m_strLog = sText2;
    
      UpdateData (FALSE);
      m_editLog.SetSel(-1,-1);
      m_editLog.UpdateWindow();
      *pResult = 0;
    }

  3. #3
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123
    Thank you Andreas. With your code happens the same. When the text is changed in my edit box (with spin control), all text is selected.
    I am Miss Maiden... Miss Iron Maiden :-D

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