// IDC_SLIDER1 and IDC_SLIDER2 are trackbars created in
// the resource editor.
void LabelTrackbarsWithBuddies(HWND hDlg)
{
const int staticWidth = 50;
const int staticHeight = 20;
// Get horizontal trackbar.
HWND hwndTrackbar = GetDlgItem(hDlg, IDC_SLIDER1);
// Create buddies.
HWND hwndBuddy = CreateWindowEx(0, L"STATIC", L"Left",
SS_RIGHT | WS_CHILD | WS_VISIBLE,
0, 0,
staticWidth, staticHeight,
hDlg, NULL, g_hInst, NULL);
SendMessage(hwndTrackbar, TBM_SETBUDDY,
(WPARAM)TRUE, (LPARAM)hwndBuddy);
hwndBuddy = CreateWindowEx(0, L"STATIC", L"Right",
SS_LEFT | WS_CHILD | WS_VISIBLE,
0, 0,
staticWidth, staticHeight,
hDlg, NULL, g_hInst, NULL);
SendMessage(hwndTrackbar, TBM_SETBUDDY,
(WPARAM)FALSE, (LPARAM)hwndBuddy);
// Get vertical trackbar.
hwndTrackbar = GetDlgItem(hDlg, IDC_SLIDER2);
// Create buddies.
hwndBuddy = CreateWindowEx(0, L"STATIC", L"Top",
SS_CENTER | WS_CHILD | WS_VISIBLE,
0, 0,
staticWidth, staticHeight,
hDlg, NULL, g_hInst, NULL);
SendMessage(hwndTrackbar, TBM_SETBUDDY,
(WPARAM)TRUE, (LPARAM)hwndBuddy);
hwndBuddy = CreateWindowEx(0, L"STATIC", L"Bottom",
SS_CENTER | WS_CHILD | WS_VISIBLE,
0, 0,
staticWidth, staticHeight,
hDlg, NULL, g_hInst, NULL);
SendMessage(hwndTrackbar, TBM_SETBUDDY,
(WPARAM)FALSE, (LPARAM)hwndBuddy);
}