0

I need to display text along with values of variables in a CEdit controlled Edit Control Box. How do I do it ? Currently I'm using SetWindowText(), but that only takes a string...how do I get a formatted string to display in the edit control?

Example: printf("The answer is %d\n",ans) -> how do i print the same message in a Edit Control?

TCSGrad
  • 11,898
  • 14
  • 49
  • 70

1 Answers1

4

Use CString's Format member.

CString text;
text.Format(_T("The answer is %d\n"), ans);
edit.SetWindowText(text);
Nikola Smiljanić
  • 26,745
  • 6
  • 48
  • 60
  • and/or you could derive you own class from CEdit and add a method to do that in one call. M. – Max Mar 22 '10 at 13:05