-
July 21st, 2004, 07:33 AM
#1
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!
-
July 21st, 2004, 07:37 AM
#2
You could do:
SetDlgItemInt(IDC_COUNT, m_Count);
-
July 21st, 2004, 07:38 AM
#3
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);
-
July 21st, 2004, 10:46 AM
#4
Originally Posted by Alin
3.
Code:
m_Count = 100;
UpdateData(FALSE);
This one is the prefered one.
-
July 21st, 2004, 11:13 AM
#5
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).
-
July 21st, 2004, 08:55 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|