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 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
LRESULT CALLBACK hpanel_proc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam){
SCROLLINFO si;
int yPos;
WORD wScrollNotify = 0xFFFF;
int content_height = 0;
switch (Message) {
// Here I am re-sizing my STATIC controls, for more details see the project link
case WM_SIZE:
//Resizing control code - it works and I get the total height of the content as
content_height = 40 + window_props(desc_panel, HEIGHT) +
window_props(title_panel, HEIGHT) +
window_props(desc_panel2, HEIGHT);
content_height = 40 + window_props(desc_panel, HEIGHT) +
window_props(title_panel, HEIGHT) + window_props(desc_panel2, HEIGHT);
si.fMask = SIF_RANGE;
si.nMin = 0;
si.nMax = content_height - window_props(head_panel, HEIGHT);
si.nPage = content_height - (content_height - window_props(head_panel, HEIGHT));
SetScrollRange(head_panel, SB_CTL, 0, 100, TRUE);
SetScrollInfo(head_panel, SB_CTL, &si, TRUE);
UpdateWindow(hWnd);
return 0;
break;
case WM_VSCROLL:
si.fMask = SIF_ALL;
GetScrollInfo(hWnd, SB_VERT, &si);
yPos = si.nPos;
switch (LOWORD(wParam)) {
case SB_TOP:
si.nPos = si.nMin;
break;
case SB_BOTTOM:
si.nPos = si.nMax;
break;
case SB_LINEUP:
si.nPos -= 1;
break;
case SB_LINEDOWN:
si.nPos += 1;
break;
case SB_PAGEUP:
si.nPos -= si.nPage;
break;
case SB_PAGEDOWN:
si.nPos += si.nPage;
break;
case SB_THUMBTRACK:
si.nPos = si.nTrackPos;
break;
default:
break;
}
si.fMask = SIF_POS;
SetScrollInfo (hWnd, SB_VERT, &si, TRUE);
GetScrollInfo (hWnd, SB_VERT, &si);
if (si.nPos != yPos) {
ScrollWindow(hWnd, 0, yPos - si.nPos, NULL, NULL);
UpdateWindow(hWnd);
}
return 0;
break;
// This doesn't work either but for the moment the problem is not here
case WM_KEYDOWN:
switch (wParam) {
case VK_UP:
wScrollNotify = SB_LINEUP;
break;
case VK_PRIOR:
wScrollNotify = SB_PAGEUP;
break;
case VK_NEXT:
wScrollNotify = SB_PAGEDOWN;
break;
case VK_DOWN:
wScrollNotify = SB_LINEDOWN;
break;
case VK_HOME:
wScrollNotify = SB_TOP;
break;
case VK_END:
wScrollNotify = SB_BOTTOM;
break;
}
SendMessage(hWnd, WM_VSCROLL, MAKELONG(wScrollNotify, 0), 0L);
return 0;
break;
default:
return CallWindowProc(orig_hpanel_proc, hWnd, Message, wParam, lParam);
break;
}
}
|