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?
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().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With