Code:
static int xClient, yClient, Column, IconsNo, CurrentPos;
case WM_SIZE:
IconsNo = 13;
Column = IconsNo / 4 + 1; // if possible correct this formula
xClient = LOWORD (lParam) ;
yClient = HIWORD (lParam) ; // this is what we wan
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE;
si.nPage = yClient; // page/viewing size is Y coord, Reasonable rite
si.nMin = 0;
si.nMax = Column * 150 + 10 - yClient;
SetScrollInfo(hwnd,SB_VERT,&si,TRUE);
case WM_PAINT:
HDC hdc;
hdc = BeginPaint(hwnd,&ps);
HBITMAP test;
test = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_NOTE));
int x,y,i;
x = 10; y = 10; // starting coordinates
i = 0;
// Displaying the Icons onto the client area
while(i<IconsNo)
{
if ( x > 265 )
{
x = 10;
y = y + 90;
bMp->Draw(test,hdc,1,x,y,0,0);
}
bMp->Draw(test,hdc,1,x,y,0,0);
x = x + 85;
i++;
}
if (Scroll )
{
HDC TempHDC;
TempHDC = CreateCompatibleDC(hdc);
SelectObject(TempHDC,test);
// i did this SelectObject to show if scrolling worked
// but this bitmap will only appear if i did an extreme
// thumb position from down to up, other than it wun even appear
BitBlt(ps.hdc,ps.rcPaint.left,ps.rcPaint.top,
ps.rcPaint.right - ps.rcPaint.left,
ps.rcPaint.bottom - ps.rcPaint.top,
TempHDC,
ps.rcPaint.left + 0,
ps.rcPaint.top + CurrentPos,SRCCOPY);
Scroll = FALSE;
}
EndPaint(hwnd,&ps);
DeleteObject(test);
break;
case WM_VSCROLL:
// coding this scroll bar is making my hair drop !
int YnewPos,MovedAmt;
si.cbSize = sizeof (si); // impt
si.fMask = SIF_ALL; // impt
GetScrollInfo(hwnd,SB_VERT,&si);
YnewPos = si.nPos;
switch(LOWORD(wParam))
{
case SB_LINEDOWN:
si.nPos +=5;
break;
case SB_PAGEDOWN:
si.nPos += 20;
break;
case SB_THUMBPOSITION:
si.nPos = si.nTrackPos;
break;
case SB_PAGEUP:
si.nPos -= 20;
break;
case SB_LINEUP:
si.nPos -=5;
break;
}
if ( si.nPos != YnewPos )
{
SetScrollInfo(hwnd,SB_VERT,&si,TRUE); // impt
GetScrollInfo(hwnd,SB_VERT,&si); // impt
Scroll = TRUE; // flag to inform WM_PAINT abt new job
MovedAmt = YnewPos - si.nPos; // determine scroll moved amt
ScrollWindowEx(hwnd,0,MovedAmt,NULL,NULL,NULL,NULL,SW_INVALIDATE);
UpdateWindow(hwnd); // push WM_PAINT now
}
break;
everithing abt the scrollbar is fine now, all i need is that it display the correct amount of icons being hidden below or above. This is what im stucked with.