Ignore:
Timestamp:
Aug 7, 2001, 11:34:30 PM (24 years ago)
Author:
umoeller
Message:

Lafaix and Ratcliffe updates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/winh.c

    r91 r95  
    13621362 *      this func after you have received SPBN_UP/DOWNARROW,
    13631363 *      the spin button's value will always in/decrease
    1364  *      in steps of 100.
     1364 *      so that the spin button's value is a multiple of 100.
     1365 *
     1366 *      By contrast, if (lGrid < 0), this will not really
     1367 *      snap the value to a multiple of -lGrid, but instead
     1368 *      in/decrease the value by -lGrid. The value will not
     1369 *      necessarily be a multiple of the grid. (0.9.14)
    13651370 *
    13661371 *      This returns the "snapped" value to which the spin
     
    13681373 *
    13691374 *      If you specify lGrid == 0, this returns the spin
    1370  *      button's value only (V0.9.0).
     1375 *      button's value only without snapping (V0.9.0).
    13711376 *
    13721377 *@@changed V0.9.0 [umoeller]: added check for lGrid == 0 (caused division by zero previously)
     1378 *@@changed V0.9.14 (2001-08-03) [umoeller]: added fixes for age-old problems with wrap around
     1379 *@@changed V0.9.14 (2001-08-03) [umoeller]: added lGrid < 0 mode
    13731380 */
    13741381
     
    13801387    HWND hwndSpin = WinWindowFromID(hwndDlg, usItemID);
    13811388    LONG lBottom, lTop, lValue;
     1389
    13821390    // get value, which has already increased /
    13831391    // decreased by 1
     
    13971405        // manually enters something (SPBN_CHANGE),
    13981406        // we'll accept that value
    1399         lValue = (lValue / lGrid) * lGrid;
    1400         // add /subtract grid
    1401         if (usNotifyCode == SPBN_UPARROW)
    1402             lValue += lGrid;
    1403         // else we'll have -= lGrid already
     1407        LONG lChanged = (usNotifyCode == SPBN_UPARROW)
     1408                            // if the spin button went up, subtract 1
     1409                            ? -1
     1410                            : +1;
     1411        LONG lPrev  = lValue + lChanged;
     1412
     1413        // if grid is negative, it is assumed to
     1414        // not be a "real" grid but jump in those
     1415        // steps only
     1416        if (lGrid < 0)
     1417        {
     1418            // add /subtract grid
     1419            if (usNotifyCode == SPBN_UPARROW)
     1420                lValue = lPrev - lGrid;
     1421            else
     1422                lValue = lPrev + lGrid;
     1423
     1424            // lValue = (lValue / lGrid) * lGrid;
     1425        }
     1426        else
     1427        {
     1428            // add /subtract grid
     1429            if (usNotifyCode == SPBN_UPARROW)
     1430                lValue = lPrev + lGrid;
     1431            else
     1432                lValue = lPrev - lGrid;
     1433
     1434            lValue = (lValue / lGrid) * lGrid;
     1435        }
    14041436
    14051437        // balance with spin button limits
Note: See TracChangeset for help on using the changeset viewer.