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 70 71 72 73 74 75 76 77 78 79 80 81
|
case WM_VSCROLL: {
auto action = LOWORD(wParam);
HWND hScroll = (HWND)lParam;
int pos = -1;
if (action == SB_THUMBPOSITION || action == SB_THUMBTRACK) {
pos = HIWORD(wParam);
} else if (action == SB_LINEDOWN) {
pos = g_scrollY + 30;
} else if (action == SB_LINEUP) {
pos = g_scrollY - 30;
}
if (pos == -1)
break;
WCHAR buf[20];
SCROLLINFO si = { 0 };
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_POS;
si.nPos = pos;
si.nTrackPos = 0;
SetScrollInfo(hwnd, SB_VERT, &si, true);
GetScrollInfo(hwndscroll, SB_VERT, &si);
pos = si.nPos;
POINT pt;
pt.x = 0;
pt.y = pos - g_scrollY;
auto hdc = GetDC(hwndscroll);
LPtoDP(hdc, &pt, 1);
ReleaseDC(hwndscroll, hdc);
ScrollWindow(hwndscroll, 0, -pt.y, NULL, NULL);
g_scrollY = pos;
myredraw = true;
RedrawWindow(hwnd, &lprcUpdate, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW);
break;
}
case WM_CREATE:
hwndscroll = CreateWindow(
"static",
"",
WS_CHILD | WS_VISIBLE | IDC_VSCROLLBAR,
0,
120,
180,
500,
hwnd,
(HMENU) 1002,
((LPCREATESTRUCT) lParam ->hInstance,
(PVOID) NULL
);
RECT rc = { 0 };
GetClientRect(hwndscroll, &rc);
SCROLLINFO si = { 0 };
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = 30 * 99 + 21;
si.nPage = (rc.bottom - rc.top);
si.nPos = 0;
si.nTrackPos = 0;
SetScrollInfo(hwnd, SB_VERT, &si, true);
case WM_COMMAND:
if(LOWORD(wParam) == 1000){//"+"
myhwnd = CreateWindow (
"button",
"G",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
25,
25+(mypage-1)*175,
20,
20,
hwndscroll,
(HMENU) 10001,
NULL,
NULL
);
}
if(LOWORD(wParam) == 10001){
|