Original Post
Did anybody ever have this problem... (by the way, I'm using c++) You have a vertical or horizontal scrollbar. Let's use a horizontal one for this example. If the SCROLLINFO.nPos member is at 0 (thumb is all the way at the left), and you click on the left arrow, the thumb shoots to the right. That happened to me with this code... Anyone have an idea? It wasn't messing up before but I had to delete all the code here to integrate it into my Map Editor Engine.
LRESULT CALLBACK cEditor::prTileHandler(HWND hTileWnd, UINT msg, WPARAM wParam,
LPARAM lParam){
// Scrolling information
SCROLLINFO si;
BITMAP bm;
RECT rcTileWnd;
static short sXTilePos;
switch(msg){
// Called when Tile Selector window is resized
case WM_SIZE:
GetObject(tlSelectedSet.hTileset, sizeof(bm), &bm); // Just retrieves dimensions of current tileset for scrolling
GetClientRect(hTileWnd, &rcTileWnd);
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
si.nMin = 0;
si.nPage = rcTileWnd.right;
si.nMax = bm.bmWidth - 1;
si.nPos = sXTilePos;
SetScrollInfo(hTileWnd, SB_HORZ, &si, TRUE);
// WM_SIZE message handled, return 0;
return 0;
// Called when the Tile Selector window is scrolled horizontally
case WM_HSCROLL:
GetScrollInfo(hTileWnd, SB_HORZ, &si);
{
switch(LOWORD(wParam)){
case SB_LINELEFT:
si.nPos -= 1;
break;
case SB_LINERIGHT:
si.nPos += 1;
break;
case SB_THUMBTRACK:
si.nPos = HIWORD(wParam); // Oh and this doesn't work either
break;
}
si.fMask = SIF_POS;
SetScrollInfo(hTileWnd, SB_HORZ, &si, TRUE);
}
// WM_HSCROLL message handled, return 0
return 0;
// ... rest of messages
}
}