Reputation: 3582
I am attempting to write a very small graphical program for Windows in the Visual C++ using pure Windows API. Program consists of the one dialog with couple buttons and static text control. Dialog is initializaed from resource. What I need to do is when dialog initialized, static text is filled with some value, that is dynamicallt computed. I am stuck at his point, because I completely don't know how to change static text value on the dialog dynamically. Please advise. I assume that must be call to SetWindowText(), but the question is - how do I determine hWnd for the particular static text on the dialog?
Upvotes: 3
Views: 4217
Reputation: 37202
In your resource script the control would have a particular ID (e.g. IDC_STATIC
). The simplest way to change its text in that case is:
SetDlgItemText(hwndDlg, IDC_STATIC, L"the new text");
Alternatively, you can use GetDlgItem()
to get the handle to the control using its ID and then call SetWindowText()
.
Upvotes: 7