to let it work with both mouse and keyboard, move the previous code from SetThumbLocation to GetThumbTrackLocation like this
void GetThumbTrackLocation(IN HWND hWnd, OUT long &tx, OUT long &ty) {
RECT rc = {0}; float sIncrement = 0.0f; long imgW = 0, imgH = 0, tMin = 0, tMax = 0, tVal = 0, nRange = 0, nWidth = 0, nHeight = 0;
skGetBitmapSize(g_BtnTrack, imgW, imgH);
imgW = imgW / 2;
tMin = (long) SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
tMax = (long) SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
tVal = (long) SendMessage(hWnd, TBM_GETPOS, 0, 0);
GetClientRect(hWnd, &rc); nWidth = rc.right; nHeight = rc.bottom;
if (TrackOrientation(hWnd) == TRACK_HORZ) {
ty = (nHeight - imgW) / 2; if ((nHeight % 2) == 0) { ty += (imgH % 2); }
nRange = nWidth - imgW;
sIncrement = (float)((float)(tMax - tMin) / (float) nRange);
if (sIncrement == 0) { tx = 0; } else { tx = (long)((float)(tVal - tMin) / (float)sIncrement); }
} else {
tx = (nWidth - imgW) / 2; if ((nWidth % 2) == 0) { tx += (imgW % 2); }
nRange = nHeight - imgH;
sIncrement = (float)(tMax - tMin) / (float)nRange;
if (sIncrement == 0) { ty = 0; } else { ty = (long) ((float)(tVal - tMin) / (float)sIncrement); }
}
if (CheckWindowStyle(hWnd, TBS_TOOLTIPS)) { skSetToolTipText(hWnd, STRL(tVal)); }
}
I shall use #define TBS_CUSTOMTIPS 0x10000000, and offer a new API much easier to deal with, than the convoluted WM_NOTIFY/TTN_NEEDTEXT