Changeset 224 for trunk/src/helpers
- Timestamp:
- Sep 9, 2002, 6:49:14 PM (23 years ago)
- Location:
- trunk/src/helpers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/cctl_checkcnr.c
r222 r224 861 861 862 862 /* 863 *@@ FINDCHECKRECORD: 864 * 865 *@@added V0.9.21 (2002-09-09) [umoeller] 866 */ 867 868 typedef struct _FINDCHECKRECORD 869 { 870 ULONG ulItemID; 871 PCHECKBOXRECORDCORE precFound; 872 } FINDCHECKRECORD, *PFINDCHECKRECORD; 873 874 /* 863 875 *@@ fncbFindCheckRecord: 864 876 * helper callback for finding a checkbox … … 870 882 * 871 883 *@@added V0.9.0 (99-11-28) [umoeller] 872 */ 873 874 STATIC ULONG EXPENTRY fncbFindCheckRecord(HWND hwndCnr, // in: container 884 *@@changed V0.9.21 (2002-09-09) [umoeller]: adjusted for cnrhForAllRecords updates 885 */ 886 887 STATIC ULONG XWPENTRY fncbFindCheckRecord(HWND hwndCnr, // in: container 875 888 PRECORDCORE preccThis, // in: current record (from cnrhForAllRecords) 876 ULONG ulItemID, // in: item ID to find 877 ULONG ulppRecc) // out: PRECORDCORE* if found 878 { 879 ULONG ulrc = 0; 880 PCHECKBOXRECORDCORE precc = (PCHECKBOXRECORDCORE)preccThis; 881 if (precc) 882 { 883 if (precc->ulItemID == ulItemID) 884 { 885 // found: 886 PCHECKBOXRECORDCORE *pprecc = (PCHECKBOXRECORDCORE*)ulppRecc; 887 // store 888 *pprecc = precc; 889 // and stop 890 ulrc = 1; 891 } 892 } 893 894 return ulrc; 889 ULONG ulUser) 890 { 891 if (((PCHECKBOXRECORDCORE)preccThis)->ulItemID == ((PFINDCHECKRECORD)ulUser)->ulItemID) 892 { 893 // found: store found record 894 ((PFINDCHECKRECORD)ulUser)->precFound = (PCHECKBOXRECORDCORE)preccThis; 895 // and stop 896 return 1; 897 } 898 899 return 0; 895 900 } 896 901 … … 902 907 * 903 908 *@@added V0.9.1 (99-12-03) [umoeller] 909 *@@changed V0.9.21 (2002-09-09) [umoeller]: adjusted for cnrhForAllRecords updates 904 910 */ 905 911 … … 907 913 ULONG ulItemID) 908 914 { 909 PCHECKBOXRECORDCORE precc = 0; 915 FINDCHECKRECORD fcr; 916 917 fcr.ulItemID = ulItemID; 918 fcr.precFound = NULL; 910 919 911 920 cnrhForAllRecords(hwndCnr, 912 921 NULL, // start with root 913 922 fncbFindCheckRecord, 914 (ULONG)ulItemID, // input 915 (ULONG)&precc); 916 917 return precc; 923 (ULONG)&fcr); 924 925 return fcr.precFound; 918 926 } 919 927 -
trunk/src/helpers/cnrh.c
r184 r224 1529 1529 /* 1530 1530 *@@ cnrhForAllRecords: 1531 * this monster function calls pfnwpCallback1532 * f or 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. 1534 1534 * 1535 1535 * This is extremely useful for cleaning up … … 1538 1538 * 1539 1539 * This function recurses for child records. 1540 * On the first call, prec cParent should be1540 * On the first call, precParent should be 1541 1541 * NULL; you may however specify a certain 1542 1542 * record, and this function will call the 1543 1543 * callback only for that record and children. 1544 1544 * 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 1546 1559 * parameters: 1547 1560 * 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. 1559 1566 * 1560 1567 * If the callback returns anything != 0, this … … 1572 1579 * 1573 1580 *@@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 1574 1584 */ 1575 1585 1576 1586 ULONG 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 { 1583 1591 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, 1605 1605 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 1611 1608 MPFROM2SHORT( 1612 usQuery, // set above 1609 (precParent) 1610 ? CMA_FIRSTCHILD 1611 : CMA_FIRST, 1613 1612 CMA_ITEMORDER) 1614 1613 ); 1615 1614 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 1620 1633 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 1638 1644 break; 1639 1645 1640 fFirstCall = FALSE; 1646 ulrc++; 1647 1648 prec2 = precNext; 1641 1649 } 1642 1650
Note:
See TracChangeset
for help on using the changeset viewer.