I am writing a simple GUI application in Visual C++/Windows API. I have a Trackbar control on the dialogbox defined in resources as:
CONTROL "",IDC_SLIDER1045,"msctls_trackbar32",0x50010000,23,52,141,16,0x00000000
I want to show the trackbar value on static text control, so I wrote:
case WM_NOTIFY:
if(lParam == TRBN_THUMBPOSCHANGING)
{
Pos1 = SendMessage(GetDlgItem(hwndDlg, 1045), TBM_GETPOS, 0, 0);
wsprintf(szPos1, "Change IP address every %d minutes", Pos1);
SetDlgItemText(hwndDlg, 1044, szPos1);
}
break;
I tried also:
case WM_NOTIFY:
Pos1 = SendMessage(GetDlgItem(hwndDlg, 1045), TBM_GETPOS, 0, 0);
wsprintf(szPos1, "Change IP address every %d minutes", Pos1);
SetDlgItemText(hwndDlg, 1044, szPos1);
break;
Both codes doesn't work. First gives no action, second hangs the application.
My question is: How to get Trackbar value and show it on static text control in real time?