Mercurial > dwindows
comparison win/dw.c @ 211:e57c182cac64
Automatically scroll when getting PAGE and LINE messages, not just
track messages.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 01 Feb 2003 11:28:43 +0000 |
parents | 85f25e8c1b1e |
children | 13d3de3f1e83 |
comparison
equal
deleted
inserted
replaced
210:b9c7b762c104 | 211:e57c182cac64 |
---|---|
1195 usedpadx = usedpady = usedx = usedy = depth = 0; | 1195 usedpadx = usedpady = usedx = usedy = depth = 0; |
1196 | 1196 |
1197 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); | 1197 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); |
1198 } | 1198 } |
1199 } | 1199 } |
1200 } | |
1201 | |
1202 int _HandleScroller(HWND handle, int pos, int which) | |
1203 { | |
1204 SCROLLINFO si; | |
1205 | |
1206 si.cbSize = sizeof(SCROLLINFO); | |
1207 si.fMask = SIF_ALL; | |
1208 | |
1209 SendMessage(handle, SBM_GETSCROLLINFO, 0, (LPARAM)&si); | |
1210 | |
1211 switch(which) | |
1212 { | |
1213 case SB_THUMBTRACK: | |
1214 return pos; | |
1215 /*case SB_PAGEDOWN:*/ | |
1216 case SB_PAGELEFT: | |
1217 pos = si.nPos - si.nPage; | |
1218 if(pos < si.nMin) | |
1219 pos = si.nMin; | |
1220 return pos; | |
1221 /*case SB_PAGEUP:*/ | |
1222 case SB_PAGERIGHT: | |
1223 pos = si.nPos + si.nPage; | |
1224 if(pos > (si.nMax - si.nPage) + 1) | |
1225 pos = (si.nMax - si.nPage) + 1; | |
1226 return pos; | |
1227 /*case SB_LINEDOWN:*/ | |
1228 case SB_LINELEFT: | |
1229 pos = si.nPos - 1; | |
1230 if(pos < si.nMin) | |
1231 pos = si.nMin; | |
1232 return pos; | |
1233 /*case SB_LINEUP:*/ | |
1234 case SB_LINERIGHT: | |
1235 pos = si.nPos + 1; | |
1236 if(pos > (si.nMax - si.nPage) + 1) | |
1237 pos = (si.nMax - si.nPage) + 1; | |
1238 return pos; | |
1239 } | |
1240 return -1; | |
1200 } | 1241 } |
1201 | 1242 |
1202 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */ | 1243 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */ |
1203 BOOL CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | 1244 BOOL CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) |
1204 { | 1245 { |
1527 tmp = NULL; | 1568 tmp = NULL; |
1528 } | 1569 } |
1529 } | 1570 } |
1530 else if(strnicmp(tmpbuf, SCROLLBARCLASSNAME, strlen(SCROLLBARCLASSNAME)+1)==0) | 1571 else if(strnicmp(tmpbuf, SCROLLBARCLASSNAME, strlen(SCROLLBARCLASSNAME)+1)==0) |
1531 { | 1572 { |
1532 if(handle == tmp->window && LOWORD(mp1) == SB_THUMBTRACK) | 1573 if(handle == tmp->window) |
1533 { | 1574 { |
1534 int value = (int)HIWORD(mp1); | 1575 int value = _HandleScroller(handle, (int)HIWORD(mp1), (int)LOWORD(mp1)); |
1535 | 1576 |
1536 dw_scrollbar_set_pos(tmp->window, value); | 1577 if(value > -1) |
1537 result = valuechangefunc(tmp->window, value, tmp->data); | 1578 { |
1579 dw_scrollbar_set_pos(tmp->window, value); | |
1580 result = valuechangefunc(tmp->window, value, tmp->data); | |
1581 } | |
1538 tmp = NULL; | 1582 tmp = NULL; |
1583 msg = 0; | |
1539 } | 1584 } |
1540 } | 1585 } |
1541 } | 1586 } |
1542 break; | 1587 break; |
1543 } | 1588 } |
1626 case WM_HSCROLL: | 1671 case WM_HSCROLL: |
1627 case WM_VSCROLL: | 1672 case WM_VSCROLL: |
1628 { | 1673 { |
1629 HWND handle = (HWND)mp2; | 1674 HWND handle = (HWND)mp2; |
1630 | 1675 |
1631 if(dw_window_get_data(handle, "_dw_scrollbar") && LOWORD(mp1) == SB_THUMBTRACK) | 1676 if(dw_window_get_data(handle, "_dw_scrollbar")) |
1632 { | 1677 { |
1633 int value = (int)HIWORD(mp1); | 1678 int value = _HandleScroller(handle, (int)HIWORD(mp1), (int)LOWORD(mp1)); |
1634 dw_scrollbar_set_pos(handle, value); | 1679 |
1680 if(value > -1) | |
1681 dw_scrollbar_set_pos(handle, value); | |
1635 } | 1682 } |
1636 } | 1683 } |
1637 break; | 1684 break; |
1638 case WM_GETMINMAXINFO: | 1685 case WM_GETMINMAXINFO: |
1639 { | 1686 { |