CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2002
    Posts
    18

    How to display a number in edit box with GetDlgItem?

    I have a dialog: dlg,
    IDC_CONTENT: a edit box control of dlg
    CString m_strContent : variable of IDC_CONTENT control

    i can show text with this fuction: (instead i use UpdateData(0) )
    dlg->GetDlgItem(IDC_CONTENT)->SetWindowText(m_strContent);

    i have a edit box: IDC_COUNT with variable m_Count (integer)

    How can I show number control of IDC_COUNT?

    dlg->GetDlgItem(IDC_COUNT)->???

    I don't understand this point

    help me pls!
    Thanks!

  2. #2
    Join Date
    Jul 2004
    Posts
    9
    You could do:
    SetDlgItemInt(IDC_COUNT, m_Count);

  3. #3
    Join Date
    Feb 2002
    Posts
    3,788
    Quote Originally Posted by lad
    I have a dialog: dlg,
    IDC_CONTENT: a edit box control of dlg
    CString m_strContent : variable of IDC_CONTENT control

    i can show text with this fuction: (instead i use UpdateData(0) )
    dlg->GetDlgItem(IDC_CONTENT)->SetWindowText(m_strContent);

    i have a edit box: IDC_COUNT with variable m_Count (integer)

    How can I show number control of IDC_COUNT?

    dlg->GetDlgItem(IDC_COUNT)->???

    I don't understand this point

    help me pls!
    Thanks!
    1.
    Code:
    CString strNumber;
    strNumber.Format("%d", m_Count);
    dlg->GetDlgItem(IDC_COUNT)->SetWindowText(strNumber);
    2.
    Code:
    SetDlgItemInt(IDC_COUNT,  m_Count, FALSE);
    3.
    Code:
    m_Count = 100;
    UpdateData(FALSE);

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150
    Quote Originally Posted by Alin
    3.
    Code:
    m_Count = 100;
    UpdateData(FALSE);
    This one is the prefered one.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360
    The safe method would be:
    Code:
    UpdateData(TRUE);
    m_Count = 100;
    UpdateData(FALSE);
    In case you have more such controls, and want to preserve the others from side effects that might appear(say I have n_Count1 and n_Count2. I can modify anyone of them by typing values, but when I press a button n_Count1 is to be reset to 0, while n_Count2 remains unchanged. Without the first call to UpdataData the edit number would be set to the last "saved" n_Count2).
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  6. #6
    Join Date
    Mar 2002
    Posts
    18
    Because I have a loop (while) and I want display data immediatly in each loop, then using UpdateData() can't do this work.

    I used your method:
    dlg->SetDlgItemInt(IDC_COUNT, count)
    and dlg->SetDlgItemInt(IDC_COUNT, count,FALSE)

    two work greatly!

    thanks alot!

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