int firstButton = IDC_BUTTON1;
for(int i = firstButton; i < firstButton + 16; ++i)
{
CWnd *pB = GetDlgItem(i);
for(int j = 0; j < 16; ++j)
{
pB->SetWindowTextW((LPCTSTR)(szTest[j]));
}
}
I want to change button caption dynamically.
when in use SetWindowTextW with static text like "static txt" it works well,
but with char array (in this case szTest), the captions are'nt changed
Am i coded a wrong type casting?
The inner for loop in your code doesn't make sens to me. You probably want this:
char szTest[] = "0123456789ABCDEF" ;
int firstButton = IDC_BUTTON1;
for (int i = firstButton; i < firstButton + 16; ++i)
{
CWnd *pB = GetDlgItem(i);
CString str(szTest[i]) ;
pB->SetWindowText(str);
}
With that piece of code, the first button will contain "0", the second will contain "1" etc.
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