-
changing static text
Hi,
I'm a newbie to win32 c and I'm still getting to used to a lot of things. I was wondering whether there is a way to change the contents of static text controls during runtime on a DialogBox loaded from the resources rather than using a window class etc.
I tried thinking that maybe you use SetWindowText or SetDlgItemText but i don't know how to find out the hwnd of the static text and it doesn't seem to have an indentifier like IDOK or whatever. I know you can use SetWindowText if you make the static text using CreateWindow as it returns the hwnd of it but i don't know how to change ones which have been drawn on the dialog at design time.
I used to use vb which is probably why I'm approaching it in this way, if I'm totally looking in the wrong direction then please correct me!
Thanks,
Daniel Briley
-
Open up your resource script, either using a GUI editor if you have one, or in a text editor if you don't. Find the static control you wish to modify the text of and give it an id which you should give a numeric value (ie #define it) in your resource header.
Now that the static control has a unique id you can use GetDlgItem to get the handle of the control for use with SetWindowText or just use SetDlgItemText.
eg in resource header:
Code:
#define IDC_MY_STATIC_CNTRL 500
and then in the resource script:
Code:
LTEXT "original static cntrl text", IDC_MY_STATIC_CNTRL, 0, 0, 200, 15
Hope that helps.
-
Thanks for that, works exactly as i needed it too :-D
greatly appreciated