Guys i need help with my scroll bar, when it scrolls down or up, my bitmap within the client area will be smudged. What codes m i missing ? Err how should i attach my picture files?
http://cboard.cprogramming.com/attac...achmentid=5599
Below is the code to displaying the scrollbar and my icons, the program im doing is to mimic a windows folder and display the icons depending on how many there are.
I apologise for the huge codings but is there something i missed ? i have no idea how to salvage the situation.Code:case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd,&ps);
HBITMAP test;
int x,y,i,IconsNo, Columns;
x = 10; y = 10;
i = 0;
IconsNo = 20; // artificial icon number to test my program firsthand.
test = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_NOTE));
while(i<IconsNo)
{
if ( x > 265 )
{
x = 10;
y = y + 90;
bMp->Draw(test,hdc,1,x,y,0,0); // this is just a bitblt function
}
bMp->Draw(test,hdc,1,x,y,0,0);
x = x + 85;
i++;
}
Columns = IconsNo / 4 + 1; // Each row only takes 4 icons + 1 to round up
si.cbSize = sizeof (si) ;
si.fMask = SIF_RANGE | SIF_PAGE ;
si.nMin = 1 ;
si.nMax = Columns * TextperIcon - (cyClient / cyChar) - 10;
// 10 is the starting y value, icon starts at (10,10)
si.nPage = cyClient / cyChar ; // No. of text displayed
SetScrollInfo (hwnd, SB_VERT, &si, TRUE) ;
DeleteObject(test);
break;
case WM_VSCROLL:
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
GetScrollInfo(hwnd,SB_VERT,&si);
PosVert = si.nPos;
switch(LOWORD(wParam))
{
case SB_LINEDOWN:
si.nPos += 1 ;
break;
case SB_PAGEDOWN:
si.nPos += si.nPage ;
break;
case SB_THUMBTRACK:
si.nPos = si.nTrackPos ;
break;
case SB_PAGEUP:
si.nPos -= si.nPage ;
break;
case SB_LINEUP:
si.nPos -= 1 ;
break;
}
si.fMask = SIF_POS ;
SetScrollInfo (hwnd, SB_VERT, &si, TRUE) ;
GetScrollInfo (hwnd, SB_VERT, &si) ;
// If the position has changed, scroll the window and update it
if (si.nPos != PosVert)
{
ScrollWindowEx(hwnd,0,cyChar * (PosVert - si.nPos),
NULL,NULL,NULL,NULL,SW_ERASE) ;
UpdateWindow (hwnd) ;
}
break;