54#define new(TYPE, numElems) \
55 HeapAlloc(GetProcessHeap(), 0, (numElems) * sizeof(TYPE))
57 HeapFree(GetProcessHeap(), 0, (ptr))
63#define GWLP_USERDATA GWL_USERDATA
66#define GWLP_WNDPROC GWL_WNDPROC
69#ifndef SetWindowLongPtr
70#define SetWindowLongPtr SetWindowLong
72#ifndef GetWindowLongPtr
73#define GetWindowLongPtr GetWindowLong
76#define DWORD_PTR DWORD
83#define str_len (unsigned)wcslen
85#define str_ncpy wcsncpy
86#define str_ncmp wcsncmp
87#define str_icmp _wcsicmp
89#define str_len (unsigned)strlen
91#define str_ncpy strncpy
92#define str_ncmp strncmp
93#define str_icmp _stricmp
96#define WM_MOUSEWHEEL 0x020A
99#define WHEEL_DELTA 120
102#define MAX_COLUMNS 32
105#define EN_SETTEXT 0x1000
106#define EN_RETURN 0x1578
107#define EN_ESCAPE 0x1579
108#define ID_TOOLTIPCHECK 0x3912
109#define SORT_NOUPDATE 1234567
110#define VK_ISACHAR 0x01000000
111#define FIRST_LINE 0xFFFFFFFE
112#define FROM_HEADER 0x88776655
113#define I_CCB I_CHILDRENCALLBACK
114#define U(h) ((unsigned)(ULONG_PTR)(h))
115#define THEMEIMGLIST ((HIMAGELIST)1)
116#define GetHandle(h) ((TreeListData*)GetWindowLongPtr(h,0))
117#define TVIF_ALL (TVIF_CHILDREN|TVIF_HANDLE|TVIF_IMAGE|TVIF_PARAM|TVIF_SELECTEDIMAGE|TVIF_STATE|TVIF_TEXT)
118#define UNLOCK(d) ReleaseSemaphore(d->hSem,1,NULL)
119#define LOCK(d) WaitForSingleObject(d->hSem,INFINITE)
120#define TVIS_EDIT(m) ((1<<m)&((1<<TVAX_EDIT)|(1<<TVAX_COMBO)|(1<<TVAX_STEPED)|(1<<TVAX_CHECKED)))
121#define TVIS_BASEFLAGS (TVIS_EXPANDED|TVIS_EXPANDEDONCE|TVIS_EXPANDPARTIAL|TVIS_SELECTED)
122#define TVIS_TRACKED (TVIX_TRACKED<<16)
123#define TVIS_BKCOLOR (TVIX_BKCOLOR<<16)
125#define TVIS_FOCUSED (TVIX_FOCUSED<<16)
126#define TVIS_TEXTCOLOR (TVIX_TEXTCOLOR<<16)
127#define TVC_ONLYFOCUS TVIF_ONLYFOCUS
128#define TVC_UNSELECT 0x4000
129#define TVC_DESELECT 0x8000
130#define DEFAULT_IDENT 19
131#define DEFAULT_SHIFT 7
132#ifndef BPBF_COMPATIBLEBITMAP
133#define BPBF_COMPATIBLEBITMAP 0
147#ifndef CBS_UNCHECKEDNORMAL
148#define CBS_UNCHECKEDNORMAL 1
150#ifndef CBS_CHECKEDNORMAL
151#define CBS_CHECKEDNORMAL 5
155#define TVAX_NONE (TVAE_NONE >>TVAE_MODEPOS)
156#define TVAX_EDIT (TVAE_EDIT >>TVAE_MODEPOS)
157#define TVAX_COMBO (TVAE_COMBO >>TVAE_MODEPOS)
158#define TVAX_CBLIST (TVAE_CBLIST >>TVAE_MODEPOS)
159#define TVAX_STEP (TVAE_STEP >>TVAE_MODEPOS)
160#define TVAX_STEPED (TVAE_STEPED >>TVAE_MODEPOS)
161#define TVAX_CHECK (TVAE_CHECK >>TVAE_MODEPOS)
162#define TVAX_CHECKED (TVAE_CHECKED>>TVAE_MODEPOS)
164#define TVIX_VARBUTTON 0x01
165#define TVIX_HASBUTTON 0x02
166#define TVIX_HASIMAGE 0x04
167#define TVIX_TRACKED 0x08
168#define TVIX_TEXTCOLOR 0x10
169#define TVIX_BKCOLOR 0x20
170#define TVIX_FOCUSED 0x40
223 BYTE bDummy[32 - 23 -
sizeof(
void *)];
396 static int iIsRegistered =
FALSE;
406 memset(&sClass, 0,
sizeof(sClass));
407 sClass.
cbSize =
sizeof(sClass);
424 iIsRegistered =
TRUE;
555 sInfo.item.lParam =
pEntry->lParam;
557 sInfo.item.state =
pEntry->uState;
558 sInfo.item.stateMask = 0xFFFFFFFF;
566 pData->cTempText2[0] = 0;
567 sInfo.item.pszText =
pData->cTempText2;
568 sInfo.item.cchTextMax =
sizeof(
pData->cTempText2) /
sizeof(
TCHAR) - 1;
571 pData->cTempText1[0] = 0;
572 sInfo.item.pszText =
pData->cTempText1;
573 sInfo.item.cchTextMax =
sizeof(
pData->cTempText1) /
sizeof(
TCHAR) - 1;
576 sInfo.item.pszText = 0;
577 sInfo.item.cchTextMax = 0;
580 sInfo.hdr.hwndFrom =
pData->hWnd;
590 *iImage = sInfo.item.iImage;
594 *iImage = sInfo.item.iSelectedImage;
598 switch(sInfo.item.cChildren) {
600 pEntry->bFlags &= ~TVIX_HASBUTTON;
605 pEntry->bFlags &= ~TVIX_VARBUTTON;
616 pEntry->bFlags &= ~TVIX_HASBUTTON;
621 *
pText = sInfo.item.pszText;
622 *uTextSize =
str_len(sInfo.item.pszText);
644 sInfo.item.lParam =
pEntry->lParam;
646 sInfo.item.state = pExtra->
uState;
648 sInfo.item.stateMask = 0xFFFFFFFF;
651 sInfo.item.cChildren = uSub;
655 pData->cTempText1[0] = 0;
656 sInfo.item.pszText =
pData->cTempText1;
657 sInfo.item.cchTextMax =
sizeof(
pData->cTempText1) /
sizeof(
TCHAR) - 1;
659 sInfo.item.pszText = 0;
660 sInfo.item.cchTextMax = 0;
663 sInfo.hdr.hwndFrom =
pData->hWnd;
673 *iImage = sInfo.item.iImage;
675 *
pText = sInfo.item.pszText;
676 *uTextSize =
str_len(sInfo.item.pszText);
709 pProc =
pData->pProcId3;
748 if(
pData->uEditMode && iId == 3)
751 if(dwStart || dwStop)
759 if(
pData->uEditMode && iId == 3)
763 if(dwCount > dwStart)
882 iAll =
pData->iAllWeight;
883 iCnt =
pData->uColumnCountVar;
886 for(uPos = 0; uPos <
pData->uColumnCount; uPos++) {
887 iWeight =
pData->aColumn[uPos].bWeight;
891 iValue =
pData->aColumn[uPos].sSize;
896 pData->iVarSize = iValue;
898 if(sItem.cxy <
pData->aColumn[uPos].sMin) {
899 sItem.cxy =
pData->aColumn[uPos].sMin;
902 if(
pData->aColumn[uPos].sReal != sItem.cxy) {
903 pData->aColumn[uPos].sReal = (
short)sItem.cxy;
911 sNotify.
iSize = sItem.cxy;
932 for(uPos = 0;; uPos++) {
933 iWeight =
pData->aColumn[uPos].bWeight;
944 iSize = iDelta / iAll;
945 iRest = iDelta % iAll;
950 iValue =
pData->aColumn[uPos].sSize;
951 iValue += iSize * iWeight;
952 iPoint += iRest * iWeight;
960 if(iWeight >=
pData->aColumn[uPos].bWeight) {
968 if(uPos >=
pData->uColumnCount)
970 iWeight =
pData->aColumn[uPos].bWeight;
974 iValue =
pData->aColumn[uPos].sSize;
978 iValue += iSize * iWeight;
979 iPoint += iRest * iWeight;
985 iValue += iSize * iWeight;
994 iCnt =
pData->uColumnCountVar;
996 for(uPos = 0; iCnt > 0; uPos++) {
997 iWeight =
pData->aColumn[uPos].bWeight;
999 iFix +=
pData->aColumn[uPos].sSize;
1003 iVar +=
pData->aColumn[uPos].sSize;
1004 sItem.cxy =
pData->aColumn[uPos].sSize;
1006 if(sItem.cxy <
pData->aColumn[uPos].sMin) {
1007 sItem.cxy =
pData->aColumn[uPos].sMin;
1010 if(
pData->aColumn[uPos].sReal != sItem.cxy) {
1011 pData->aColumn[uPos].sReal = (
short)sItem.cxy;
1019 sNotify.
iSize = sItem.cxy;
1030 pData->iFixSize = iFix;
1031 pData->iVarSize = iVar;
1054 pData->hToolTip =
CreateWindow(
TOOLTIPS_CLASS,
NULL,
WS_POPUP,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
pData->hWnd,
NULL,
NULL,
NULL);
1059 sInfo.hwnd =
pData->hWnd;
1092 if(!
pData->hThemeBt) {
1096 if(
pData->hThemeBt) {
1103 pData->iChecksXsize = 16;
1104 pData->iChecksYsize = 16;
1105 pData->iChecksMode = 1;
1112 pData->iStatesXsize = 16;
1113 pData->iStatesYsize = 16;
1114 pData->iStatesMode = 1;
1138 Rectangle(hDc, -1, -1, 16 * 3 + 2, 16 + 2);
1142 sRect.
left = 16 * 1 + 8 - 7;
1143 sRect.
right = 16 * 1 + 8 + 6;
1147 sRect.
left = 16 * 2 + 8 - 7;
1148 sRect.
right = 16 * 2 + 8 + 6;
1175 pData->iStatesXsize = 16;
1176 pData->iStatesYsize = 16;
1177 pData->iStatesMode = 1;
1182 pData->iChecksXsize = 16;
1183 pData->iChecksYsize = 16;
1184 pData->iChecksMode = 1;
1225 if(uItem >
pData->uTreeItemsMax)
1232 iHeigh =
pData->iFontHeight;
1235 if(uSub >=
pData->uColumnCount)
1238 pExtra =
pData->pExtraItems[uSub - 1][uItem];
1243 iWidth =
pData->iFontHeight * 4;
1256 uTSize =
pEntry->uTextSize;
1258 iWidth =
pEntry->iTextPixels;
1265 if(
pData->hImages && iImage >= 0) {
1266 if(iHeigh < pData->iImagesYsize)
1267 iHeigh =
pData->iImagesYsize;
1268 iAdd =
pData->iImagesXsize + 2;
1280 pMem =
new(
BYTE, iHeigh * (iWidth + 4) * 4 + 1024);
1297 sRect.
right = iWidth;
1298 iYpos = (iHeigh -
pData->iFontHeight) / 2;
1388 pData->cGlyphOk = 1;
1390 pData->cGlyphOk = 0;
1401 iDiff = ((uColOdd) & 0xFF) - ((
pData->uColors[
TVC_EVEN]) & 0xFF);
1402 iSum = iDiff * iDiff;
1403 iDiff = ((uColOdd >> 8) & 0xFF) - ((
pData->uColors[
TVC_EVEN] >> 8) & 0xFF);
1404 iSum += iDiff * iDiff;
1405 iDiff = ((uColOdd >> 16) & 0xFF) - ((
pData->uColors[
TVC_EVEN] >> 16) & 0xFF);
1406 iSum += iDiff * iDiff;
1410 uColOdd |= ((
pData->uColors[
TVC_EVEN] & 0x00FF0000) - 0x00080000) & 0x00FF0000;
1418 if(uColor & 0x00F00000)
1419 uColor -= 0x00100000;
1420 if(uColor & 0x0000F000)
1421 uColor -= 0x00001000;
1422 if(uColor & 0x000000F0)
1423 uColor -= 0x00000010;
1430 if(uColor & 0x00F00000)
1431 uColor -= 0x00100000;
1432 if(uColor & 0x0000F000)
1433 uColor -= 0x00001000;
1434 if(uColor & 0x000000F0)
1435 uColor -= 0x00000010;
1442 if(uColor & 0x00F00000)
1443 uColor -= 0x00100000;
1444 if(uColor & 0x0000F000)
1445 uColor -= 0x00001000;
1446 if(uColor & 0x000000F0)
1447 uColor -= 0x00000010;
1475 if(
pData->cFixedHeight)
1481 if(iHeight < pData->iChecksYsize + 2)
1482 iHeight =
pData->iChecksYsize + 2;
1484 if(iHeight < pData->iStatesYsize + 2)
1485 iHeight =
pData->iStatesYsize + 2;
1486 if(iHeight < pData->iSubImgYsize + 2)
1487 iHeight =
pData->iSubImgYsize + 2;
1488 if(iHeight < pData->iImagesYsize + 2)
1489 iHeight =
pData->iImagesYsize + 2;
1490 if(iHeight < pData->iFontHeight + 2)
1491 iHeight =
pData->iFontHeight + 2;
1496 if(
pData->iRowHeight == iHeight)
1499 pData->iRowHeight = iHeight;
1505 pData->uMaxEnties = 0;
1541 if(uPos >=
pData->uMaxEnties)
1544 uNext =
pData->aColumn[uSub].bNext;
1550 sRect.
top +=
pData->iRowHeight * uPos;
1572 if(uColumn >=
pData->uColumnCount)
1575 sRect.
left =
pData->aColumnXpos[uColumn];
1580 uNext =
pData->aColumn[uColumn].bNext;
1615 if(uPos >=
pData->uMaxEnties)
1621 sRect.
top +=
pData->iRowHeight * uPos;
1664 uCols =
pData->uColumnCount;
1666 uSize =
pData->aColumnXpos[uCols] - 1;
1668 uSize =
pData->iMaxSizeX - 1;
1671 if(
pData->uOldXCount == uSize)
1677 pData->uOldXCount = uSize;
1695 if(sInfo.
nMax > 0) {
1702 pData->uScrollX = 0;
1706 if(
pData->hHeader) {
1728 if(
pData->uOldYCount ==
pData->uItemPosCount)
1752 pData->uScrollY = 0;
1791 if(
pData->uToolTipItem)
1799 if(
pData->uToolTipItem != uItem ||
pData->uToolTipSub != 0) {
1800 if(!
pData->pTreeItems[uItem]) {
1817 sNotify.itemNew.stateMask = 0xFFFFFFFF;
1818 sNotify.itemNew.state =
pEntry->uState;
1819 sNotify.itemNew.lParam =
pEntry->lParam;
1820 sNotify.itemNew.pszText =
pEntry->pText;
1821 sNotify.itemNew.cchTextMax =
pEntry->uTextSize;
1822 sNotify.itemNew.cChildren = 0;
1823 sNotify.itemOld.mask = 0;
1824 sNotify.ptDrag.x = sRect.
left;
1825 sNotify.ptDrag.y = sRect.
top;
1838 sToolNv.lParam =
pEntry->lParam;
1839 sToolNv.pszText = cTemp;
1850 sNotify.itemNew.pszText = sToolNv.pszText;
1851 sNotify.itemNew.cchTextMax =
str_len(sToolNv.pszText);
1852 sNotify.itemNew.cChildren = 0;
1853 sNotify.itemNew.stateMask = 0xFFFFFFFF;
1854 sNotify.itemNew.state =
pEntry->uState;
1855 sNotify.itemNew.lParam =
pEntry->lParam;
1856 sNotify.ptDrag.x = sRect.
left;
1857 sNotify.ptDrag.y = sRect.
top;
1864 uSize =
pEntry->uTextSize;
1874 if(uLen >=
pData->uToolTipSize) {
1875 delete(
pData->pToolTipText);
1876 pData->uToolTipSize = (uLen + 255)&~0xFF;
1884 hToolTip =
pData->hToolTip;
1893 sInfo.cbSize =
sizeof(sInfo);
1894 sInfo.hwnd =
pData->hWnd;
1897 if(
pData->uToolTipItem) {
1899 pData->uToolTipItem = 0;
1907 pData->uToolTipItem = uItem;
1908 pData->uToolTipShow = 0;
1909 pData->uToolTipSub = 0;
1913 if(
pData->uToolTipItem)
1925 pExtra =
pData->pExtraItems[uCol - 1][uItem];
1935 sNotify.itemNew.state = pExtra->
uState;
1936 sNotify.itemNew.pszText = pExtra->
pText;
1937 sNotify.itemNew.cchTextMax = pExtra->
uTextSize;
1939 sNotify.itemNew.state = 0;
1940 sNotify.itemNew.cchTextMax = 0;
1941 sNotify.itemNew.pszText =
_T(
"");
1946 sNotify.itemNew.lParam =
pEntry->lParam;
1949 sNotify.itemNew.stateMask = 0xFFFFFFFF;
1950 sNotify.itemNew.cChildren = uCol;
1951 sNotify.itemOld.mask = 0;
1952 sNotify.ptDrag.x = sRect.
left;
1953 sNotify.ptDrag.y = sRect.
top;
1982 if(uLen >=
pData->uToolTipSize) {
1983 delete(
pData->pToolTipText);
1984 pData->uToolTipSize = (uLen + 255)&~0xFF;
1994 hToolTip =
pData->hToolTip;
2001 sInfo.cbSize =
sizeof(sInfo);
2002 sInfo.hwnd =
pData->hWnd;
2005 if(
pData->uToolTipItem) {
2007 pData->uToolTipItem = 0;
2015 pData->uToolTipItem = uItem;
2016 pData->uToolTipSub = uCol;
2017 pData->uToolTipShow = 0;
2021 if(
pData->uToolTipItem)
2025 if(
pData->uToolTipItem)
2035 if(
pData->uToolTipItem) {
2038 sInfo.cbSize =
sizeof(sInfo);
2039 sInfo.hwnd =
pData->hWnd;
2046 pData->uToolTipItem = 0;
2047 pData->uToolTipSub = 0;
2048 pData->uToolTipShow = 0;
2057 pText = sNotify.itemNew.pszText;
2058 uSize = sNotify.itemNew.cchTextMax;
2059 sRect.
left = sNotify.ptDrag.x;
2060 sRect.
top = sNotify.ptDrag.y;
2066 if(uLen >=
pData->uToolTipSize) {
2068 delete(
pData->pToolTipText);
2069 pData->uToolTipSize = (uLen + 255)&~0xFF;
2077 pData->sToolTipPos = sNotify.ptDrag;
2079 hToolTip =
pData->hToolTip;
2082 if((sNotify.itemNew.mask &
TVIF_TOOLTIPTIME) && sNotify.itemNew.lParam > 0) {
2083 pData->uToolTipShow = (
unsigned)(sNotify.itemNew.lParam + 499) / 500;
2084 pData->uToolTipSub = sNotify.itemNew.cChildren;
2085 pData->uToolTipItem = uItem;
2094 sInfo.cbSize =
sizeof(sInfo);
2095 sInfo.hwnd =
pData->hWnd;
2098 if(
pData->uToolTipItem) {
2100 pData->uToolTipItem = 0;
2108 pData->uToolTipShow = 0;
2109 pData->uToolTipItem = uItem;
2110 pData->uToolTipSub = sNotify.itemNew.cChildren;
2134 pData->hFontB = hBold;
2198 iPos =
pData->uTreeItemsMax;
2200 for(; iPos >= 0; iPos--) {
2209 for(uSub = 1; uSub <
pData->uColumnCount; uSub++) {
2210 iPos =
pData->uTreeItemsMax;
2213 for(; iPos >= 0; iPos--) {
2262 uOld =
pData->uItemPosCount;
2263 pLines =
pData->pItemPos;
2267 uItem =
pData->uFirstChild;
2272 for(uNum = 0; uNum < uOld; uNum++) {
2273 uTemp = pLines[uNum];
2283 pData->uItemPosCount = 0;
2288 memset(pLines, 0,
sizeof(
unsigned)*uOld);
2292 for(uNum = 0; uNum < uOld; uNum++) {
2293 uTemp = pLines[uNum];
2316 for(uNum = uPos; uNum < uOld; uNum++) {
2317 uTemp = pLines[uNum];
2330 uItem =
pEntry->uFirstChild;
2333 uItem =
pEntry->uNextItem;
2342 uItem =
pEntry->uNextItem;
2353 if(pLines[uPos] != uItem) {
2354 pLines[uPos] = uItem;
2364 pData->uItemPosCount = uPos;
2366 if(uStart >
pData->uScrollY)
2367 uStart -=
pData->uScrollY;
2373 sRect.
top =
pData->uStartPixel +
pData->iRowHeight * uStart;
2405 hHeader =
pData->hHeader;
2407 pData->aColumnXpos[0] = 0;
2413 for(uCol = 0; uCol <
pData->uColumnCount;) {
2414 uSub =
pData->aColumnPos[uCol];
2415 iSize =
pData->aColumn[uSub].sReal;
2416 uSub =
pData->aColumn[uSub].bNext;
2425 if(uSub ==
pData->uColumnCount)
2426 if(iNow >= (
int)
pData->uSizeX - 1) {
2430 iNum =
pData->aColumnXpos[uSub];
2441 if(
pData->uSelectedItem) {
2442 uNext =
pData->aColumn[
pData->uSelectedSub].bNext;
2448 if(
pData->uTrackedItem) {
2449 uNext =
pData->aColumn[
pData->uTrackedSub].bNext;
2456 pData->aColumnXpos[uSub] = iNow;
2460 while(uCol < pData->uColumnCount) {
2462 uSub =
pData->aColumnPos[uCol];
2463 iNow +=
pData->aColumn[uSub].sReal;
2464 uSub =
pData->aColumn[uSub].bNext;
2467 if(uCol ==
pData->uColumnCount)
2468 if(iNow >= (
int)
pData->uSizeX - 1) {
2472 pData->aColumnXpos[uSub] = iNow;
2508 if(aArray[0] != 0) {
2512 for(uCol =
pData->uColumnCount; uCol > 0; uCol++) {
2514 aArray[uCol] = uCol;
2518 uItems =
pData->uColumnCount;
2521 if(
pData->uColumnCount != uItems || uItems == 0 || *pArray) {
2526 memset(aFlags, 0,
sizeof(aFlags) - 1);
2528 for(uCol = 0, uDiff = 0; uCol < uItems; uCol++) {
2529 uSub = pArray[uCol];
2535 aFlags[uSub] = (
BYTE)uCol;
2537 uDiff |= uCol ^
pData->aColumnPos[uSub];
2545 aFlags[uItems] = (
BYTE)uItems;
2547 for(uCol = 1; uCol < uItems; uCol++) {
2548 pData->aColumnPos[uCol] = (
BYTE)pArray[uCol];
2551 for(uCol = 0; uCol < uItems; uCol++) {
2552 uSub = aFlags[uCol];
2553 pData->aColumn[uCol].bIndex = (
BYTE)uSub;
2554 pData->aColumn[uCol].bNext =
pData->aColumnPos[uSub + 1];
2564 for(uCol = 0; uCol < uItems; uCol++) {
2605 if(uItem >
pData->uTreeItemsMax)
2613 uAction = uAddFlags & 0x0F;
2618 sNotify.action = uAction;
2622 sNotify.itemNew.stateMask = 0xFFFFFFFF;
2623 sNotify.itemNew.state =
pEntry->uState;
2624 sNotify.itemNew.lParam =
pEntry->lParam;
2625 sNotify.itemNew.pszText = (
LPTSTR) - 1;
2626 sNotify.itemNew.cchTextMax = -1;
2627 sNotify.itemOld.mask = 0;
2628 sNotify.ptDrag.x = 0;
2629 sNotify.ptDrag.y = 0;
2653 pEntry->uState &= ~TVIS_EXPANDED;
2657 pEntry->uState &= ~TVIS_EXPANDPARTIAL;
2658 pEntry->uState |= uAddFlags&~0x0F;
2660 if(
pEntry->uShowPos && bDo) {
2663 uNext =
pEntry->uFirstChild;
2666 pTemp =
pList[uNext];
2691 sNotify.action = uAction;
2695 sNotify.itemNew.stateMask = 0xFFFFFFFF;
2696 sNotify.itemNew.state =
pEntry->uState;
2697 sNotify.itemNew.lParam =
pEntry->lParam;
2698 sNotify.itemNew.pszText = (
LPTSTR) - 1;
2699 sNotify.itemNew.cchTextMax = -1;
2700 sNotify.itemOld.mask = 0;
2701 sNotify.ptDrag.x = 0;
2702 sNotify.ptDrag.y = 0;
2720 if(
pData->uSelectedItem && bDo) {
2723 pData->uSelectedItem = 0;
2724 pData->uSelectedSub = 0;
2727 while(!
pEntry->uShowPos) {
2763 if(uItem >
pData->uTreeItemsMax) {
2775 if(uPos >=
pData->uMaxEnties) {
2781 pRect->
top +=
pData->iRowHeight * uPos;
2786 if(uSub >=
pData->uColumnCount)
2789 uNext =
pData->aColumn[uSub].bNext;
2803 pExtra =
pData ->pExtraItems[uSub - 1][uItem];
2816 if(
pData->cHasRootRow) {
2822 if(
pData->hStates) {
2875 if(uItem >
pData->uTreeItemsMax)
2889 pTemp =
pData->pTreeItems[uTemp];
2910 if(uPos < pData->uScrollY) {
2911 pData->uScrollY = uPos;
2916 if(uPos !=
pData->uScrollY) {
2917 pData->uScrollY = uPos;
2924 if(uPos >=
pData->uScrollY +
pData->uPageEnties) {
2925 iOff = uPos - (
pData->uPageEnties - 1);
2926 iMax =
pData->uItemPosCount;
2927 iMax -=
pData->uPageEnties - 1;
2933 if(iOff != (
int)
pData->uScrollY) {
2934 pData->uScrollY = iOff;
2940 if(uSub < pData->uColumnCount) {
2941 uNext =
pData->aColumn[uSub].bNext;
2942 iNum =
pData->uSizeX;
2943 iOff =
pData->uScrollX;
2944 iAnf =
pData->aColumnXpos[uSub ];
2945 iEnd =
pData->aColumnXpos[uNext];
2947 if(iOff + iNum < iAnf)
2951 if(iOff + iNum < iEnd)
2956 iMax =
pData->aColumnXpos[
pData->uColumnCount];
2957 iMax -=
pData->uSizeX / 2;
2963 if(iOff != (
int)
pData->uScrollX) {
2964 pData->uScrollX = iOff;
3000 if(uItem >
pData->uTreeItemsMax)
3013 if(uPos < pData->uScrollY) {
3018 if(uPos >=
pData->uScrollY +
pData->uMaxEnties) {
3022 if(uPos ==
pData->uScrollY +
pData->uPageEnties) {
3023 if(uSub < pData->uColumnCount) {
3024 uNext =
pData->aColumn[uSub].bNext;
3025 iNum =
pData->uSizeX;
3026 iOff =
pData->uScrollX;
3027 iAnf =
pData->aColumnXpos[uSub ];
3028 iEnd =
pData->aColumnXpos[uNext];
3030 if(iOff + iNum < iAnf)
3039 if(uSub < pData->uColumnCount) {
3040 uNext =
pData->aColumn[uSub].bNext;
3041 iNum =
pData->uSizeX;
3042 iOff =
pData->uScrollX;
3043 iAnf =
pData->aColumnXpos[uSub ];
3044 iEnd =
pData->aColumnXpos[uNext];
3046 if(iOff + iNum < iAnf)
3050 if(iOff + iNum < iEnd)
3083 if(
pData->cLockChanges)
3086 if(uItem >
pData->uTreeItemsMax) {
3089 if(
pData->uLastChild == 0)
3092 while(
pData->uLastChild) {
3096 pData->uItemPosCount = 0;
3108 if(
pData->uLastChild == 0)
3111 while(
pData->uLastChild) {
3115 pData->uItemPosCount = 0;
3124 if(!
pEntry->uFirstChild) {
3128 while(
pEntry->uLastChild) {
3140 while(
pEntry->uLastChild) {
3144 if(uItem ==
pData->uSelectedItem) {
3149 sNotify.itemOld.stateMask = 0xFFFFFFFF;
3150 sNotify.itemOld.state =
pEntry->uState&~TVIS_SELECTED;
3151 sNotify.itemOld.lParam =
pEntry->lParam;
3152 sNotify.itemOld.cChildren = 0;
3153 sNotify.itemOld.pszText = (
LPTSTR) - 1;
3154 sNotify.itemOld.cchTextMax = -1;
3156 sNotify.itemNew.hItem =
NULL;
3157 sNotify.itemNew.stateMask = 0xFFFFFFFF;
3158 sNotify.itemNew.state = 0;
3159 sNotify.itemNew.lParam = 0;
3160 sNotify.itemNew.cChildren = 0;
3161 sNotify.itemNew.pszText = (
LPTSTR) - 1;
3162 sNotify.itemNew.cchTextMax = -1;
3163 sNotify.ptDrag.x = 0;
3164 sNotify.ptDrag.y = 0;
3170 pData->uSelectedItem = 0;
3171 pData->uSelectedSub = 0;
3175 sNotify.itemNew.mask = 0;
3178 sNotify.itemOld.lParam =
pEntry->lParam;
3179 sNotify.itemOld.pszText = (
LPTSTR) - 1;
3180 sNotify.itemNew.stateMask = 0xFFFFFFFF;
3181 sNotify.itemNew.state =
pEntry->uState;
3182 sNotify.itemOld.cchTextMax = -1;
3183 sNotify.ptDrag.x = 0;
3184 sNotify.ptDrag.y = 0;
3194 if(uItem ==
pData->uTrackedItem) {
3195 pData->uTrackedItem = 0;
3196 pData->uTrackedSub = 0;
3199 if(
pData->uInsertMark == uItem) {
3200 pData->uInsertMark = 0;
3203 if(
pData->uSingleSel == uItem) {
3204 pData->uSingleSel = 0;
3228 pTemp->
bFlags &= ~TVIX_HASBUTTON;
3235 for(uPos = 1; uPos <
pData->uColumnCount; uPos++) {
3238 pExtra =
pList[uItem];
3246 delete(pExtra->
pText);
3261 uItem =
pEntry->uPrevItem;
3262 if(!uItem && !
pEntry->uNextItem) {
3267 uPos =
pData->pTreeItems[uItem]->uShowPos;
3278 if(
pData->uSelectedCount > 0) {
3279 pData->uSelectedCount--;
3284 pData->uTreeItemsCount--;
3286 iOff =
pData->uScrollY;
3287 iMax =
pData->uItemPosCount;
3288 iMax -=
pData->uPageEnties - 1;
3294 if(iOff != (
int)
pData->uScrollY) {
3295 pData->uScrollY = iOff;
3327 if(uItem ==
pData->uSelectedItem)
3333 sNotify.action =
iMode;
3336 sNotify.itemNew.stateMask = 0xFFFFFFFF;
3337 sNotify.itemNew.state =
pEntry->uState;
3338 sNotify.itemNew.lParam =
pEntry->lParam;
3339 sNotify.itemNew.cChildren = 0;
3340 sNotify.itemNew.pszText = (
LPTSTR) - 1;
3341 sNotify.itemNew.cchTextMax = -1;
3343 sNotify.itemOld.hItem =
NULL;
3344 sNotify.itemOld.stateMask = 0xFFFFFFFF;
3345 sNotify.itemOld.state = 0;
3346 sNotify.itemOld.lParam = 0;
3347 sNotify.itemOld.cChildren = 0;
3348 sNotify.itemOld.pszText = (
LPTSTR) - 1;
3349 sNotify.itemOld.cchTextMax = -1;
3350 sNotify.ptDrag.x = 0;
3351 sNotify.ptDrag.y = 0;
3366 sNotify.action =
iMode;
3369 sNotify.itemNew.stateMask = 0xFFFFFFFF;
3370 sNotify.itemNew.state =
pEntry->uState;
3371 sNotify.itemNew.lParam =
pEntry->lParam;
3372 sNotify.itemNew.cChildren = 0;
3373 sNotify.itemNew.pszText = (
LPTSTR) - 1;
3374 sNotify.itemNew.cchTextMax = -1;
3376 sNotify.itemOld.hItem =
NULL;
3377 sNotify.itemOld.stateMask = 0xFFFFFFFF;
3378 sNotify.itemOld.state = 0;
3379 sNotify.itemOld.lParam = 0;
3380 sNotify.itemOld.cChildren = 0;
3381 sNotify.itemOld.pszText = (
LPTSTR) - 1;
3382 sNotify.itemOld.cchTextMax = -1;
3383 sNotify.ptDrag.x = 0;
3384 sNotify.ptDrag.y = 0;
3402 pData->uSelectedCount++;
3404 pData->uSelectedCount--;
3425 if(!
pData->uFocusItem)
3428 uItem =
pData->uFocusItem;
3432 pEntry->bFlags &= ~TVIX_FOCUSED;
3434 uSub =
pData->uFocusSub;
3437 pExtra =
pData->pExtraItems[uSub - 1][uItem];
3439 pExtra->
bFlags &= ~TVIX_FOCUSED;
3445 pData->uFocusItem = 0;
3446 pData->uFocusSub = 0;
3467 if(
pData->uFocusItem) {
3468 if(uSub == 0xFFFFFFFF)
3469 uSub =
pData->uFocusSub;
3470 if(uItem == 0xFFFFFFFF)
3471 uItem =
pData->uFocusItem;
3473 if(uSub == 0xFFFFFFFF)
3474 uSub =
pData->uSelectedSub;
3475 if(uItem == 0xFFFFFFFF)
3476 uItem =
pData->uSelectedItem;
3479 if(
pData->uFocusItem == uItem)
3480 if(
pData->uFocusSub == uSub)
3489 if(uItem >
pData->uTreeItemsMax) {
3505 uTemp =
pData->uFocusItem;
3506 pTemp =
pData->pTreeItems[uTemp];
3509 pTemp->
bFlags &= ~TVIX_FOCUSED;
3510 uCol =
pData->uFocusSub;
3513 pExtra =
pData->pExtraItems[uCol - 1][uTemp];
3515 pExtra->
bFlags &= ~TVIX_FOCUSED;
3523 pExtra =
pData->pExtraItems[uSub - 1][uItem];
3530 pData->uFocusItem = uItem;
3531 pData->uFocusSub = uSub;
3534 if(
pData->uSelectedItem != uItem) {
3535 uTemp =
pData->uSelectedItem;
3536 uCol =
pData->uSelectedSub;
3539 uCol =
pData->uSelectedSub;
3542 pData->uSelectedItem = uItem;
3543 pData->uSelectedSub = uSub;
3605 uOld =
pData->uSelectedItem;
3606 uSub =
pData->uSelectedSub;
3608 if(uSubItem >=
pData->uColumnCount && uSubItem > 0)
3610 if(uItem >
pData->uTreeItemsMax)
3613 if(uSubItem == uSub)
3630 if(
pData->uSelectedCount > 1 &&
pData->uTreeItemsMax) {
3631 for(uPos =
pData->uTreeItemsMax; uPos; uPos--) {
3636 if(!
pData->uSelectedCount)
3642 iMode &= ~TVC_ONLYFOCUS;
3661 pExtra =
pData->pExtraItems[uSubItem - 1][uItem];
3663 uState |= pExtra->
uState;
3667 pTemp =
pData->pTreeItems[uOld];
3677 pExtra =
pData->pExtraItems[uSub - 1][uOld];
3679 uStOld |= pExtra->
uState;
3684 sNotify.action =
iMode;
3687 sNotify.itemNew.stateMask = 0xFFFFFFFF;
3688 sNotify.itemNew.state = uState;
3689 sNotify.itemNew.lParam =
lParam;
3690 sNotify.itemNew.cChildren = uSubItem;
3691 sNotify.itemNew.pszText = (
LPTSTR) - 1;
3692 sNotify.itemNew.cchTextMax = -1;
3695 sNotify.itemOld.stateMask = 0xFFFFFFFF;
3696 sNotify.itemOld.state = uStOld;
3697 sNotify.itemNew.lParam = lPaOld;
3698 sNotify.itemOld.cChildren = uSub;
3699 sNotify.itemOld.pszText = (
LPTSTR) - 1;
3700 sNotify.itemOld.cchTextMax = -1;
3701 sNotify.ptDrag.x = 0;
3702 sNotify.ptDrag.y = 0;
3721 uOld =
pData->uSelectedItem;
3722 pTemp =
pData->pTreeItems[uOld];
3735 uStOld &= ~TVIS_SELECTED;
3736 pTemp->
uState &= ~TVIS_SELECTED;
3738 if(
pData->uSelectedCount > 0) {
3739 pData->uSelectedCount -= 1;
3743 pData->uSelectedSub = 0;
3744 pData->uSelectedItem = 0;
3753 uState &= ~TVIS_SELECTED;
3754 pEntry->uState &= ~TVIS_SELECTED;
3755 if(
pData->uSelectedCount)
3756 pData->uSelectedCount--;
3762 pData->uSelectedCount += 1;
3766 if(uSubItem && uSubItem < pData->uColumnCount) {
3767 pExtra =
pData->pExtraItems[uSubItem - 1][uItem];
3773 pData->pExtraItems[uSubItem - 1][uItem] = pExtra;
3789 pData->uSelectedSub = uSubItem;
3790 pData->uSelectedItem = uItem;
3792 pData->uSelectedItem = 0;
3793 pData->uSelectedSub = 0;
3798 sNotify.action =
iMode;
3801 sNotify.itemNew.stateMask = 0xFFFFFFFF;
3802 sNotify.itemNew.state = uState;
3803 sNotify.itemNew.lParam =
lParam;
3804 sNotify.itemNew.cChildren = uSubItem;
3805 sNotify.itemNew.pszText = (
LPTSTR) - 1;
3806 sNotify.itemNew.cchTextMax = -1;
3809 sNotify.itemOld.stateMask = 0xFFFFFFFF;
3810 sNotify.itemOld.state = uStOld;
3811 sNotify.itemOld.lParam = lPaOld;
3812 sNotify.itemOld.cChildren = uSub;
3813 sNotify.itemOld.pszText = (
LPTSTR) - 1;
3814 sNotify.itemOld.cchTextMax = -1;
3815 sNotify.ptDrag.x = 0;
3816 sNotify.ptDrag.y = 0;
3824 if(
pData->uSelectedItem) {
3836 sNotify.action =
iMode;
3839 sNotify.itemNew.stateMask = 0xFFFFFFFF;
3841 sNotify.itemNew.cChildren = 0;
3842 sNotify.itemNew.pszText = (
LPTSTR) - 1;
3843 sNotify.itemNew.cchTextMax = -1;
3846 sNotify.itemOld.stateMask = 0xFFFFFFFF;
3847 sNotify.itemOld.state = (pTemp) ? pTemp->
uState : 0;
3848 sNotify.itemOld.cChildren = 0;
3849 sNotify.itemOld.pszText = (
LPTSTR) - 1;
3850 sNotify.itemOld.cchTextMax = -1;
3851 sNotify.ptDrag.x = 0;
3852 sNotify.ptDrag.y = 0;
3859 pTemp =
pData->pTreeItems[uOld ];
3890 pTemp =
pData->pTreeItems[uNext];
3903 pTemp =
pData->pTreeItems[uNext];
3927 if(
pData->uSelectedItem) {
3957 uItem =
pData->uFirstChild;
3959 if(uItem >
pData->uTreeItemsMax)
3963 if(!
pData->pTreeItems[uItem]) {
3979 uItem =
pEntry->uFirstChild;
3985 uItem =
pEntry->uNextItem;
4014 PFNTVSORTEX pCompare;
4042 if(
pData->cLockChanges)
4045 uParent =
U(pInsert->hParent);
4046 if(uParent >
pData->uTreeItemsMax) {
4061 if(
pData->uTreeItemsCount + 1 >
pData->uTreeItemsMax) {
4062 pPosOld =
pData->pItemPos;
4063 pOld =
pData->pTreeItems;
4064 uMax =
pData->uTreeItemsMax;
4065 uMax +=
pData->uTreeItemsMax / 2;
4079 for(uPos = 1; uPos <
pData->uColumnCount; uPos++) {
4080 pExOld[uPos] =
pData->pExtraItems[uPos - 1];
4081 pExNew[uPos] =
new(
ExtraItem*, uMax + 1);
4084 for(uPos--; uPos > 0; uPos--)
4085 delete(pExNew[uPos]);
4094 memcpy(pPosNew,
pData->pItemPos ,
sizeof(
unsigned) * (
pData->uTreeItemsCount));
4095 memset(pPosNew +
pData->uTreeItemsCount, 0,
sizeof(
unsigned) * (uMax -
pData->uTreeItemsCount));
4097 for(uPos = 1; uPos <
pData->uColumnCount; uPos++) {
4100 pData->pExtraItems[uPos - 1] = pExNew[uPos];
4101 delete(pExOld[uPos]);
4104 pData->uTreeItemsMax = uMax;
4106 pData->pItemPos = pPosNew;
4113 uPos =
pData->uNextSeachPos + 1;
4121 if(
pData->uUserDataSize) {
4126 if(uPos >
pData->uTreeItemsMax)
4132 pData->uNextSeachPos = uPos;
4138 uBits = pInsert->item.mask;
4141 pNew->
uState = pInsert->item.state & pInsert->item.stateMask;
4150 pNew->
lParam = pInsert->item.lParam;
4154 pNew->
iImage = pInsert->item.iImage;
4166 switch(pInsert->item.cChildren) {
4185 pNew->
uState &= ~TVIS_EXPANDED;
4208 uFirst = 0xFFFFFFFF;
4209 pFirst = &
pData->uFirstChild;
4210 pLast = &
pData->uLastChild;
4214 uFirst =
pParent->uFirstChild;
4215 pFirst = &
pParent->uFirstChild;
4225 uAfter =
U(pInsert->hInsertAfter);
4239 uFirst = 0xFFFFFFFF;
4240 pFirst = &
pData->uFirstChild;
4241 pLast = &
pData->uLastChild;
4245 uFirst =
pParent->uFirstChild;
4246 pFirst = &
pParent->uFirstChild;
4255 uAfter =
pEntry->uPrevItem;
4263 pEntry->uPrevItem = uPos;
4277 pFirst = &
pData->uFirstChild;
4278 pLast = &
pData->uLastChild;
4283 pEntry->uNextItem = uPos;
4312 pData->cLockChanges = 1;
4314 pCompare = (PFNTVSORTEX)(pInsert->item.hItem);
4323 uNext =
pItems[uNext]->uNextItem;
4327 iShift = iCount / 2;
4331 uNext =
pItems[uNext]->uNextItem;
4342 pTextTemp =
pEntry->pText;
4347 iCount -= (iCount + 1) / 2;
4352 iCount -= iCount / 2 + 1;
4354 uItem =
pItems[uNext]->uNextItem;
4358 uBefore =
pEntry->uPrevItem;
4363 pData->cLockChanges = 0;
4370 pEntry->uNextItem = uPos;
4377 pEntry->uPrevItem = uPos;
4400 pData->cLockChanges = 1;
4408 uNext =
pItems[uNext]->uNextItem;
4412 iShift = iCount / 2;
4416 uNext =
pItems[uNext]->uNextItem;
4428 pTextTemp =
pEntry->pText;
4434 iCount -= (iCount + 1) / 2;
4439 iCount -= iCount / 2 + 1;
4441 uItem =
pItems[uNext]->uNextItem;
4445 uBefore =
pEntry->uPrevItem;
4451 pData->cLockChanges = 0;
4458 pEntry->uNextItem = uPos;
4465 pEntry->uPrevItem = uPos;
4483 uFirst = 0xFFFFFFFF;
4484 pFirst = &
pData->uFirstChild;
4485 pLast = &
pData->uLastChild;
4489 uFirst =
pParent->uFirstChild;
4490 pFirst = &
pParent->uFirstChild;
4509 if(uAfter >
pData->uTreeItemsMax) {
4510 if((uAfter & 0xFFF00000) == 0xFFE00000) {