1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
case WM_VSCROLL:
{
static bool Vstops=false;
SCROLLINFO si;
ZeroMemory(&si, sizeof(si));
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
GetScrollInfo(inst->hwnd,SB_VERT, &si);//the nMax is 34, in these case
if( LOWORD(wParam)==SB_LINEDOWN && si.nPos<si.nMax)
{
SetScrollPos(inst->hwnd,SB_VERT, GetScrollPos(inst->hwnd,SB_VERT) +1,TRUE);
ScrollWindowEx(inst->hwnd,0,-1,NULL,NULL,NULL,NULL,SW_SCROLLCHILDREN | SW_INVALIDATE | SW_ERASE);
}
else if( LOWORD(wParam)==SB_LINEUP)
{
if(GetScrollPos(inst->hwnd,SB_VERT)>0)
{
SetScrollPos(inst->hwnd,SB_VERT, GetScrollPos(inst->hwnd,SB_VERT) -1,TRUE);
ScrollWindowEx(inst->hwnd,0,+1,NULL,NULL,NULL,NULL,SW_SCROLLCHILDREN | SW_INVALIDATE | SW_ERASE);
}
}
else if(LOWORD(wParam)==SB_THUMBPOSITION && Vstops==false)//when the user up the click
{
int thumbposition = HIWORD(wParam);
bool upthumb=(thumbposition<si.nPos);
SetScrollPos(inst->hwnd,SB_VERT, thumbposition,TRUE);
int newposition=0;
if(upthumb==false)
{
newposition= +si.nPos - thumbposition;
}
else
{
newposition = si.nPos - thumbposition;
}
ScrollWindowEx(inst->hwnd,0,newposition,NULL,NULL,NULL,NULL,SW_SCROLLCHILDREN | SW_INVALIDATE | SW_ERASE);
}
else if(LOWORD(wParam)==SB_THUMBTRACK && Vstops==false)//while draggind
{
int thumbposition = HIWORD(wParam);
bool upthumb=(thumbposition<si.nPos);
SetScrollPos(inst->hwnd,SB_VERT, thumbposition,TRUE);
int newposition=0;
if(upthumb==false)
{
newposition= +si.nPos - thumbposition;
}
else
{
newposition = si.nPos - thumbposition;
}
ScrollWindowEx(inst->hwnd,0,newposition,NULL,NULL,NULL,NULL,SW_SCROLLCHILDREN | SW_INVALIDATE | SW_ERASE);
}
else if(LOWORD(wParam)==SB_TOP && Vstops==false)
{
static int i=i+1;
SetWindowText(inst->hwnd,to_string(i).c_str());
}
}
break;
|