Ignore:
Timestamp:
Sep 9, 2002, 6:49:14 PM (23 years ago)
Author:
umoeller
Message:

Misc fixes.

File:
1 edited

Legend:

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

    r184 r224  
    15291529/*
    15301530 *@@ cnrhForAllRecords:
    1531  *      this monster function calls pfnwpCallback
    1532  *      for really all the records in the container,
    1533  *      including child records in tree view.
     1531 *      this monster function calls the given callback
     1532 *      function for really all the records in the
     1533 *      container, including child records in tree view.
    15341534 *
    15351535 *      This is extremely useful for cleaning up
     
    15381538 *
    15391539 *      This function recurses for child records.
    1540  *      On the first call, preccParent should be
     1540 *      On the first call, precParent should be
    15411541 *      NULL; you may however specify a certain
    15421542 *      record, and this function will call the
    15431543 *      callback only for that record and children.
    15441544 *
    1545  *      pfnwpCallback gets called with the following
     1545 *      As a special argument, if precParent is -1,
     1546 *      we do not recurse into child records. This
     1547 *      is useful if you _know_ that your container
     1548 *      does not contain child records and you want
     1549 *      to speed up processing.
     1550 *
     1551 *      The callback function pfncb must be declared as
     1552 *      follows:
     1553 *
     1554 +          ULONG XWPENTRY fncb(HWND hwndCnr,
     1555 +                              PRECORDCORE precc,
     1556 +                              ULONG ulUser)
     1557 *
     1558 *      It gets called for every record with the following
    15461559 *      parameters:
    15471560 *
    1548  *      -- HWND hwnd: hwndCnr, as passed to this func
    1549  *      -- PRECORDCORE precc: current record core, as
    1550  *                     determined by this func.
    1551  *      -- ULONG ulUser1/2: what you have specified here.
    1552  *
    1553  *      It must be declared as follows:
    1554  *
    1555  +          ULONG EXPENTRY fncb(HWND hwndCnr,
    1556  +                              PRECORDCORE precc,
    1557  +                              ULONG ulUser1,
    1558  +                              ULONG ulUser2)
     1561 *      -- HWND hwndCnr, as passed to this function
     1562 *
     1563 *      -- PRECORDCORE precc: current record core
     1564 *
     1565 *      -- ULONG ulUser: what was given to this function.
    15591566 *
    15601567 *      If the callback returns anything != 0, this
     
    15721579 *
    15731580 *@@added V0.9.0 [umoeller]
     1581 *@@changed V0.9.21 (2002-09-09) [umoeller]: rewritten to support deletion in callback
     1582 *@@changed V0.9.21 (2002-09-09) [umoeller]: added support for precParent = -1
     1583 *@@changed V0.9.21 (2002-09-09) [umoeller]: changed prototype and callback prototype
    15741584 */
    15751585
    15761586ULONG cnrhForAllRecords(HWND hwndCnr,
    1577                         PRECORDCORE preccParent,    // in: NULL for root
    1578                         PFNCBRECC pfncbRecc,        // in: callback
    1579                         ULONG ulUser1,
    1580                         ULONG ulUser2)
    1581 {
    1582     PRECORDCORE precc2 = preccParent;
     1587                        PRECORDCORE precParent,     // in: parent rec to start with, or NULL, or -1
     1588                        PFNCBRECC pfncb,            // in: callback function
     1589                        ULONG ulUser)               // in: user argument for callback
     1590{
    15831591    ULONG       ulrc = 0;
    1584     USHORT      usQuery;
    1585     BOOL        fFirstCall = TRUE;
    1586 
    1587     while (TRUE)
    1588     {
    1589         if (fFirstCall)
    1590         {
    1591             // first call:
    1592             if (preccParent)
    1593                 // non-root:
    1594                 usQuery = CMA_FIRSTCHILD;
    1595             else
    1596                 // NULL == root:
    1597                 usQuery = CMA_FIRST;
    1598         }
    1599         else
    1600             // subsequent calls:
    1601             usQuery = CMA_NEXT;     // works as CMA_NEXTCHILD also
    1602 
    1603         precc2 =
    1604             (PRECORDCORE)WinSendMsg(hwndCnr,
     1592
     1593    // get first record or first child record
     1594    PRECORDCORE prec2;
     1595
     1596    BOOL        fRecurse = TRUE;
     1597
     1598    if ((ULONG)precParent == -1)
     1599    {
     1600        fRecurse = FALSE;
     1601        precParent = NULL;
     1602    }
     1603
     1604    prec2 = (PRECORDCORE)WinSendMsg(hwndCnr,
    16051605                                    CM_QUERYRECORD,
    1606                                     (MPARAM)((fFirstCall)
    1607                                          // first call (CMA_FIRSTCHILD or CMA_FIRST):
    1608                                          ? preccParent   // ignored for CMA_FIRST
    1609                                          // subsequent calls (CMA_NEXTCHILD or CMA_NEXT):
    1610                                          : precc2),  // what we queried last
     1606                                    (MPARAM)precParent,
     1607                                            // ignored for CMA_FIRST
    16111608                                    MPFROM2SHORT(
    1612                                             usQuery,    // set above
     1609                                            (precParent)
     1610                                                    ? CMA_FIRSTCHILD
     1611                                                    : CMA_FIRST,
    16131612                                            CMA_ITEMORDER)
    16141613                                    );
    16151614
    1616         if ((precc2) && ((ULONG)precc2 != -1))
    1617         {
    1618             // record found:
    1619             // recurse for that record
     1615    // loop while we have records
     1616    while (    (prec2)
     1617            && ((ULONG)prec2 != -1)
     1618          )
     1619    {
     1620        // record found:
     1621
     1622        // get the next record BEFORE calling the callback
     1623        // in case the callback removes the record
     1624        // V0.9.21 (2002-09-09) [umoeller]
     1625        PRECORDCORE precNext = (PRECORDCORE)WinSendMsg(hwndCnr,
     1626                                                       CM_QUERYRECORD,
     1627                                                       (MPARAM)prec2,
     1628                                                       MPFROM2SHORT(CMA_NEXT,
     1629                                                                    CMA_ITEMORDER));
     1630
     1631        if (fRecurse)   // V0.9.21 (2002-09-09) [umoeller]
     1632            // recurse for the record we found
    16201633            ulrc += cnrhForAllRecords(hwndCnr,
    1621                                       precc2,        // new parent to search
    1622                                       pfncbRecc,
    1623                                       ulUser1,
    1624                                       ulUser2);
    1625 
    1626             // _Pmpf(("Calling callback for %s", precc2->pszIcon));
    1627 
    1628             // call callback
    1629             if (pfncbRecc)
    1630                 if ((*pfncbRecc)(hwndCnr, precc2, ulUser1, ulUser2))
    1631                     // returns something != NULL:
    1632                     // stop
    1633                     break;
    1634             ulrc++;
    1635         }
    1636         else
    1637             // no more records or error: get outta here
     1634                                      prec2,        // new parent to search
     1635                                      pfncb,
     1636                                      ulUser);
     1637
     1638        // call callback
     1639        if (    (pfncb)
     1640             && (pfncb(hwndCnr, prec2, ulUser))
     1641           )
     1642            // returns something != NULL:
     1643            // stop
    16381644            break;
    16391645
    1640         fFirstCall = FALSE;
     1646        ulrc++;
     1647
     1648        prec2 = precNext;
    16411649    }
    16421650
Note: See TracChangeset for help on using the changeset viewer.