- Timestamp:
- May 22, 2001, 3:35:04 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/listview.c
r5778 r5780 7 7 * 8 8 * NOTES 9 * Listview control implementation. 9 * Listview control implementation. 10 10 * 11 11 * TODO: … … 19 19 * Data structure: 20 20 * LISTVIEW_SetItemCount : not completed for non OWNERDATA 21 * 21 * 22 22 * Unicode: 23 23 * LISTVIEW_SetItemW : no unicode support … … 30 30 * LISTVIEW_GetNumberOfWorkAreas : not implemented 31 31 * LISTVIEW_GetHotCursor : not implemented 32 * LISTVIEW_GetISearchString : not implemented 32 * LISTVIEW_GetISearchString : not implemented 33 33 * LISTVIEW_GetBkImage : not implemented 34 34 * LISTVIEW_SetBkImage : not implemented … … 37 37 * LISTVIEW_Arrange : empty stub 38 38 * LISTVIEW_ApproximateViewRect : incomplete 39 * LISTVIEW_Scroll : not implemented 39 * LISTVIEW_Scroll : not implemented 40 40 * LISTVIEW_Update : not completed 41 41 */ … … 71 71 DEFAULT_DEBUG_CHANNEL(listview); 72 72 73 /* Some definitions for inline edit control */ 73 /* Some definitions for inline edit control */ 74 74 typedef BOOL (*EditlblCallback)(HWND, LPSTR, DWORD); 75 75 … … 164 164 165 165 /* 166 * constants 166 * constants 167 167 */ 168 168 … … 190 190 191 191 /* default column width for items in list display mode */ 192 #define DEFAULT_COLUMN_WIDTH 96 192 #define DEFAULT_COLUMN_WIDTH 96 193 193 194 194 /* Increment size of the horizontal scroll bar */ … … 203 203 /* Border for the icon caption */ 204 204 #define CAPTION_BORDER 2 205 /* 205 /* 206 206 * macros 207 207 */ … … 213 213 #define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount) 214 214 215 HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y, 216 INT width, INT height, HWND parent, HINSTANCE hinst, 217 218 219 /* 220 * forward declarations 215 HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y, 216 INT width, INT height, HWND parent, HINSTANCE hinst, 217 EditlblCallback EditLblCb, DWORD param); 218 219 /* 220 * forward declarations 221 221 */ 222 222 static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem, BOOL internal); … … 311 311 static BOOL 312 312 LISTVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc, 313 UINT iItem, UINT iSubItem, 313 UINT iItem, UINT iSubItem, 314 314 UINT uItemDrawState) 315 315 { … … 372 372 373 373 /************************************************************************* 374 * 375 * 376 * Processes keyboard messages generated by pressing the letter keys 374 * LISTVIEW_ProcessLetterKeys 375 * 376 * Processes keyboard messages generated by pressing the letter keys 377 377 * on the keyboard. 378 * What this does is perform a case insensitive search from the 378 * What this does is perform a case insensitive search from the 379 379 * current position with the following quirks: 380 * - If two chars or more are pressed in quick succession we search 380 * - If two chars or more are pressed in quick succession we search 381 381 * for the corresponding string (e.g. 'abc'). 382 * - If there is a delay we wipe away the current search string and 382 * - If there is a delay we wipe away the current search string and 383 383 * restart with just that char. 384 * - If the user keeps pressing the same character, whether slowly or 385 * fast, so that the search string is entirely composed of this 386 * character ('aaaaa' for instance), then we search for first item 384 * - If the user keeps pressing the same character, whether slowly or 385 * fast, so that the search string is entirely composed of this 386 * character ('aaaaa' for instance), then we search for first item 387 387 * that starting with that character. 388 * - If the user types the above character in quick succession, then 389 * we must also search for the corresponding string ('aaaaa'), and 388 * - If the user types the above character in quick succession, then 389 * we must also search for the corresponding string ('aaaaa'), and 390 390 * go to that string if there is a match. 391 391 * … … 396 396 * BUGS 397 397 * 398 * - The current implementation has a list of characters it will 399 * accept and it ignores averything else. In particular it will 400 * ignore accentuated characters which seems to match what 401 * Windows does. But I'm not sure it makes sense to follow 398 * - The current implementation has a list of characters it will 399 * accept and it ignores averything else. In particular it will 400 * ignore accentuated characters which seems to match what 401 * Windows does. But I'm not sure it makes sense to follow 402 402 * Windows there. 403 403 * - We don't sound a beep when the search fails. … … 526 526 527 527 /************************************************************************* 528 * LISTVIEW_UpdateHeaderSize [Internal] 528 * LISTVIEW_UpdateHeaderSize [Internal] 529 529 * 530 530 * Function to resize the header control … … 567 567 /*** 568 568 * DESCRIPTION: 569 * Update the scrollbars. This functions should be called whenever 569 * Update the scrollbars. This functions should be called whenever 570 570 * the content, size or view changes. 571 * 571 * 572 572 * PARAMETER(S): 573 573 * [I] HWND : window handle … … 578 578 static VOID LISTVIEW_UpdateScroll(HWND hwnd) 579 579 { 580 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 580 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 581 581 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 582 582 UINT uView = lStyle & LVS_TYPEMASK; … … 619 619 /* update horizontal scrollbar */ 620 620 nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 621 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE 621 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE 622 622 || GETITEMCOUNT(infoPtr) == 0) 623 623 { 624 624 scrollInfo.nPos = 0; 625 } 625 } 626 626 scrollInfo.nMin = 0; 627 scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE ; 627 scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE ; 628 628 scrollInfo.nPage = nListWidth / LISTVIEW_SCROLL_DIV_SIZE; 629 629 scrollInfo.nMax = max(infoPtr->nItemWidth / LISTVIEW_SCROLL_DIV_SIZE, 0)-1; 630 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 630 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 631 631 632 632 /* Update the Header Control */ … … 679 679 * Prints a message for unsupported window styles. 680 680 * A kind of TODO list for window styles. 681 * 681 * 682 682 * PARAMETER(S): 683 683 * [I] LONG : window style … … 732 732 * DESCRIPTION: 733 733 * Aligns the items with the top edge of the window. 734 * 734 * 735 735 * PARAMETER(S): 736 736 * [I] HWND : window handle … … 747 747 RECT rcView; 748 748 INT i; 749 749 750 750 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 751 751 { 752 752 ZeroMemory(&ptItem, sizeof(POINT)); 753 753 ZeroMemory(&rcView, sizeof(RECT)); 754 754 755 755 if (nListWidth > infoPtr->nItemWidth) 756 756 { … … 762 762 ptItem.y += infoPtr->nItemHeight; 763 763 } 764 764 765 765 ListView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 766 766 ptItem.x += infoPtr->nItemWidth; … … 789 789 * DESCRIPTION: 790 790 * Aligns the items with the left edge of the window. 791 * 791 * 792 792 * PARAMETER(S): 793 793 * [I] HWND : window handle … … 804 804 RECT rcView; 805 805 INT i; 806 806 807 807 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 808 808 { … … 846 846 * DESCRIPTION: 847 847 * Set the bounding rectangle of all the items. 848 * 848 * 849 849 * PARAMETER(S): 850 850 * [I] HWND : window handle … … 860 860 BOOL bResult = FALSE; 861 861 862 TRACE("(hwnd=%x, left=%d, top=%d, right=%d, bottom=%d)\n", hwnd, 862 TRACE("(hwnd=%x, left=%d, top=%d, right=%d, bottom=%d)\n", hwnd, 863 863 lprcView->left, lprcView->top, lprcView->right, lprcView->bottom); 864 864 865 865 if (lprcView != NULL) 866 866 { … … 878 878 * DESCRIPTION: 879 879 * Retrieves the bounding rectangle of all the items. 880 * 880 * 881 881 * PARAMETER(S): 882 882 * [I] HWND : window handle … … 906 906 } 907 907 908 TRACE("(left=%d, top=%d, right=%d, bottom=%d)\n", 908 TRACE("(left=%d, top=%d, right=%d, bottom=%d)\n", 909 909 lprcView->left, lprcView->top, lprcView->right, lprcView->bottom); 910 910 } … … 916 916 * DESCRIPTION: 917 917 * Retrieves the subitem pointer associated with the subitem index. 918 * 918 * 919 919 * PARAMETER(S): 920 920 * [I] HDPA : DPA handle for a specific item … … 925 925 * FAILURE : NULL 926 926 */ 927 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItemPtr(HDPA hdpaSubItems, 927 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItemPtr(HDPA hdpaSubItems, 928 928 INT nSubItem) 929 929 { … … 949 949 * DESCRIPTION: 950 950 * Calculates the width of an item. 951 * 951 * 952 952 * PARAMETER(S): 953 953 * [I] HWND : window handle … … 960 960 { 961 961 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 962 LONG style = GetWindowLongA(hwnd, GWL_STYLE); 963 UINT uView = style & LVS_TYPEMASK; 962 LONG style = GetWindowLongA(hwnd, GWL_STYLE); 963 UINT uView = style & LVS_TYPEMASK; 964 964 INT nHeaderItemCount; 965 965 RECT rcHeaderItem; … … 989 989 { 990 990 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 991 { 991 { 992 992 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, i); 993 993 nItemWidth = max(nItemWidth, nLabelWidth); 994 994 } 995 995 996 996 /* default label size */ 997 997 if (GETITEMCOUNT(infoPtr) == 0) … … 1009 1009 /* add padding */ 1010 1010 nItemWidth += WIDTH_PADDING; 1011 1011 1012 1012 if (infoPtr->himlSmall != NULL) 1013 1013 { … … 1033 1033 * DESCRIPTION: 1034 1034 * Calculates the width of a specific item. 1035 * 1036 * PARAMETER(S): 1037 * [I] HWND : window handle 1038 * [I] LPSTR : string 1035 * 1036 * PARAMETER(S): 1037 * [I] HWND : window handle 1038 * [I] LPSTR : string 1039 1039 * 1040 1040 * RETURN: … … 1088 1088 /* add padding */ 1089 1089 nItemWidth += WIDTH_PADDING; 1090 1090 1091 1091 if (infoPtr->himlSmall != NULL) 1092 1092 { … … 1101 1101 } 1102 1102 } 1103 1103 1104 1104 return nItemWidth; 1105 1105 } … … 1108 1108 * DESCRIPTION: 1109 1109 * Calculates the height of an item. 1110 * 1110 * 1111 1111 * PARAMETER(S): 1112 1112 * [I] HWND : window handle … … 1119 1119 { 1120 1120 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 1121 #ifdef __WIN32OS2__ 1122 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); 1123 UINT uView = dwStyle & LVS_TYPEMASK; 1124 #else 1121 1125 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 1126 #endif 1122 1127 INT nItemHeight = 0; 1123 1128 … … 1128 1133 else 1129 1134 { 1130 TEXTMETRICA tm; 1135 TEXTMETRICA tm; 1131 1136 HDC hdc = GetDC(hwnd); 1132 1137 HFONT hOldFont = SelectObject(hdc, infoPtr->hFont); … … 1140 1145 SelectObject(hdc, hOldFont); 1141 1146 ReleaseDC(hwnd, hdc); 1147 #ifdef __WIN32OS2__ 1148 if(dwStyle & LVS_OWNERDRAWFIXED) { 1149 /* Get item height */ 1150 1151 MEASUREITEMSTRUCT mis; 1152 UINT id = GetWindowLongA(hwnd,GWL_ID); 1153 1154 mis.CtlType = ODT_LISTVIEW; 1155 mis.CtlID = id; 1156 mis.itemID = 0; 1157 mis.itemData = 0; //TODO:!!!! 1158 mis.itemHeight = nItemHeight; 1159 SendMessageA(GetParent(hwnd), WM_MEASUREITEM, id, (LPARAM)&mis ); 1160 nItemHeight = mis.itemHeight; 1161 } 1162 #endif 1142 1163 } 1143 1164 … … 1175 1196 * 0 : if Item 1 == Item 2 1176 1197 */ 1177 static INT CALLBACK LISTVIEW_CompareSelectionRanges(LPVOID range1, LPVOID range2, 1198 static INT CALLBACK LISTVIEW_CompareSelectionRanges(LPVOID range1, LPVOID range2, 1178 1199 LPARAM flags) 1179 1200 { … … 1181 1202 int l2 = ((LISTVIEW_SELECTION*)(range2))->lower; 1182 1203 int u1 = ((LISTVIEW_SELECTION*)(range1))->upper; 1183 int u2 = ((LISTVIEW_SELECTION*)(range2))->upper; 1204 int u2 = ((LISTVIEW_SELECTION*)(range2))->upper; 1184 1205 int rc=0; 1185 1206 1186 1207 if (u1 < l2) 1187 1208 rc= -1; 1188 1209 1189 1210 if (u2 < l1) 1190 1211 rc= 1; … … 1196 1217 * DESCRIPTION: 1197 1218 * Adds a selection range. 1198 * 1219 * 1199 1220 * PARAMETER(S): 1200 1221 * [I] HWND : window handle 1201 1222 * [I] INT : lower item index 1202 * [I] INT : upper item index 1223 * [I] INT : upper item index 1203 1224 * 1204 1225 * RETURN: … … 1234 1255 LISTVIEW_CompareSelectionRanges, 1235 1256 0,0); 1236 selection->upper --; 1257 selection->upper --; 1237 1258 if (lowerzero) 1238 1259 lowerzero=FALSE; … … 1245 1266 TRACE("Merge with index %i (%lu - %lu)\n",index,checkselection->lower, 1246 1267 checkselection->upper); 1247 1268 1248 1269 checkselection->lower = min(selection->lower,checkselection->lower); 1249 1270 checkselection->upper = max(selection->upper,checkselection->upper); 1250 1251 TRACE("New range (%lu - %lu)\n", checkselection->lower, 1271 1272 TRACE("New range (%lu - %lu)\n", checkselection->lower, 1252 1273 checkselection->upper); 1253 1274 1254 COMCTL32_Free(selection); 1255 1275 COMCTL32_Free(selection); 1276 1256 1277 /* merge now common selection ranges in the lower group*/ 1257 1278 do 1258 1279 { 1259 checkselection->upper ++; 1280 checkselection->upper ++; 1260 1281 if (checkselection->lower == 0) 1261 1282 lowerzero = TRUE; … … 1263 1284 checkselection->lower --; 1264 1285 1265 TRACE("search lower range (%lu - %lu)\n", checkselection->lower, 1286 TRACE("search lower range (%lu - %lu)\n", checkselection->lower, 1266 1287 checkselection->upper); 1267 1288 … … 1271 1292 0); 1272 1293 1273 checkselection->upper --; 1294 checkselection->upper --; 1274 1295 if (lowerzero) 1275 1296 lowerzero = FALSE; 1276 1297 else 1277 1278 1279 1280 { 1281 1298 checkselection->lower ++; 1299 1300 if (mergeindex >=0 && mergeindex != index) 1301 { 1302 TRACE("Merge with index %i\n",mergeindex); 1282 1303 checkselection2 = DPA_GetPtr(infoPtr->hdpaSelectionRanges, 1283 1304 mergeindex); 1284 checkselection->lower = min(checkselection->lower, 1305 checkselection->lower = min(checkselection->lower, 1285 1306 checkselection2->lower); 1286 1307 checkselection->upper = max(checkselection->upper, … … 1299 1320 if (checkselection->lower == 0) 1300 1321 lowerzero = TRUE; 1301 else 1322 else 1302 1323 checkselection->lower --; 1303 1324 1304 TRACE("search upper range %i (%lu - %lu)\n",index, 1325 TRACE("search upper range %i (%lu - %lu)\n",index, 1305 1326 checkselection->lower, checkselection->upper); 1306 1327 … … 1308 1329 mergeindex = DPA_Search(infoPtr->hdpaSelectionRanges, checkselection, 1309 1330 index+1, 1310 1311 1312 1313 checkselection->upper --; 1331 LISTVIEW_CompareSelectionRanges, 0, 1332 0); 1333 1334 checkselection->upper --; 1314 1335 if (lowerzero) 1315 1336 lowerzero = FALSE; … … 1319 1340 if (mergeindex >=0 && mergeindex !=index) 1320 1341 { 1321 1322 1323 1324 checkselection->lower = min(checkselection->lower, 1325 1326 1327 1328 1329 1342 TRACE("Merge with index %i\n",mergeindex); 1343 checkselection2 = DPA_GetPtr(infoPtr->hdpaSelectionRanges, 1344 mergeindex); 1345 checkselection->lower = min(checkselection->lower, 1346 checkselection2->lower); 1347 checkselection->upper = max(checkselection->upper, 1348 checkselection2->upper); 1349 COMCTL32_Free(checkselection2); 1350 DPA_DeletePtr(infoPtr->hdpaSelectionRanges,mergeindex); 1330 1351 } 1331 1352 } … … 1336 1357 1337 1358 index = DPA_Search(infoPtr->hdpaSelectionRanges, selection, 0, 1338 LISTVIEW_CompareSelectionRanges, 0, 1359 LISTVIEW_CompareSelectionRanges, 0, 1339 1360 DPAS_INSERTAFTER); 1340 1361 … … 1342 1363 if (index == -1) 1343 1364 index = 0; 1344 DPA_InsertPtr(infoPtr->hdpaSelectionRanges,index,selection); 1365 DPA_InsertPtr(infoPtr->hdpaSelectionRanges,index,selection); 1345 1366 } 1346 } 1367 } 1347 1368 else 1348 1369 { … … 1350 1371 } 1351 1372 /* 1352 * Incase of error 1373 * Incase of error 1353 1374 */ 1354 1375 DPA_Sort(infoPtr->hdpaSelectionRanges,LISTVIEW_CompareSelectionRanges,0); … … 1359 1380 * DESCRIPTION: 1360 1381 * check if a specified index is selected. 1361 * 1382 * 1362 1383 * PARAMETER(S): 1363 1384 * [I] HWND : window handle 1364 * [I] INT : item index 1385 * [I] INT : item index 1365 1386 * 1366 1387 * RETURN: … … 1402 1423 INT i; 1403 1424 LVITEMA item; 1404 1425 1405 1426 TRACE("(0x%x)\n",hwnd); 1406 1427 … … 1418 1439 LISTVIEW_RemoveSelectionRange(hwnd,selection->lower,selection->upper); 1419 1440 } 1420 } 1441 } 1421 1442 while (infoPtr->hdpaSelectionRanges->nItemCount>0); 1422 1443 1423 1444 TRACE("done\n"); 1424 return TRUE; 1445 return TRUE; 1425 1446 } 1426 1447 … … 1428 1449 * DESCRIPTION: 1429 1450 * Removes a range selections. 1430 * 1451 * 1431 1452 * PARAMETER(S): 1432 1453 * [I] HWND : window handle 1433 1454 * [I] INT : lower item index 1434 * [I] INT : upper item index 1455 * [I] INT : upper item index 1435 1456 * 1436 1457 * RETURN: … … 1452 1473 LISTVIEW_CompareSelectionRanges, 1453 1474 0,0); 1454 1475 1455 1476 if (index == -1) 1456 1477 return; 1457 1478 1458 1479 1459 1480 checkselection = DPA_GetPtr(infoPtr->hdpaSelectionRanges, 1460 1481 index); … … 1464 1485 1465 1486 /* case 1: Same */ 1466 if ((checkselection->upper == removeselection.upper) && 1487 if ((checkselection->upper == removeselection.upper) && 1467 1488 (checkselection->lower == removeselection.lower)) 1468 1489 { … … 1471 1492 } 1472 1493 /* case 2: engulf */ 1473 else if (((checkselection->upper < removeselection.upper) && 1494 else if (((checkselection->upper < removeselection.upper) && 1474 1495 (checkselection->lower > removeselection.lower))|| 1475 1496 ((checkselection->upper <= removeselection.upper) && … … 1509 1530 /* bisect the range */ 1510 1531 LISTVIEW_SELECTION *newselection; 1511 1532 1512 1533 newselection = (LISTVIEW_SELECTION *) 1513 1534 COMCTL32_Alloc(sizeof(LISTVIEW_SELECTION)); … … 1525 1546 * DESCRIPTION: 1526 1547 * Updates the various indices after an item has been inserted or deleted. 1527 * 1548 * 1528 1549 * PARAMETER(S): 1529 1550 * [I] HWND : window handle 1530 * [I] INT : item index 1551 * [I] INT : item index 1531 1552 * [I] INT : Direction of shift, +1 or -1. 1532 1553 * … … 1549 1570 0,DPAS_SORTED|DPAS_INSERTAFTER); 1550 1571 1551 while ((index < infoPtr->hdpaSelectionRanges->nItemCount)&&(index != -1)) 1572 while ((index < infoPtr->hdpaSelectionRanges->nItemCount)&&(index != -1)) 1552 1573 { 1553 1574 checkselection = DPA_GetPtr(infoPtr->hdpaSelectionRanges,index); … … 1593 1614 * DESCRIPTION: 1594 1615 * Adds a block of selections. 1595 * 1596 * PARAMETER(S): 1597 * [I] HWND : window handle 1598 * [I] INT : item index 1616 * 1617 * PARAMETER(S): 1618 * [I] HWND : window handle 1619 * [I] INT : item index 1599 1620 * 1600 1621 * RETURN: … … 1629 1650 * DESCRIPTION: 1630 1651 * Adds a single selection. 1631 * 1632 * PARAMETER(S): 1633 * [I] HWND : window handle 1634 * [I] INT : item index 1652 * 1653 * PARAMETER(S): 1654 * [I] HWND : window handle 1655 * [I] INT : item index 1635 1656 * 1636 1657 * RETURN: … … 1655 1676 * DESCRIPTION: 1656 1677 * Selects or unselects an item. 1657 * 1658 * PARAMETER(S): 1659 * [I] HWND : window handle 1660 * [I] INT : item index 1661 * 1662 * RETURN: 1663 * SELECT: TRUE 1678 * 1679 * PARAMETER(S): 1680 * [I] HWND : window handle 1681 * [I] INT : item index 1682 * 1683 * RETURN: 1684 * SELECT: TRUE 1664 1685 * UNSELECT : FALSE 1665 1686 */ … … 1675 1696 if (LISTVIEW_IsSelected(hwnd,nItem)) 1676 1697 { 1677 1698 1678 1699 LISTVIEW_SetItemState(hwnd,nItem,&item); 1679 1700 bResult = FALSE; … … 1694 1715 /*** 1695 1716 * DESCRIPTION: 1696 * Selects items based on view coordinates. 1697 * 1698 * PARAMETER(S): 1699 * [I] HWND : window handle 1700 * [I] RECT : selection rectangle 1717 * Selects items based on view coordinates. 1718 * 1719 * PARAMETER(S): 1720 * [I] HWND : window handle 1721 * [I] RECT : selection rectangle 1701 1722 * 1702 1723 * RETURN: … … 1733 1754 * DESCRIPTION: 1734 1755 * Sets a single group selection. 1735 * 1736 * PARAMETER(S): 1737 * [I] HWND : window handle 1738 * [I] INT : item index 1739 * 1740 * RETURN: 1741 * None 1756 * 1757 * PARAMETER(S): 1758 * [I] HWND : window handle 1759 * [I] INT : item index 1760 * 1761 * RETURN: 1762 * None 1742 1763 */ 1743 1764 static VOID LISTVIEW_SetGroupSelection(HWND hwnd, INT nItem) … … 1799 1820 * DESCRIPTION: 1800 1821 * Manages the item focus. 1801 * 1802 * PARAMETER(S): 1803 * [I] HWND : window handle 1804 * [I] INT : item index 1822 * 1823 * PARAMETER(S): 1824 * [I] HWND : window handle 1825 * [I] INT : item index 1805 1826 * 1806 1827 * RETURN: … … 1823 1844 ZeroMemory(&lvItem, sizeof(LVITEMA)); 1824 1845 lvItem.stateMask = LVIS_FOCUSED; 1825 ListView_SetItemState(hwnd, oldFocus, &lvItem); 1846 ListView_SetItemState(hwnd, oldFocus, &lvItem); 1826 1847 1827 1848 } … … 1834 1855 ListView_EnsureVisible(hwnd, nItem, FALSE); 1835 1856 } 1836 1837 return bResult; 1857 1858 return bResult; 1838 1859 } 1839 1860 … … 1841 1862 * DESCRIPTION: 1842 1863 * Sets a single selection. 1843 * 1844 * PARAMETER(S): 1845 * [I] HWND : window handle 1846 * [I] INT : item index 1864 * 1865 * PARAMETER(S): 1866 * [I] HWND : window handle 1867 * [I] INT : item index 1847 1868 * 1848 1869 * RETURN: … … 1856 1877 ZeroMemory(&lvItem, sizeof(LVITEMA)); 1857 1878 lvItem.stateMask = LVIS_FOCUSED; 1858 ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem); 1879 ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem); 1859 1880 1860 1881 LISTVIEW_RemoveAllSelections(hwnd); … … 1871 1892 * DESCRIPTION: 1872 1893 * Set selection(s) with keyboard. 1873 * 1874 * PARAMETER(S): 1875 * [I] HWND : window handle 1876 * [I] INT : item index 1894 * 1895 * PARAMETER(S): 1896 * [I] HWND : window handle 1897 * [I] INT : item index 1877 1898 * 1878 1899 * RETURN: … … 1893 1914 { 1894 1915 bResult = TRUE; 1895 LISTVIEW_SetSelection(hwnd, nItem); 1916 LISTVIEW_SetSelection(hwnd, nItem); 1896 1917 ListView_EnsureVisible(hwnd, nItem, FALSE); 1897 1918 } … … 1901 1922 { 1902 1923 bResult = TRUE; 1903 LISTVIEW_SetGroupSelection(hwnd, nItem); 1924 LISTVIEW_SetGroupSelection(hwnd, nItem); 1904 1925 } 1905 1926 else if (wCtrl) … … 1910 1931 { 1911 1932 bResult = TRUE; 1912 LISTVIEW_SetSelection(hwnd, nItem); 1933 LISTVIEW_SetSelection(hwnd, nItem); 1913 1934 ListView_EnsureVisible(hwnd, nItem, FALSE); 1914 1935 } … … 1935 1956 * LVS_EX_TRACKSELECT: An item is automatically selected when the cursor remains 1936 1957 * over the item for a certain period of time. 1937 * 1958 * 1938 1959 */ 1939 1960 static LRESULT LISTVIEW_MouseHover(HWND hwnd, WPARAM wParam, LPARAM lParam) … … 1969 1990 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 1970 1991 TRACKMOUSEEVENT trackinfo; 1971 1992 1972 1993 /* see if we are supposed to be tracking mouse hovering */ 1973 1994 if(infoPtr->dwExStyle & LVS_EX_TRACKSELECT) { … … 1988 2009 } 1989 2010 } 1990 2011 1991 2012 return 0; 1992 2013 } … … 1995 2016 * DESCRIPTION: 1996 2017 * Selects an item based on coordinates. 1997 * 2018 * 1998 2019 * PARAMETER(S): 1999 2020 * [I] HWND : window handle … … 2015 2036 if (uView == LVS_REPORT) 2016 2037 { 2017 bottomindex = topindex + LISTVIEW_GetCountPerColumn(hwnd) + 1; 2038 bottomindex = topindex + LISTVIEW_GetCountPerColumn(hwnd) + 1; 2018 2039 bottomindex = min(bottomindex,GETITEMCOUNT(infoPtr)); 2019 2040 } … … 2023 2044 } 2024 2045 2025 for (i = topindex; i < bottomindex; i++) 2046 for (i = topindex; i < bottomindex; i++) 2026 2047 { 2027 2048 rcItem.left = LVIR_SELECTBOUNDS; … … 2041 2062 * DESCRIPTION: 2042 2063 * Removes a column. 2043 * 2064 * 2044 2065 * PARAMETER(S): 2045 2066 * [IO] HDPA : dynamic pointer array handle … … 2067 2088 } 2068 2089 } 2069 2090 2070 2091 return bResult; 2071 2092 } … … 2074 2095 * DESCRIPTION: 2075 2096 * Removes a subitem at a given position. 2076 * 2097 * 2077 2098 * PARAMETER(S): 2078 2099 * [IO] HDPA : dynamic pointer array handle … … 2096 2117 { 2097 2118 /* free string */ 2098 if ((lpSubItem->pszText != NULL) && 2119 if ((lpSubItem->pszText != NULL) && 2099 2120 (lpSubItem->pszText != LPSTR_TEXTCALLBACKA)) 2100 2121 { 2101 2122 COMCTL32_Free(lpSubItem->pszText); 2102 2123 } 2103 2124 2104 2125 /* free item */ 2105 2126 COMCTL32_Free(lpSubItem); … … 2116 2137 } 2117 2138 } 2118 } 2119 2139 } 2140 2120 2141 return TRUE; 2121 2142 } … … 2124 2145 * DESCRIPTION: 2125 2146 * Compares the item information. 2126 * 2127 * PARAMETER(S): 2128 * [I] LISTVIEW_ITEM *: destination item 2129 * [I] LPLVITEM : source item 2147 * 2148 * PARAMETER(S): 2149 * [I] LISTVIEW_ITEM *: destination item 2150 * [I] LPLVITEM : source item 2130 2151 * 2131 2152 * RETURN: … … 2141 2162 if (lpLVItem->mask & LVIF_STATE) 2142 2163 { 2143 if ((lpItem->state & lpLVItem->stateMask) != 2164 if ((lpItem->state & lpLVItem->stateMask) != 2144 2165 (lpLVItem->state & lpLVItem->stateMask)) 2145 2166 { 2146 uChanged |= LVIF_STATE; 2167 uChanged |= LVIF_STATE; 2147 2168 } 2148 2169 } … … 2152 2173 if (lpItem->iImage != lpLVItem->iImage) 2153 2174 { 2154 uChanged |= LVIF_IMAGE; 2155 } 2156 } 2157 2175 uChanged |= LVIF_IMAGE; 2176 } 2177 } 2178 2158 2179 if (lpLVItem->mask & LVIF_PARAM) 2159 2180 { 2160 2181 if (lpItem->lParam != lpLVItem->lParam) 2161 2182 { 2162 uChanged |= LVIF_PARAM; 2163 } 2164 } 2165 2183 uChanged |= LVIF_PARAM; 2184 } 2185 } 2186 2166 2187 if (lpLVItem->mask & LVIF_INDENT) 2167 2188 { 2168 2189 if (lpItem->iIndent != lpLVItem->iIndent) 2169 2190 { 2170 uChanged |= LVIF_INDENT; 2171 } 2172 } 2173 2174 if (lpLVItem->mask & LVIF_TEXT) 2175 { 2176 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2191 uChanged |= LVIF_INDENT; 2192 } 2193 } 2194 2195 if (lpLVItem->mask & LVIF_TEXT) 2196 { 2197 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2177 2198 { 2178 2199 if (lpItem->pszText != LPSTR_TEXTCALLBACKA) 2179 2200 { 2180 uChanged |= LVIF_TEXT; 2201 uChanged |= LVIF_TEXT; 2181 2202 } 2182 2203 } … … 2185 2206 if (lpItem->pszText == LPSTR_TEXTCALLBACKA) 2186 2207 { 2187 uChanged |= LVIF_TEXT; 2188 } 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2208 uChanged |= LVIF_TEXT; 2209 } 2210 else 2211 { 2212 if (lpLVItem->pszText) 2213 { 2214 if (lpItem->pszText) 2215 { 2216 if (strcmp(lpLVItem->pszText, lpItem->pszText) != 0) 2217 { 2218 uChanged |= LVIF_TEXT; 2219 } 2220 } 2221 else 2222 { 2223 uChanged |= LVIF_TEXT; 2224 } 2225 } 2226 else 2227 { 2228 if (lpItem->pszText) 2229 { 2230 uChanged |= LVIF_TEXT; 2231 } 2232 } 2233 } 2213 2234 } 2214 2235 } … … 2220 2241 * DESCRIPTION: 2221 2242 * Initializes item attributes. 2222 * 2223 * PARAMETER(S): 2224 * [I] HWND : window handle 2225 * [O] LISTVIEW_ITEM *: destination item 2226 * [I] LPLVITEM : source item 2243 * 2244 * PARAMETER(S): 2245 * [I] HWND : window handle 2246 * [O] LISTVIEW_ITEM *: destination item 2247 * [I] LPLVITEM : source item 2227 2248 * 2228 2249 * RETURN: … … 2230 2251 * FAILURE : FALSE 2231 2252 */ 2232 static BOOL LISTVIEW_InitItem(HWND hwnd, LISTVIEW_ITEM *lpItem, 2253 static BOOL LISTVIEW_InitItem(HWND hwnd, LISTVIEW_ITEM *lpItem, 2233 2254 LPLVITEMA lpLVItem) 2234 2255 { … … 2239 2260 { 2240 2261 bResult = TRUE; 2241 2262 2242 2263 if (lpLVItem->mask & LVIF_STATE) 2243 2264 { … … 2245 2266 lpItem->state |= (lpLVItem->state & lpLVItem->stateMask); 2246 2267 } 2247 2268 2248 2269 if (lpLVItem->mask & LVIF_IMAGE) 2249 2270 { 2250 2271 lpItem->iImage = lpLVItem->iImage; 2251 2272 } 2252 2273 2253 2274 if (lpLVItem->mask & LVIF_PARAM) 2254 2275 { 2255 2276 lpItem->lParam = lpLVItem->lParam; 2256 2277 } 2257 2278 2258 2279 if (lpLVItem->mask & LVIF_INDENT) 2259 2280 { … … 2261 2282 } 2262 2283 2263 if (lpLVItem->mask & LVIF_TEXT) 2264 { 2265 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2284 if (lpLVItem->mask & LVIF_TEXT) 2285 { 2286 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2266 2287 { 2267 2288 if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING)) … … 2270 2291 } 2271 2292 2272 if ((lpItem->pszText != NULL) && 2293 if ((lpItem->pszText != NULL) && 2273 2294 (lpItem->pszText != LPSTR_TEXTCALLBACKA)) 2274 2295 { 2275 2296 COMCTL32_Free(lpItem->pszText); 2276 2297 } 2277 2298 2278 2299 lpItem->pszText = LPSTR_TEXTCALLBACKA; 2279 2300 } 2280 else 2301 else 2281 2302 { 2282 2303 if (lpItem->pszText == LPSTR_TEXTCALLBACKA) … … 2284 2305 lpItem->pszText = NULL; 2285 2306 } 2286 2307 2287 2308 bResult = Str_SetPtrA(&lpItem->pszText, lpLVItem->pszText); 2288 2309 } … … 2309 2330 * FAILURE : FALSE 2310 2331 */ 2311 static BOOL LISTVIEW_InitSubItem(HWND hwnd, LISTVIEW_SUBITEM *lpSubItem, 2332 static BOOL LISTVIEW_InitSubItem(HWND hwnd, LISTVIEW_SUBITEM *lpSubItem, 2312 2333 LPLVITEMA lpLVItem) 2313 2334 { 2314 2335 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 2315 2336 BOOL bResult = FALSE; 2316 2337 2317 2338 if ((lpSubItem != NULL) && (lpLVItem != NULL)) 2318 2339 { … … 2327 2348 lpSubItem->iImage = lpLVItem->iImage; 2328 2349 } 2329 2330 if (lpLVItem->mask & LVIF_TEXT) 2331 { 2332 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2350 2351 if (lpLVItem->mask & LVIF_TEXT) 2352 { 2353 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2333 2354 { 2334 2355 if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING)) 2335 2356 { 2336 2357 return FALSE; 2337 } 2338 2339 if ((lpSubItem->pszText != NULL) && 2358 } 2359 2360 if ((lpSubItem->pszText != NULL) && 2340 2361 (lpSubItem->pszText != LPSTR_TEXTCALLBACKA)) 2341 2362 { 2342 2363 COMCTL32_Free(lpSubItem->pszText); 2343 2364 } 2344 2365 2345 2366 lpSubItem->pszText = LPSTR_TEXTCALLBACKA; 2346 2367 } 2347 else 2368 else 2348 2369 { 2349 2370 if (lpSubItem->pszText == LPSTR_TEXTCALLBACKA) … … 2351 2372 lpSubItem->pszText = NULL; 2352 2373 } 2353 2374 2354 2375 bResult = Str_SetPtrA(&lpSubItem->pszText, lpLVItem->pszText); 2355 2376 } … … 2364 2385 * DESCRIPTION: 2365 2386 * Adds a subitem at a given position (column index). 2366 * 2367 * PARAMETER(S): 2368 * [I] HWND : window handle 2369 * [I] LPLVITEM : new subitem atttributes 2387 * 2388 * PARAMETER(S): 2389 * [I] HWND : window handle 2390 * [I] LPLVITEM : new subitem atttributes 2370 2391 * 2371 2392 * RETURN: … … 2393 2414 if (lpSubItem != NULL) 2394 2415 { 2395 2416 ZeroMemory(lpSubItem, sizeof(LISTVIEW_SUBITEM)); 2396 2417 if (LISTVIEW_InitSubItem(hwnd, lpSubItem, lpLVItem) != FALSE) 2397 2418 { 2398 nPosition = LISTVIEW_FindInsertPosition(hdpaSubItems, 2419 nPosition = LISTVIEW_FindInsertPosition(hdpaSubItems, 2399 2420 lpSubItem->iSubItem); 2400 2421 nItem = DPA_InsertPtr(hdpaSubItems, nPosition, lpSubItem); … … 2402 2423 { 2403 2424 bResult = TRUE; 2404 } 2405 } 2406 } 2407 } 2408 } 2409 2410 /* cleanup if unsuccessful */ 2425 } 2426 } 2427 } 2428 } 2429 } 2430 2431 /* cleanup if unsuccessful */ 2411 2432 if ((bResult == FALSE) && (lpSubItem != NULL)) 2412 2433 { 2413 2434 COMCTL32_Free(lpSubItem); 2414 2435 } 2415 2436 2416 2437 return bResult; 2417 2438 } … … 2420 2441 * DESCRIPTION: 2421 2442 * Finds the dpa insert position (array index). 2422 * 2443 * 2423 2444 * PARAMETER(S): 2424 2445 * [I] HWND : window handle … … 2443 2464 return i; 2444 2465 } 2445 } 2466 } 2446 2467 } 2447 2468 … … 2452 2473 * DESCRIPTION: 2453 2474 * Retrieves a listview subitem at a given position (column index). 2454 * 2475 * 2455 2476 * PARAMETER(S): 2456 2477 * [I] HWND : window handle … … 2478 2499 { 2479 2500 return NULL; 2480 } 2481 } 2482 } 2483 2501 } 2502 } 2503 } 2504 2484 2505 return NULL; 2485 2506 } … … 2488 2509 * DESCRIPTION: 2489 2510 * Sets item attributes. 2490 * 2491 * PARAMETER(S): 2492 * [I] HWND : window handle 2493 * [I] LPLVITEM : new item atttributes 2511 * 2512 * PARAMETER(S): 2513 * [I] HWND : window handle 2514 * [I] LPLVITEM : new item atttributes 2494 2515 * 2495 2516 * RETURN: … … 2523 2544 itm.iSubItem = 0; 2524 2545 ListView_GetItemA(hwnd,&itm); 2525 2546 2526 2547 2527 2548 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); … … 2535 2556 nmlv.iItem = lpLVItem->iItem; 2536 2557 2537 if ((itm.state & lpLVItem->stateMask) != 2558 if ((itm.state & lpLVItem->stateMask) != 2538 2559 (lpLVItem->state & lpLVItem->stateMask)) 2539 2560 { … … 2567 2588 ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv); 2568 2589 2569 2570 2571 2590 rcItem.left = LVIR_BOUNDS; 2591 LISTVIEW_GetItemRect(hwnd, lpLVItem->iItem, &rcItem); 2592 InvalidateRect(hwnd, &rcItem, TRUE); 2572 2593 } 2573 2594 } … … 2613 2634 } 2614 2635 2615 2636 LISTVIEW_AddSelectionRange(hwnd,lpLVItem->iItem, 2616 2637 lpLVItem->iItem); 2617 2638 } … … 2621 2642 lpLVItem->iItem); 2622 2643 } 2623 2644 if (nmlv.uNewState & LVIS_FOCUSED) 2624 2645 { 2625 2646 /* 2626 2647 * This is a fun hoop to jump to try to catch if 2627 2648 * the user is calling us directly to call focus or if 2628 * this function is being called as a result of a 2629 * SetItemFocus call. 2649 * this function is being called as a result of a 2650 * SetItemFocus call. 2630 2651 */ 2631 2652 if (infoPtr->nFocusedItem >= 0) 2632 2653 LISTVIEW_SetItemFocus(hwnd, lpLVItem->iItem); 2633 } 2654 } 2634 2655 } 2635 2656 2636 2657 nmlv.uChanged = uChanged; 2637 2658 nmlv.iItem = lpLVItem->iItem; … … 2661 2682 bResult = TRUE; 2662 2683 } 2663 2684 2664 2685 if (uChanged) 2665 2686 { 2666 2687 rcItem.left = LVIR_BOUNDS; 2667 2688 LISTVIEW_GetItemRect(hwnd, lpLVItem->iItem, &rcItem); 2668 2689 InvalidateRect(hwnd, &rcItem, TRUE); 2669 2690 } … … 2679 2700 * DESCRIPTION: 2680 2701 * Sets subitem attributes. 2681 * 2682 * PARAMETER(S): 2683 * [I] HWND : window handle 2684 * [I] LPLVITEM : new subitem atttributes 2702 * 2703 * PARAMETER(S): 2704 * [I] HWND : window handle 2705 * [I] LPLVITEM : new subitem atttributes 2685 2706 * 2686 2707 * RETURN: … … 2719 2740 bResult = LISTVIEW_AddSubItem(hwnd, lpLVItem); 2720 2741 } 2721 2742 2722 2743 rcItem.left = LVIR_BOUNDS; 2723 2724 2725 } 2744 LISTVIEW_GetItemRect(hwnd, lpLVItem->iItem, &rcItem); 2745 InvalidateRect(hwnd, &rcItem, FALSE); 2746 } 2726 2747 } 2727 2748 } … … 2734 2755 * DESCRIPTION: 2735 2756 * Retrieves the index of the item at coordinate (0, 0) of the client area. 2736 * 2757 * 2737 2758 * PARAMETER(S): 2738 2759 * [I] HWND : window handle … … 2751 2772 scrollInfo.cbSize = sizeof(SCROLLINFO); 2752 2773 scrollInfo.fMask = SIF_POS; 2753 2774 2754 2775 if (uView == LVS_LIST) 2755 2776 { … … 2772 2793 } 2773 2794 } 2774 2795 2775 2796 return nItem; 2776 2797 } … … 2779 2800 * DESCRIPTION: 2780 2801 * Draws a subitem. 2781 * 2802 * 2782 2803 * PARAMETER(S): 2783 2804 * [I] HWND : window handle … … 2790 2811 * None 2791 2812 */ 2792 static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, 2813 static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, 2793 2814 RECT rcItem, BOOL Selected) 2794 2815 { 2795 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2816 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2796 2817 CHAR szDispText[DISP_TEXT_SIZE]; 2797 2818 LVITEMA lvItem; … … 2850 2871 } 2851 2872 2852 ExtTextOutA(hdc, rcItem.left, rcItem.top, textoutOptions, 2873 ExtTextOutA(hdc, rcItem.left, rcItem.top, textoutOptions, 2853 2874 &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL); 2854 2875 … … 2877 2898 * DESCRIPTION: 2878 2899 * Draws an item. 2879 * 2900 * 2880 2901 * PARAMETER(S): 2881 2902 * [I] HWND : window handle … … 2889 2910 static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem, BOOL FullSelect, RECT* SuggestedFocus) 2890 2911 { 2891 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2912 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2892 2913 CHAR szDispText[DISP_TEXT_SIZE]; 2893 2914 INT nLabelWidth; … … 2926 2947 if (lvItem.iIndent>0 && infoPtr->iconSize.cx > 0) 2927 2948 { 2928 rcItem.left += infoPtr->iconSize.cx * lvItem.iIndent; 2949 rcItem.left += infoPtr->iconSize.cx * lvItem.iIndent; 2929 2950 2930 2951 if (SuggestedFocus) 2931 2952 SuggestedFocus->left += infoPtr->iconSize.cx * lvItem.iIndent; 2932 } 2953 } 2933 2954 2934 2955 /* state icons */ 2935 2956 if (infoPtr->himlState != NULL) 2936 2957 { 2937 UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12; 2958 UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12; 2938 2959 if (uStateImage > 0) 2939 2960 { 2940 ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcItem.left, 2961 ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcItem.left, 2941 2962 rcItem.top, ILD_NORMAL); 2942 2963 } 2943 2944 rcItem.left += infoPtr->iconSize.cx; 2964 2965 rcItem.left += infoPtr->iconSize.cx; 2945 2966 if (SuggestedFocus) 2946 2967 SuggestedFocus->left += infoPtr->iconSize.cx; 2947 2968 bImage = TRUE; 2948 2969 } 2949 2970 2950 2971 /* small icons */ 2951 2972 if (infoPtr->himlSmall != NULL) … … 2955 2976 { 2956 2977 ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); 2957 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 2978 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 2958 2979 rcItem.top, ILD_SELECTED); 2959 2980 } … … 2961 2982 { 2962 2983 ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); 2963 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 2984 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 2964 2985 rcItem.top, ILD_NORMAL); 2965 2986 } 2966 2967 rcItem.left += infoPtr->iconSize.cx; 2987 2988 rcItem.left += infoPtr->iconSize.cx; 2968 2989 2969 2990 if (SuggestedFocus) … … 2978 2999 if ((lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus != FALSE)) 2979 3000 { 2980 /* set item colors */ 3001 /* set item colors */ 2981 3002 dwBkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); 2982 3003 dwTextColor = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); … … 2984 3005 nMixMode = SetROP2(hdc, R2_XORPEN); 2985 3006 } 2986 else if ((GetWindowLongA(hwnd, GWL_STYLE) & LVS_SHOWSELALWAYS) && 3007 else if ((GetWindowLongA(hwnd, GWL_STYLE) & LVS_SHOWSELALWAYS) && 2987 3008 (lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus == FALSE)) 2988 3009 { … … 3011 3032 nMixMode = SetROP2(hdc, R2_COPYPEN); 3012 3033 } 3013 3034 3014 3035 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 3015 3036 if (rcItem.left + nLabelWidth < rcItem.right) … … 3020 3041 rcItem.right += IMAGE_PADDING; 3021 3042 } 3022 3023 /* draw label */ 3043 3044 /* draw label */ 3024 3045 dwTextX = rcItem.left + 1; 3025 3046 if (bImage) … … 3037 3058 rec.left = rec.right; 3038 3059 rec.right = rec.left+REPORT_MARGINX; 3039 ExtTextOutA(hdc, rec.left , rec.top, textoutOptions, 3060 ExtTextOutA(hdc, rec.left , rec.top, textoutOptions, 3040 3061 &rec, NULL, 0, NULL); 3041 3062 } 3042 3063 3043 3064 if (!FullSelect) 3044 3065 CopyRect(SuggestedFocus,&rcItem); … … 3057 3078 * DESCRIPTION: 3058 3079 * Draws an item when in large icon display mode. 3059 * 3080 * 3060 3081 * PARAMETER(S): 3061 3082 * [I] HWND : window handle … … 3071 3092 RECT *SuggestedFocus) 3072 3093 { 3073 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3094 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3074 3095 CHAR szDispText[DISP_TEXT_SIZE]; 3075 3096 INT nDrawPosX = rcItem.left; … … 3105 3126 if (lvItem.state & LVIS_SELECTED) 3106 3127 { 3107 /* set item colors */ 3128 /* set item colors */ 3108 3129 SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); 3109 3130 SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); … … 3136 3157 if ((lvItem.state & LVIS_SELECTED) && (lvItem.iImage>=0)) 3137 3158 { 3138 ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 3159 ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 3139 3160 rcItem.top, ILD_SELECTED); 3140 3161 } 3141 3162 else if (lvItem.iImage>=0) 3142 3163 { 3143 ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 3164 ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 3144 3165 rcItem.top, ILD_NORMAL); 3145 3166 } … … 3151 3172 3152 3173 InflateRect(&rcItem, -(2*CAPTION_BORDER), 0); 3153 rcItem.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; 3174 rcItem.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; 3154 3175 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 3155 3176 GetTextMetricsA(hdc, &tm); … … 3161 3182 INT i, len, eos, nCharsFit; 3162 3183 /* give or take a couple, how many average sized chars would fit? */ 3163 nCharsFit = tm.tmAveCharWidth > 0 ? (rcWidth/tm.tmAveCharWidth)+2 : 0; 3184 nCharsFit = tm.tmAveCharWidth > 0 ? (rcWidth/tm.tmAveCharWidth)+2 : 0; 3164 3185 /* place the ellipse accordingly, without overrunning the buffer */ 3165 3186 len = strlen(szDispText); 3166 3187 eos = min((nCharsFit > 1 && nCharsFit < len) ? nCharsFit+3 : len+2, 3167 3188 sizeof(szDispText)-1); 3168 3189 3169 3190 nLabelWidth = ListView_GetStringWidthA(hwnd, szDispText); 3170 3191 while ((nLabelWidth > rcWidth) && (eos > 3)) 3171 3192 { 3172 3173 szDispText[eos-i] = '.'; 3193 for (i = 1; i < 4; i++) 3194 szDispText[eos-i] = '.'; 3174 3195 /* shift the ellipse one char to the left for each iteration */ 3175 szDispText[eos--] = '\0'; 3196 szDispText[eos--] = '\0'; 3176 3197 nLabelWidth = ListView_GetStringWidthA(hwnd, szDispText); 3177 3198 } … … 3191 3212 } 3192 3213 3193 /* draw label */ 3194 rcItem.bottom = rcItem.top + tm.tmHeight + HEIGHT_PADDING; 3195 3196 ExtTextOutA(hdc, rcItem.left + CAPTION_BORDER, rcItem.top, textoutOptions, 3214 /* draw label */ 3215 rcItem.bottom = rcItem.top + tm.tmHeight + HEIGHT_PADDING; 3216 3217 ExtTextOutA(hdc, rcItem.left + CAPTION_BORDER, rcItem.top, textoutOptions, 3197 3218 &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL); 3198 3219 3199 3220 3200 3221 CopyRect(SuggestedFocus,&rcItem); … … 3204 3225 * DESCRIPTION: 3205 3226 * Draws listview items when in report display mode. 3206 * 3207 * PARAMETER(S): 3208 * [I] HWND : window handle 3209 * [I] HDC : device context handle 3227 * 3228 * PARAMETER(S): 3229 * [I] HWND : window handle 3230 * [I] HDC : device context handle 3210 3231 * 3211 3232 * RETURN: … … 3280 3301 RECT br; 3281 3302 3282 TRACE("Owner Drawn\n"); 3303 TRACE("Owner Drawn\n"); 3283 3304 dis.CtlType = ODT_LISTVIEW; 3284 3305 dis.CtlID = uID; … … 3286 3307 dis.itemAction = ODA_DRAWENTIRE; 3287 3308 dis.itemState = 0; 3288 3309 3289 3310 if (LISTVIEW_IsSelected(hwnd,nItem)) dis.itemState|=ODS_SELECTED; 3290 3311 if (nItem==infoPtr->nFocusedItem) dis.itemState|=ODS_FOCUS; … … 3295 3316 Header_GetItemRect(infoPtr->hwndHeader, nColumnCount-1, &br); 3296 3317 3297 dis.rcItem.left = -scrollOffset; 3318 dis.rcItem.left = -scrollOffset; 3298 3319 dis.rcItem.right = max(dis.rcItem.left, br.right - scrollOffset); 3299 3320 dis.rcItem.top = nDrawPosY; 3300 3321 dis.rcItem.bottom = dis.rcItem.top + infoPtr->nItemHeight; 3301 3322 3302 3323 ZeroMemory(&item,sizeof(LVITEMA)); 3303 3324 item.iItem = nItem; … … 3325 3346 ir.top = nDrawPosY; 3326 3347 ir.bottom = ir.top + infoPtr->nItemHeight; 3327 3348 3328 3349 CopyRect(&SuggestedFocusRect,&ir); 3329 3350 } … … 3351 3372 { 3352 3373 LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem, FullSelected, 3353 &SuggestedFocusRect); 3354 } 3355 else 3356 { 3357 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, j, rcItem, 3374 &SuggestedFocusRect); 3375 } 3376 else 3377 { 3378 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, j, rcItem, 3358 3379 FullSelected); 3359 3380 } 3360 3381 3361 3382 if (cditemmode & CDRF_NOTIFYPOSTPAINT) 3362 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, nItem, 0, 3363 3383 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, nItem, 0, 3384 CDDS_ITEMPOSTPAINT); 3364 3385 } 3365 3386 /* … … 3372 3393 rop = SetROP2(hdc, R2_XORPEN); 3373 3394 3374 Rectangle(hdc, SuggestedFocusRect.left, SuggestedFocusRect.top, 3375 SuggestedFocusRect.right,SuggestedFocusRect.bottom); 3395 Rectangle(hdc, SuggestedFocusRect.left, SuggestedFocusRect.top, 3396 SuggestedFocusRect.right,SuggestedFocusRect.bottom); 3376 3397 3377 3398 if (rop) … … 3385 3406 * DESCRIPTION: 3386 3407 * Retrieves the number of items that can fit vertically in the client area. 3387 * 3408 * 3388 3409 * PARAMETER(S): 3389 3410 * [I] HWND : window handle … … 3420 3441 /*** 3421 3442 * DESCRIPTION: 3422 * Retrieves the number of items that can fit horizontally in the client 3443 * Retrieves the number of items that can fit horizontally in the client 3423 3444 * area. 3424 * 3445 * 3425 3446 * PARAMETER(S): 3426 3447 * [I] HWND : window handle … … 3449 3470 /*** 3450 3471 * DESCRIPTION: 3451 * Retrieves the number of columns needed to display all the items when in 3472 * Retrieves the number of columns needed to display all the items when in 3452 3473 * list display mode. 3453 * 3474 * 3454 3475 * PARAMETER(S): 3455 3476 * [I] HWND : window handle … … 3477 3498 3478 3499 return nColumnCount; 3479 } 3480 3500 } 3501 3481 3502 3482 3503 /*** 3483 3504 * DESCRIPTION: 3484 3505 * Draws listview items when in list display mode. 3485 * 3486 * PARAMETER(S): 3487 * [I] HWND : window handle 3488 * [I] HDC : device context handle 3506 * 3507 * PARAMETER(S): 3508 * [I] HWND : window handle 3509 * [I] HDC : device context handle 3489 3510 * 3490 3511 * RETURN: … … 3539 3560 */ 3540 3561 if (LISTVIEW_GetItemState(hwnd,nItem,LVIS_FOCUSED) && infoPtr->bFocus) 3541 Rectangle(hdc, FocusRect.left, FocusRect.top, 3562 Rectangle(hdc, FocusRect.left, FocusRect.top, 3542 3563 FocusRect.right,FocusRect.bottom); 3543 3564 3544 3565 if (cditemmode & CDRF_NOTIFYPOSTPAINT) 3545 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, nItem, 0, 3566 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, nItem, 0, 3546 3567 CDDS_ITEMPOSTPAINT); 3547 3568 3548 3569 } 3549 3570 } … … 3553 3574 * DESCRIPTION: 3554 3575 * Draws listview items when in icon or small icon display mode. 3555 * 3556 * PARAMETER(S): 3557 * [I] HWND : window handle 3558 * [I] HDC : device context handle 3576 * 3577 * PARAMETER(S): 3578 * [I] HWND : window handle 3579 * [I] HDC : device context handle 3559 3580 * 3560 3581 * RETURN: … … 3593 3614 ptPosition.x += ptOrigin.x; 3594 3615 ptPosition.y += ptOrigin.y; 3595 3616 3596 3617 if (ptPosition.y + infoPtr->nItemHeight > infoPtr->rcList.top) 3597 3618 { … … 3617 3638 * Draw Focus Rect 3618 3639 */ 3619 if (LISTVIEW_GetItemState(hwnd,i,LVIS_FOCUSED) && 3640 if (LISTVIEW_GetItemState(hwnd,i,LVIS_FOCUSED) && 3620 3641 infoPtr->bFocus) 3621 Rectangle(hdc, SuggestedFocus.left, SuggestedFocus.top, 3622 SuggestedFocus.right,SuggestedFocus.bottom); 3642 Rectangle(hdc, SuggestedFocus.left, SuggestedFocus.top, 3643 SuggestedFocus.right,SuggestedFocus.bottom); 3623 3644 } 3624 3645 } … … 3626 3647 } 3627 3648 if (cditemmode & CDRF_NOTIFYPOSTPAINT) 3628 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, i, 0, 3649 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, i, 0, 3629 3650 CDDS_ITEMPOSTPAINT); 3630 3651 } … … 3634 3655 * DESCRIPTION: 3635 3656 * Draws listview items. 3636 * 3637 * PARAMETER(S): 3638 * [I] HWND : window handle 3639 * [I] HDC : device context handle 3657 * 3658 * PARAMETER(S): 3659 * [I] HWND : window handle 3660 * [I] HDC : device context handle 3640 3661 * 3641 3662 * RETURN: … … 3668 3689 3669 3690 /* select transparent brush (for drawing the focus box) */ 3670 SelectObject(hdc, GetStockObject(NULL_BRUSH)); 3691 SelectObject(hdc, GetStockObject(NULL_BRUSH)); 3671 3692 3672 3693 if (uView == LVS_LIST) 3673 3694 { 3674 LISTVIEW_RefreshList(hwnd, hdc, cdmode); 3695 LISTVIEW_RefreshList(hwnd, hdc, cdmode); 3675 3696 } 3676 3697 else if (uView == LVS_REPORT) … … 3690 3711 SelectObject(hdc, hOldFont); 3691 3712 SelectObject(hdc, hOldPen); 3692 3713 3693 3714 /* delete pen */ 3694 3715 DeleteObject(hPen); 3695 3716 3696 3717 if (cdmode & CDRF_NOTIFYPOSTPAINT) 3697 3718 LISTVIEW_SendCustomDrawNotify(hwnd, CDDS_POSTPAINT, hdc, rect); … … 3702 3723 * DESCRIPTION: 3703 3724 * Calculates the approximate width and height of a given number of items. 3704 * 3725 * 3705 3726 * PARAMETER(S): 3706 3727 * [I] HWND : window handle … … 3712 3733 * Returns a DWORD. The width in the low word and the height in high word. 3713 3734 */ 3714 static LRESULT LISTVIEW_ApproximateViewRect(HWND hwnd, INT nItemCount, 3735 static LRESULT LISTVIEW_ApproximateViewRect(HWND hwnd, INT nItemCount, 3715 3736 WORD wWidth, WORD wHeight) 3716 3737 { … … 3748 3769 nItemCountPerColumn = 1; 3749 3770 } 3750 3771 3751 3772 if (nItemCount % nItemCountPerColumn != 0) 3752 3773 { … … 3778 3799 /* TO DO */ 3779 3800 } 3780 3801 3781 3802 return dwViewRect; 3782 3803 } … … 3785 3806 * DESCRIPTION: 3786 3807 * Arranges listview items in icon display mode. 3787 * 3808 * 3788 3809 * PARAMETER(S): 3789 3810 * [I] HWND : window handle … … 3796 3817 static LRESULT LISTVIEW_Arrange(HWND hwnd, INT nAlignCode) 3797 3818 { 3798 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3819 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3799 3820 BOOL bResult = FALSE; 3800 3821 … … 3827 3848 * DESCRIPTION: 3828 3849 * Removes all listview items and subitems. 3829 * 3850 * 3830 3851 * PARAMETER(S): 3831 3852 * [I] HWND : window handle … … 3868 3889 /* initialize memory */ 3869 3890 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 3870 3891 3871 3892 /* send LVN_DELETEALLITEMS notification */ 3872 3893 nmlv.hdr.hwndFrom = hwnd; … … 3875 3896 nmlv.iItem = -1; 3876 3897 3877 /* verify if subsequent LVN_DELETEITEM notifications should be 3898 /* verify if subsequent LVN_DELETEITEM notifications should be 3878 3899 suppressed */ 3879 3900 bSuppress = ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv); … … 3890 3911 { 3891 3912 /* free subitem string */ 3892 if ((lpSubItem->pszText != NULL) && 3913 if ((lpSubItem->pszText != NULL) && 3893 3914 (lpSubItem->pszText != LPSTR_TEXTCALLBACKA)) 3894 3915 { 3895 3916 COMCTL32_Free(lpSubItem->pszText); 3896 3917 } 3897 3918 3898 3919 /* free subitem */ 3899 3920 COMCTL32_Free(lpSubItem); 3900 } 3921 } 3901 3922 } 3902 3923 … … 3914 3935 3915 3936 /* free item string */ 3916 if ((lpItem->pszText != NULL) && 3937 if ((lpItem->pszText != NULL) && 3917 3938 (lpItem->pszText != LPSTR_TEXTCALLBACKA)) 3918 3939 { 3919 3940 COMCTL32_Free(lpItem->pszText); 3920 3941 } 3921 3942 3922 3943 /* free item */ 3923 3944 COMCTL32_Free(lpItem); 3924 3945 } 3925 3946 3926 3947 DPA_Destroy(hdpaSubItems); 3927 3948 } … … 3930 3951 /* reinitialize listview memory */ 3931 3952 bResult = DPA_DeleteAllPtrs(infoPtr->hdpaItems); 3932 3953 3933 3954 /* align items (set position of each item) */ 3934 3955 if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) … … 3943 3964 } 3944 3965 } 3945 3966 3946 3967 LISTVIEW_UpdateScroll(hwnd); 3947 3968 … … 3949 3970 InvalidateRect(hwnd, NULL, TRUE); 3950 3971 } 3951 3972 3952 3973 return bResult; 3953 3974 } … … 3956 3977 * DESCRIPTION: 3957 3978 * Removes a column from the listview control. 3958 * 3979 * 3959 3980 * PARAMETER(S): 3960 3981 * [I] HWND : window handle … … 3997 4018 * DESCRIPTION: 3998 4019 * Removes an item from the listview control. 3999 * 4000 * PARAMETER(S): 4001 * [I] HWND : window handle 4002 * [I] INT : item index 4020 * 4021 * PARAMETER(S): 4022 * [I] HWND : window handle 4023 * [I] INT : item index 4003 4024 * 4004 4025 * RETURN: … … 4021 4042 4022 4043 TRACE("(hwnd=%x,nItem=%d)\n", hwnd, nItem); 4023 4024 4044 4045 4025 4046 /* First, send LVN_DELETEITEM notification. */ 4026 4047 memset(&nmlv, 0, sizeof (NMLISTVIEW)); … … 4029 4050 nmlv.hdr.code = LVN_DELETEITEM; 4030 4051 nmlv.iItem = nItem; 4031 SendMessageA(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId, 4052 SendMessageA(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId, 4032 4053 (LPARAM)&nmlv); 4033 4054 … … 4059 4080 { 4060 4081 /* free item string */ 4061 if ((lpSubItem->pszText != NULL) && 4082 if ((lpSubItem->pszText != NULL) && 4062 4083 (lpSubItem->pszText != LPSTR_TEXTCALLBACKA)) 4063 4084 { 4064 4085 COMCTL32_Free(lpSubItem->pszText); 4065 4086 } 4066 4087 4067 4088 /* free item */ 4068 4089 COMCTL32_Free(lpSubItem); 4069 } 4070 } 4071 4090 } 4091 } 4092 4072 4093 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 4073 4094 if (lpItem != NULL) 4074 4095 { 4075 4096 /* free item string */ 4076 if ((lpItem->pszText != NULL) && 4097 if ((lpItem->pszText != NULL) && 4077 4098 (lpItem->pszText != LPSTR_TEXTCALLBACKA)) 4078 4099 { 4079 4100 COMCTL32_Free(lpItem->pszText); 4080 4101 } 4081 4102 4082 4103 /* free item */ 4083 4104 COMCTL32_Free(lpItem); 4084 4105 } 4085 4106 4086 4107 bResult = DPA_Destroy(hdpaSubItems); 4087 4108 } … … 4107 4128 InvalidateRect(hwnd, NULL, TRUE); 4108 4129 } 4109 4130 4110 4131 return bResult; 4111 4132 } … … 4157 4178 4158 4179 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); 4159 4180 4160 4181 if (!(lStyle & LVS_OWNERDATA)) 4161 4182 { 4162 4183 if (NULL == (hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem))) 4163 4184 return FALSE; 4164 4185 4165 4186 if (NULL == (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0))) 4166 4187 return FALSE; 4167 4188 } 4168 4189 else … … 4225 4246 RECT rect; 4226 4247 LISTVIEW_ITEM *lpItem; 4227 HWND hedit; 4248 HWND hedit; 4228 4249 HINSTANCE hinst = GetWindowLongA(hwnd, GWL_HINSTANCE); 4229 4250 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); … … 4234 4255 LISTVIEW_ITEM lvItemRef; 4235 4256 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 4236 4257 4237 4258 if (~GetWindowLongA(hwnd, GWL_STYLE) & LVS_EDITLABELS) 4238 4259 return FALSE; … … 4251 4272 { 4252 4273 if (NULL == (hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem))) 4253 4274 return 0; 4254 4275 4255 4276 if (NULL == (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0))) 4256 4257 } 4277 return 0; 4278 } 4258 4279 else 4259 4280 { … … 4292 4313 4293 4314 if (ListView_LVNotify(GetParent(hwnd), nCtrlId, &dispInfo)) 4294 4315 return 0; 4295 4316 4296 4317 rect.left = LVIR_LABEL; 4297 4318 if (!LISTVIEW_GetItemRect(hwnd, nItem, &rect)) 4298 4299 4300 if (!(hedit = CreateEditLabel(szDispText , WS_VISIBLE, 4301 rect.left-2, rect.top-1, 0, 4302 rect.bottom - rect.top+2, 4303 4304 4319 return 0; 4320 4321 if (!(hedit = CreateEditLabel(szDispText , WS_VISIBLE, 4322 rect.left-2, rect.top-1, 0, 4323 rect.bottom - rect.top+2, 4324 hwnd, hinst, LISTVIEW_EndEditLabel, nItem))) 4325 return 0; 4305 4326 4306 4327 infoPtr->hwndEdit = hedit; 4307 SetFocus(hedit); 4328 SetFocus(hedit); 4308 4329 SendMessageA(hedit, EM_SETSEL, 0, -1); 4309 4330 … … 4315 4336 * DESCRIPTION: 4316 4337 * Ensures the specified item is visible, scrolling into view if necessary. 4317 * 4338 * 4318 4339 * PARAMETER(S): 4319 4340 * [I] HWND : window handle … … 4360 4381 rcItem.left += infoPtr->rcList.left; 4361 4382 } 4362 4363 /* When in LVS_REPORT view, the scroll position should 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4383 4384 /* When in LVS_REPORT view, the scroll position should 4385 not be updated. */ 4386 if (nScrollPosWidth != 0) 4387 { 4388 if (rcItem.left % nScrollPosWidth == 0) 4389 { 4390 scrollInfo.nPos += rcItem.left / nScrollPosWidth; 4391 } 4392 else 4393 { 4394 scrollInfo.nPos += rcItem.left / nScrollPosWidth - 1; 4395 } 4396 4397 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 4398 } 4378 4399 } 4379 4400 } … … 4383 4404 { 4384 4405 /* scroll right */ 4385 4406 bRedraw = TRUE; 4386 4407 if (uView == LVS_LIST) 4387 4408 { … … 4395 4416 } 4396 4417 4397 /* When in LVS_REPORT view, the scroll position should 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 } 4413 } 4414 4418 /* When in LVS_REPORT view, the scroll position should 4419 not be updated. */ 4420 if (nScrollPosWidth != 0) 4421 { 4422 if (rcItem.right % nScrollPosWidth == 0) 4423 { 4424 scrollInfo.nPos += rcItem.right / nScrollPosWidth; 4425 } 4426 else 4427 { 4428 scrollInfo.nPos += rcItem.right / nScrollPosWidth + 1; 4429 } 4430 4431 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 4432 } 4433 } 4434 } 4435 4415 4436 if (rcItem.top < infoPtr->rcList.top) 4416 4437 { … … 4421 4442 if (uView == LVS_REPORT) 4422 4443 { 4423 rcItem.top -= infoPtr->rcList.top; 4444 rcItem.top -= infoPtr->rcList.top; 4424 4445 nScrollPosHeight = infoPtr->nItemHeight; 4425 4446 } … … 4438 4459 scrollInfo.nPos += rcItem.top / nScrollPosHeight - 1; 4439 4460 } 4440 4461 4441 4462 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); 4442 4463 } … … 4467 4488 scrollInfo.nPos += rcItem.bottom / nScrollPosHeight + 1; 4468 4489 } 4469 4490 4470 4491 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); 4471 4492 } 4472 4493 } 4473 4494 } 4474 4495 4475 4496 if(bRedraw) 4476 InvalidateRect(hwnd,NULL,TRUE); 4497 InvalidateRect(hwnd,NULL,TRUE); 4477 4498 return TRUE; 4478 4499 } … … 4481 4502 * DESCRIPTION: 4482 4503 * Retrieves the nearest item, given a position and a direction. 4483 * 4504 * 4484 4505 * PARAMETER(S): 4485 4506 * [I] HWND : window handle … … 4503 4524 lvHitTestInfo.pt.x += pt.x; 4504 4525 lvHitTestInfo.pt.y += pt.y; 4505 4526 4506 4527 do 4507 { 4528 { 4508 4529 if (vkDirection == VK_DOWN) 4509 4530 { 4510 4531 lvHitTestInfo.pt.y += infoPtr->nItemHeight; 4511 } 4532 } 4512 4533 else if (vkDirection == VK_UP) 4513 4534 { … … 4537 4558 4538 4559 return nItem; 4539 } 4560 } 4540 4561 4541 4562 /*** 4542 4563 * DESCRIPTION: 4543 4564 * Searches for an item with specific characteristics. 4544 * 4565 * 4545 4566 * PARAMETER(S): 4546 4567 * [I] HWND : window handle 4547 4568 * [I] INT : base item index 4548 4569 * [I] LPLVFINDINFO : item information to look for 4549 * 4570 * 4550 4571 * RETURN: 4551 4572 * SUCCESS : index of item 4552 4573 * FAILURE : -1 4553 4574 */ 4554 static LRESULT LISTVIEW_FindItem(HWND hwnd, INT nStart, 4575 static LRESULT LISTVIEW_FindItem(HWND hwnd, INT nStart, 4555 4576 LPLVFINDINFO lpFindInfo) 4556 4577 { … … 4571 4592 lvItem.mask |= LVIF_PARAM; 4572 4593 } 4573 4594 4574 4595 if (lpFindInfo->flags & LVFI_STRING) 4575 4596 { … … 4603 4624 if (lpFindInfo->flags & LVFI_NEARESTXY) 4604 4625 { 4605 nItem = LISTVIEW_GetNearestItem(hwnd, ptItem, 4626 nItem = LISTVIEW_GetNearestItem(hwnd, ptItem, 4606 4627 lpFindInfo->vkDirection); 4607 4628 if (nItem != -1) … … 4618 4639 nItem++; 4619 4640 } 4620 4641 4621 4642 lvItem.iItem = nItem; 4622 4643 lvItem.iSubItem = 0; … … 4636 4657 } 4637 4658 } 4638 4659 4639 4660 if (lvItem.mask & LVIF_PARAM) 4640 4661 { … … 4642 4663 continue; 4643 4664 } 4644 4665 4645 4666 return nItem; 4646 4667 } … … 4656 4677 { 4657 4678 return -1; 4658 } 4659 } 4660 } 4661 4662 return -1; 4679 } 4680 } 4681 } 4682 4683 return -1; 4663 4684 } 4664 4685 … … 4666 4687 * DESCRIPTION: 4667 4688 * Retrieves the background color of the listview control. 4668 * 4689 * 4669 4690 * PARAMETER(S): 4670 4691 * [I] HWND : window handle … … 4683 4704 * DESCRIPTION: 4684 4705 * Retrieves the background image of the listview control. 4685 * 4706 * 4686 4707 * PARAMETER(S): 4687 4708 * [I] HWND : window handle … … 4701 4722 * DESCRIPTION: 4702 4723 * Retrieves the callback mask. 4703 * 4724 * 4704 4725 * PARAMETER(S): 4705 4726 * [I] HWND : window handle … … 4718 4739 * DESCRIPTION: 4719 4740 * Retrieves column attributes. 4720 * 4741 * 4721 4742 * PARAMETER(S): 4722 4743 * [I] HWND : window handle … … 4733 4754 HDITEMA hdi; 4734 4755 BOOL bResult = FALSE; 4735 4756 4736 4757 if (lpColumn != NULL) 4737 4758 { 4738 4759 /* initialize memory */ 4739 4760 ZeroMemory(&hdi, sizeof(HDITEMA)); 4740 4761 4741 4762 if (lpColumn->mask & LVCF_FMT) 4742 4763 { … … 4769 4790 if (bResult != FALSE) 4770 4791 { 4771 if (lpColumn->mask & LVCF_FMT) 4792 if (lpColumn->mask & LVCF_FMT) 4772 4793 { 4773 4794 lpColumn->fmt = 0; … … 4791 4812 } 4792 4813 4793 4794 4795 4796 4814 if (hdi.fmt & HDF_BITMAP_ON_RIGHT) 4815 { 4816 lpColumn->fmt |= LVCFMT_BITMAP_ON_RIGHT; 4817 } 4797 4818 } 4798 4819 … … 4801 4822 lpColumn->cx = hdi.cxy; 4802 4823 } 4803 4824 4804 4825 if (lpColumn->mask & LVCF_IMAGE) 4805 4826 { … … 4826 4847 4827 4848 if (!lpiArray) 4828 4849 return FALSE; 4829 4850 4830 4851 /* little hack */ 4831 4852 for (i = 0; i < iCount; i++) 4832 4853 lpiArray[i] = i; 4833 4854 4834 4855 return TRUE; … … 4838 4859 * DESCRIPTION: 4839 4860 * Retrieves the column width. 4840 * 4861 * 4841 4862 * PARAMETER(S): 4842 4863 * [I] HWND : window handle … … 4845 4866 * RETURN: 4846 4867 * SUCCESS : column width 4847 * FAILURE : zero 4868 * FAILURE : zero 4848 4869 */ 4849 4870 static LRESULT LISTVIEW_GetColumnWidth(HWND hwnd, INT nColumn) … … 4874 4895 /*** 4875 4896 * DESCRIPTION: 4876 * In list or report display mode, retrieves the number of items that can fit 4877 * vertically in the visible area. In icon or small icon display mode, 4897 * In list or report display mode, retrieves the number of items that can fit 4898 * vertically in the visible area. In icon or small icon display mode, 4878 4899 * retrieves the total number of visible items. 4879 * 4900 * 4880 4901 * PARAMETER(S): 4881 4902 * [I] HWND : window handle … … 4894 4915 if (infoPtr->rcList.right > infoPtr->nItemWidth) 4895 4916 { 4896 nItemCount = LISTVIEW_GetCountPerRow(hwnd) * 4917 nItemCount = LISTVIEW_GetCountPerRow(hwnd) * 4897 4918 LISTVIEW_GetCountPerColumn(hwnd); 4898 4919 } … … 4929 4950 /* make sure we can get the listview info */ 4930 4951 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 4931 4952 return (0); 4932 4953 4933 4954 return (infoPtr->dwExStyle); … … 4937 4958 * DESCRIPTION: 4938 4959 * Retrieves the handle to the header control. 4939 * 4960 * 4940 4961 * PARAMETER(S): 4941 4962 * [I] HWND : window handle … … 4975 4996 * DESCRIPTION: 4976 4997 * Retrieves an image list handle. 4977 * 4978 * PARAMETER(S): 4979 * [I] HWND : window handle 4980 * [I] INT : image list identifier 4981 * 4998 * 4999 * PARAMETER(S): 5000 * [I] HWND : window handle 5001 * [I] INT : image list identifier 5002 * 4982 5003 * RETURN: 4983 5004 * SUCCESS : image list handle … … 4989 5010 HIMAGELIST himl = NULL; 4990 5011 4991 switch (nImageList) 5012 switch (nImageList) 4992 5013 { 4993 5014 case LVSIL_NORMAL: … … 5010 5031 * DESCRIPTION: 5011 5032 * Retrieves item attributes. 5012 * 5033 * 5013 5034 * PARAMETER(S): 5014 5035 * [I] HWND : window handle … … 5016 5037 * [I] internal : if true then we will use tricks that avoid copies 5017 5038 * but are not compatible with the regular interface 5018 * 5019 * RETURN: 5020 * SUCCESS : TRUE 5039 * 5040 * RETURN: 5041 * SUCCESS : TRUE 5021 5042 * FAILURE : FALSE 5022 5043 */ … … 5035 5056 * lpLVItem describes the information requested by the user 5036 5057 * lpItem/lpSubItem is what we have 5037 * dispInfo is a structure we use to request the missing 5058 * dispInfo is a structure we use to request the missing 5038 5059 * information from the application 5039 5060 */ … … 5062 5083 if ((lpLVItem->mask & LVIF_STATE)&&(lpLVItem->iSubItem == 0)) 5063 5084 { 5064 lpLVItem->state = 0; 5085 lpLVItem->state = 0; 5065 5086 if (infoPtr->nFocusedItem == lpLVItem->iItem) 5066 5087 lpLVItem->state |= LVIS_FOCUSED; … … 5087 5108 ppszText=&lpItem->pszText; 5088 5109 if ((infoPtr->uCallbackMask != 0) && (lpLVItem->mask & LVIF_STATE)) 5089 { 5110 { 5090 5111 dispInfo.item.mask |= LVIF_STATE; 5091 dispInfo.item.stateMask = infoPtr->uCallbackMask; 5112 dispInfo.item.stateMask = infoPtr->uCallbackMask; 5092 5113 } 5093 5114 } … … 5162 5183 lstrcpynA(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax); 5163 5184 } 5164 5185 5165 5186 if (ppszText == NULL) 5166 5187 { … … 5187 5208 5188 5209 lpLVItem->state &= ~LVIS_SELECTED; 5189 if ((dispInfo.item.stateMask & LVIS_SELECTED) && 5210 if ((dispInfo.item.stateMask & LVIS_SELECTED) && 5190 5211 (LISTVIEW_IsSelected(hwnd,dispInfo.item.iItem))) 5191 5212 lpLVItem->state |= LVIS_SELECTED; … … 5196 5217 5197 5218 lpLVItem->state &= ~LVIS_SELECTED; 5198 if ((lpLVItem->stateMask & LVIS_SELECTED) && 5219 if ((lpLVItem->stateMask & LVIS_SELECTED) && 5199 5220 (LISTVIEW_IsSelected(hwnd,lpLVItem->iItem))) 5200 5221 lpLVItem->state |= LVIS_SELECTED; … … 5235 5256 /* make sure we can get the listview info */ 5236 5257 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 5237 5258 return (-1); 5238 5259 5239 5260 return (infoPtr->nHotItem); … … 5245 5266 * DESCRIPTION: 5246 5267 * Retrieves the number of items in the listview control. 5247 * 5248 * PARAMETER(S): 5249 * [I] HWND : window handle 5250 * 5268 * 5269 * PARAMETER(S): 5270 * [I] HWND : window handle 5271 * 5251 5272 * RETURN: 5252 5273 * Number of items. … … 5262 5283 * DESCRIPTION: 5263 5284 * Retrieves the position (upper-left) of the listview control item. 5264 * 5285 * 5265 5286 * PARAMETER(S): 5266 5287 * [I] HWND : window handle … … 5272 5293 * FAILURE : FALSE 5273 5294 */ 5274 static BOOL LISTVIEW_GetItemPosition(HWND hwnd, INT nItem, 5295 static BOOL LISTVIEW_GetItemPosition(HWND hwnd, INT nItem, 5275 5296 LPPOINT lpptPosition) 5276 5297 { … … 5283 5304 INT nRow; 5284 5305 5285 TRACE("(hwnd=%x,nItem=%d,lpptPosition=%p)\n", hwnd, nItem, 5306 TRACE("(hwnd=%x,nItem=%d,lpptPosition=%p)\n", hwnd, nItem, 5286 5307 lpptPosition); 5287 5288 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && 5308 5309 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && 5289 5310 (lpptPosition != NULL)) 5290 5311 { … … 5305 5326 { 5306 5327 lpptPosition->x = (nItem / nCountPerColumn -1) * infoPtr->nItemWidth; 5307 lpptPosition->y = (nRow + nCountPerColumn) * infoPtr->nItemHeight; 5328 lpptPosition->y = (nRow + nCountPerColumn) * infoPtr->nItemHeight; 5308 5329 } 5309 5330 } … … 5319 5340 bResult = TRUE; 5320 5341 lpptPosition->x = REPORT_MARGINX; 5321 lpptPosition->y = ((nItem - ListView_GetTopIndex(hwnd)) * 5342 lpptPosition->y = ((nItem - ListView_GetTopIndex(hwnd)) * 5322 5343 infoPtr->nItemHeight) + infoPtr->rcList.top; 5323 5344 5324 5325 5326 5327 5328 5329 5345 /* Adjust position by scrollbar offset */ 5346 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 5347 scrollInfo.cbSize = sizeof(SCROLLINFO); 5348 scrollInfo.fMask = SIF_POS; 5349 GetScrollInfo(hwnd, SB_HORZ, &scrollInfo); 5350 lpptPosition->x -= scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 5330 5351 } 5331 5352 else … … 5350 5371 * DESCRIPTION: 5351 5372 * Retrieves the bounding rectangle for a listview control item. 5352 * 5373 * 5353 5374 * PARAMETER(S): 5354 5375 * [I] HWND : window handle … … 5363 5384 * LVIR_LABEL Returns the bounding rectangle of the item text. 5364 5385 * LVIR_SELECTBOUNDS Returns the union of the LVIR_ICON and LVIR_LABEL 5365 * 5366 * 5386 * rectangles, but excludes columns in report view. 5387 * 5367 5388 * RETURN: 5368 5389 * SUCCESS : TRUE … … 5397 5418 if (lvItem.iIndent>0 && infoPtr->iconSize.cx > 0) 5398 5419 { 5399 nIndent = infoPtr->iconSize.cx * lvItem.iIndent; 5400 } 5420 nIndent = infoPtr->iconSize.cx * lvItem.iIndent; 5421 } 5401 5422 else 5402 5423 nIndent = 0; … … 5404 5425 else 5405 5426 nIndent = 0; 5406 5427 5407 5428 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && (lprc != NULL)) 5408 5429 { 5409 5430 if (ListView_GetItemPosition(hwnd, nItem, &ptItem) != FALSE) 5410 5431 { 5411 switch(lprc->left) 5412 { 5413 case LVIR_ICON: 5432 switch(lprc->left) 5433 { 5434 case LVIR_ICON: 5414 5435 if (uView == LVS_ICON) 5415 5436 { … … 5422 5443 lprc->top = ptItem.y + ptOrigin.y; 5423 5444 lprc->right = lprc->left + infoPtr->iconSize.cx; 5424 lprc->bottom = (lprc->top + infoPtr->iconSize.cy + 5445 lprc->bottom = (lprc->top + infoPtr->iconSize.cy + 5425 5446 ICON_BOTTOM_PADDING + ICON_TOP_PADDING); 5426 5447 } … … 5438 5459 if (infoPtr->himlState != NULL) 5439 5460 lprc->left += infoPtr->iconSize.cx; 5440 5461 5441 5462 if (infoPtr->himlSmall != NULL) 5442 5463 lprc->right = lprc->left + infoPtr->iconSize.cx; … … 5445 5466 } 5446 5467 } 5447 else 5468 else 5448 5469 { 5449 5470 bResult = TRUE; … … 5458 5479 lprc->left += infoPtr->iconSize.cx; 5459 5480 } 5460 5481 5461 5482 if (infoPtr->himlSmall != NULL) 5462 5483 { … … 5470 5491 break; 5471 5492 5472 case LVIR_LABEL: 5493 case LVIR_LABEL: 5473 5494 if (uView == LVS_ICON) 5474 5495 { … … 5492 5513 lprc->right = lprc->left + infoPtr->iconSpacing.cx - 1; 5493 5514 } 5494 5515 5495 5516 hdc = GetDC(hwnd); 5496 5517 hOldFont = SelectObject(hdc, infoPtr->hFont); … … 5499 5520 SelectObject(hdc, hOldFont); 5500 5521 ReleaseDC(hwnd, hdc); 5501 } 5522 } 5502 5523 } 5503 5524 } … … 5507 5528 { 5508 5529 bResult = TRUE; 5509 nLeftPos = lprc->left = ptItem.x + ptOrigin.x; 5530 nLeftPos = lprc->left = ptItem.x + ptOrigin.x; 5510 5531 lprc->top = ptItem.y + ptOrigin.y; 5511 5532 lprc->bottom = lprc->top + infoPtr->nItemHeight; 5512 5533 5513 5534 if (infoPtr->himlState != NULL) 5514 5535 { 5515 5536 lprc->left += infoPtr->iconSize.cx; 5516 5537 } 5517 5538 5518 5539 if (infoPtr->himlSmall != NULL) 5519 5540 { 5520 5541 lprc->left += infoPtr->iconSize.cx; 5521 5542 } 5522 5543 5523 5544 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5524 5545 nLabelWidth += TRAILING_PADDING; … … 5538 5559 if (uView & LVS_REPORT) 5539 5560 nLeftPos = lprc->left = ptItem.x + nIndent; 5540 else 5541 nLeftPos = lprc->left = ptItem.x; 5561 else 5562 nLeftPos = lprc->left = ptItem.x; 5542 5563 lprc->top = ptItem.y; 5543 5564 lprc->bottom = lprc->top + infoPtr->nItemHeight; … … 5553 5574 } 5554 5575 5555 5576 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5556 5577 nLabelWidth += TRAILING_PADDING; 5557 5578 if (infoPtr->himlSmall) 5558 5579 nLabelWidth += IMAGE_PADDING; 5559 5560 5561 5562 5563 5564 5565 5566 5580 if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 5581 { 5582 lprc->right = lprc->left + nLabelWidth; 5583 } 5584 else 5585 { 5586 lprc->right = nLeftPos + infoPtr->nItemWidth; 5587 } 5567 5588 } 5568 5589 break; 5569 5590 5570 5591 case LVIR_BOUNDS: 5571 if (uView == LVS_ICON)5572 {5573 if (infoPtr->himlNormal != NULL)5574 {5575 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)5576 {5577 bResult = TRUE;5578 lprc->left = ptItem.x + ptOrigin.x;5579 lprc->top = ptItem.y + ptOrigin.y;5580 lprc->right = lprc->left + infoPtr->iconSpacing.cx;5581 lprc->bottom = lprc->top + infoPtr->iconSpacing.cy;5582 }5583 }5584 }5585 else if (uView == LVS_SMALLICON)5586 {5587 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)5588 {5589 bResult = TRUE;5590 lprc->left = ptItem.x + ptOrigin.x;5591 lprc->right = lprc->left;5592 lprc->top = ptItem.y + ptOrigin.y;5593 lprc->bottom = lprc->top + infoPtr->nItemHeight;5594 if (infoPtr->himlState != NULL)5595 lprc->right += infoPtr->iconSize.cx;5596 if (infoPtr->himlSmall != NULL)5597 lprc->right += infoPtr->iconSize.cx;5598 5599 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);5600 nLabelWidth += TRAILING_PADDING;5601 if (infoPtr->himlSmall)5602 nLabelWidth += IMAGE_PADDING;5603 if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth)5604 {5605 lprc->right += nLabelWidth;5606 }5607 else5608 {5609 lprc->right = lprc->left + infoPtr->nItemWidth;5610 }5611 }5612 }5613 else5614 {5615 bResult = TRUE;5616 lprc->left = ptItem.x;5617 if (!(infoPtr->dwExStyle&LVS_EX_FULLROWSELECT) && uView&LVS_REPORT)5618 lprc->left += nIndent;5619 lprc->right = lprc->left;5620 lprc->top = ptItem.y;5621 lprc->bottom = lprc->top + infoPtr->nItemHeight;5622 5623 if (infoPtr->dwExStyle & LVS_EX_FULLROWSELECT)5624 {5625 RECT br;5626 int nColumnCount = Header_GetItemCount(infoPtr->hwndHeader);5627 Header_GetItemRect(infoPtr->hwndHeader, nColumnCount-1, &br);5628 5629 lprc->right = max(lprc->left, br.right - REPORT_MARGINX);5630 }5631 else5632 {5633 if (infoPtr->himlState != NULL)5634 {5635 lprc->right += infoPtr->iconSize.cx;5636 }5637 5638 if (infoPtr->himlSmall != NULL)5639 {5640 lprc->right += infoPtr->iconSize.cx;5641 }5642 5643 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);5644 nLabelWidth += TRAILING_PADDING;5645 if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth)5646 {5647 lprc->right += nLabelWidth;5648 }5649 else5650 {5651 lprc->right = lprc->left + infoPtr->nItemWidth;5652 }5653 }5654 }5655 break;5656 5657 case LVIR_SELECTBOUNDS:5658 5592 if (uView == LVS_ICON) 5659 5593 { … … 5668 5602 lprc->bottom = lprc->top + infoPtr->iconSpacing.cy; 5669 5603 } 5670 } 5604 } 5671 5605 } 5672 5606 else if (uView == LVS_SMALLICON) … … 5675 5609 { 5676 5610 bResult = TRUE; 5677 nLeftPos= lprc->left = ptItem.x + ptOrigin.x; 5611 lprc->left = ptItem.x + ptOrigin.x; 5612 lprc->right = lprc->left; 5678 5613 lprc->top = ptItem.y + ptOrigin.y; 5679 5614 lprc->bottom = lprc->top + infoPtr->nItemHeight; 5680 5615 if (infoPtr->himlState != NULL) 5616 lprc->right += infoPtr->iconSize.cx; 5617 if (infoPtr->himlSmall != NULL) 5618 lprc->right += infoPtr->iconSize.cx; 5619 5620 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5621 nLabelWidth += TRAILING_PADDING; 5622 if (infoPtr->himlSmall) 5623 nLabelWidth += IMAGE_PADDING; 5624 if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth) 5625 { 5626 lprc->right += nLabelWidth; 5627 } 5628 else 5629 { 5630 lprc->right = lprc->left + infoPtr->nItemWidth; 5631 } 5632 } 5633 } 5634 else 5635 { 5636 bResult = TRUE; 5637 lprc->left = ptItem.x; 5638 if (!(infoPtr->dwExStyle&LVS_EX_FULLROWSELECT) && uView&LVS_REPORT) 5639 lprc->left += nIndent; 5640 lprc->right = lprc->left; 5641 lprc->top = ptItem.y; 5642 lprc->bottom = lprc->top + infoPtr->nItemHeight; 5643 5644 if (infoPtr->dwExStyle & LVS_EX_FULLROWSELECT) 5645 { 5646 RECT br; 5647 int nColumnCount = Header_GetItemCount(infoPtr->hwndHeader); 5648 Header_GetItemRect(infoPtr->hwndHeader, nColumnCount-1, &br); 5649 5650 lprc->right = max(lprc->left, br.right - REPORT_MARGINX); 5651 } 5652 else 5653 { 5654 if (infoPtr->himlState != NULL) 5655 { 5656 lprc->right += infoPtr->iconSize.cx; 5657 } 5658 5659 if (infoPtr->himlSmall != NULL) 5660 { 5661 lprc->right += infoPtr->iconSize.cx; 5662 } 5663 5664 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5665 nLabelWidth += TRAILING_PADDING; 5666 if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth) 5667 { 5668 lprc->right += nLabelWidth; 5669 } 5670 else 5671 { 5672 lprc->right = lprc->left + infoPtr->nItemWidth; 5673 } 5674 } 5675 } 5676 break; 5677 5678 case LVIR_SELECTBOUNDS: 5679 if (uView == LVS_ICON) 5680 { 5681 if (infoPtr->himlNormal != NULL) 5682 { 5683 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 5684 { 5685 bResult = TRUE; 5686 lprc->left = ptItem.x + ptOrigin.x; 5687 lprc->top = ptItem.y + ptOrigin.y; 5688 lprc->right = lprc->left + infoPtr->iconSpacing.cx; 5689 lprc->bottom = lprc->top + infoPtr->iconSpacing.cy; 5690 } 5691 } 5692 } 5693 else if (uView == LVS_SMALLICON) 5694 { 5695 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 5696 { 5697 bResult = TRUE; 5698 nLeftPos= lprc->left = ptItem.x + ptOrigin.x; 5699 lprc->top = ptItem.y + ptOrigin.y; 5700 lprc->bottom = lprc->top + infoPtr->nItemHeight; 5701 5681 5702 if (infoPtr->himlState != NULL) 5682 5703 { 5683 5704 lprc->left += infoPtr->iconSize.cx; 5684 5705 } 5685 5706 5686 5707 lprc->right = lprc->left; 5687 5708 5688 5709 if (infoPtr->himlSmall != NULL) 5689 5710 { 5690 5711 lprc->right += infoPtr->iconSize.cx; 5691 5712 } 5692 5693 5713 5714 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5694 5715 nLabelWidth += TRAILING_PADDING; 5695 5696 5697 5698 5699 5700 5701 5702 5716 if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 5717 { 5718 lprc->right += nLabelWidth; 5719 } 5720 else 5721 { 5722 lprc->right = nLeftPos + infoPtr->nItemWidth; 5723 } 5703 5724 } 5704 5725 } … … 5707 5728 bResult = TRUE; 5708 5729 if (!(infoPtr->dwExStyle&LVS_EX_FULLROWSELECT) && (uView&LVS_REPORT)) 5709 nLeftPos = lprc->left = ptItem.x + nIndent; 5730 nLeftPos = lprc->left = ptItem.x + nIndent; 5710 5731 else 5711 nLeftPos = lprc->left = ptItem.x; 5732 nLeftPos = lprc->left = ptItem.x; 5712 5733 lprc->top = ptItem.y; 5713 5734 lprc->bottom = lprc->top + infoPtr->nItemHeight; … … 5717 5738 lprc->left += infoPtr->iconSize.cx; 5718 5739 } 5719 5740 5720 5741 lprc->right = lprc->left; 5721 5742 5722 5743 if (infoPtr->dwExStyle & LVS_EX_FULLROWSELECT) 5723 5744 { 5724 5725 5726 5745 RECT br; 5746 int nColumnCount = Header_GetItemCount(infoPtr->hwndHeader); 5747 Header_GetItemRect(infoPtr->hwndHeader, nColumnCount-1, &br); 5727 5748 5728 5749 lprc->right = max(lprc->left, br.right - REPORT_MARGINX); … … 5735 5756 } 5736 5757 5737 5758 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5738 5759 nLabelWidth += TRAILING_PADDING; 5739 5760 if (infoPtr->himlSmall) 5740 5761 nLabelWidth += IMAGE_PADDING; 5741 5742 5743 5744 5745 5746 5747 5748 5762 if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 5763 { 5764 lprc->right += nLabelWidth; 5765 } 5766 else 5767 { 5768 lprc->right = nLeftPos + infoPtr->nItemWidth; 5769 } 5749 5770 } 5750 5771 } … … 5759 5780 * DESCRIPTION: 5760 5781 * Retrieves the width of a label. 5761 * 5762 * PARAMETER(S): 5763 * [I] HWND : window handle 5764 * 5782 * 5783 * PARAMETER(S): 5784 * [I] HWND : window handle 5785 * 5765 5786 * RETURN: 5766 5787 * SUCCESS : string width (in pixels) … … 5782 5803 if (LISTVIEW_GetItemA(hwnd, &lvItem, TRUE) != FALSE) 5783 5804 { 5784 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 5785 } 5786 5805 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 5806 } 5807 5787 5808 return nLabelWidth; 5788 5809 } … … 5791 5812 * DESCRIPTION: 5792 5813 * Retrieves the spacing between listview control items. 5793 * 5794 * PARAMETER(S): 5795 * [I] HWND : window handle 5796 * [I] BOOL : flag for small or large icon 5814 * 5815 * PARAMETER(S): 5816 * [I] HWND : window handle 5817 * [I] BOOL : flag for small or large icon 5797 5818 * 5798 5819 * RETURN: … … 5826 5847 * DESCRIPTION: 5827 5848 * Retrieves the state of a listview control item. 5828 * 5849 * 5829 5850 * PARAMETER(S): 5830 5851 * [I] HWND : window handle 5831 5852 * [I] INT : item index 5832 5853 * [I] UINT : state mask 5833 * 5854 * 5834 5855 * RETURN: 5835 5856 * State specified by the mask. … … 5858 5879 /*** 5859 5880 * DESCRIPTION: 5860 * Retrieves the text of a listview control item or subitem. 5861 * 5881 * Retrieves the text of a listview control item or subitem. 5882 * 5862 5883 * PARAMETER(S): 5863 5884 * [I] HWND : window handle 5864 5885 * [I] INT : item index 5865 5886 * [IO] LPLVITEMA : item information 5866 * 5887 * 5867 5888 * RETURN: 5868 5889 * SUCCESS : string length … … 5873 5894 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5874 5895 INT nLength = 0; 5875 5896 5876 5897 if (lpLVItem != NULL) 5877 5898 { … … 5893 5914 * DESCRIPTION: 5894 5915 * Searches for an item based on properties + relationships. 5895 * 5916 * 5896 5917 * PARAMETER(S): 5897 5918 * [I] HWND : window handle 5898 5919 * [I] INT : item index 5899 5920 * [I] INT : relationship flag 5900 * 5921 * 5901 5922 * RETURN: 5902 5923 * SUCCESS : item index … … 5911 5932 INT nCountPerColumn; 5912 5933 INT i; 5913 5934 5914 5935 if ((nItem >= -1) && (nItem < GETITEMCOUNT(infoPtr))) 5915 { 5936 { 5916 5937 ZeroMemory(&lvFindInfo, sizeof(LVFINDINFO)); 5917 5938 5918 5939 if (uFlags & LVNI_CUT) 5919 5940 uMask |= LVIS_CUT; 5920 5941 5921 5942 if (uFlags & LVNI_DROPHILITED) 5922 5943 uMask |= LVIS_DROPHILITED; 5923 5944 5924 5945 if (uFlags & LVNI_FOCUSED) 5925 5946 uMask |= LVIS_FOCUSED; … … 6043 6064 * DESCRIPTION: 6044 6065 * Retrieves the origin coordinates when in icon or small icon display mode. 6045 * 6066 * 6046 6067 * PARAMETER(S): 6047 6068 * [I] HWND : window handle 6048 6069 * [O] LPPOINT : coordinate information 6049 * 6070 * 6050 6071 * RETURN: 6051 6072 * SUCCESS : TRUE … … 6057 6078 UINT uView = lStyle & LVS_TYPEMASK; 6058 6079 BOOL bResult = FALSE; 6059 6080 6060 6081 TRACE("(hwnd=%x, lpptOrigin=%p)\n", hwnd, lpptOrigin); 6061 6082 … … 6070 6091 { 6071 6092 scrollInfo.fMask = SIF_POS; 6072 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 6073 { 6074 lpptOrigin->x = -scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 6093 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 6094 { 6095 lpptOrigin->x = -scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 6075 6096 } 6076 6097 } … … 6084 6105 } 6085 6106 } 6086 6107 6087 6108 bResult = TRUE; 6088 6109 } 6089 6110 6090 6111 return bResult; 6091 6112 } … … 6094 6115 * DESCRIPTION: 6095 6116 * Retrieves the number of items that are marked as selected. 6096 * 6097 * PARAMETER(S): 6098 * [I] HWND : window handle 6099 * 6117 * 6118 * PARAMETER(S): 6119 * [I] HWND : window handle 6120 * 6100 6121 * RETURN: 6101 6122 * Number of items selected. … … 6115 6136 } 6116 6137 } 6117 6138 6118 6139 return nSelectedCount; 6119 6140 } … … 6122 6143 * DESCRIPTION: 6123 6144 * Retrieves item index that marks the start of a multiple selection. 6124 * 6125 * PARAMETER(S): 6126 * [I] HWND : window handle 6127 * 6145 * 6146 * PARAMETER(S): 6147 * [I] HWND : window handle 6148 * 6128 6149 * RETURN: 6129 6150 * Index number or -1 if there is no selection mark. … … 6139 6160 * DESCRIPTION: 6140 6161 * Retrieves the width of a string. 6141 * 6142 * PARAMETER(S): 6143 * [I] HWND : window handle 6144 * 6162 * 6163 * PARAMETER(S): 6164 * [I] HWND : window handle 6165 * 6145 6166 * RETURN: 6146 6167 * SUCCESS : string width (in pixels) … … 6151 6172 { 6152 6173 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6174 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); 6153 6175 HFONT hFont, hOldFont; 6154 6176 SIZE stringSize; … … 6173 6195 SelectObject(hdc, hOldFont); 6174 6196 ReleaseDC(hwnd, hdc); 6197 } 6198 if(dwStyle & LVS_OWNERDRAWFIXED) { 6199 /* Get item width */ 6200 6201 MEASUREITEMSTRUCT mis; 6202 UINT id = GetWindowLongA(hwnd,GWL_ID); 6203 6204 mis.CtlType = ODT_LISTVIEW; 6205 mis.CtlID = id; 6206 mis.itemID = 0; 6207 mis.itemData = 0; //TODO:!!!! 6208 mis.itemHeight = 0; 6209 mis.itemWidth = 0; 6210 SendMessageA(GetParent(hwnd), WM_MEASUREITEM, id, (LPARAM)&mis ); 6211 stringSize.cx = (mis.itemWidth) ? mis.itemWidth : infoPtr->nItemWidth; 6175 6212 } 6176 6213 } … … 6204 6241 * DESCRIPTION: 6205 6242 * Retrieves the text backgound color. 6206 * 6207 * PARAMETER(S): 6208 * [I] HWND : window handle 6209 * 6243 * 6244 * PARAMETER(S): 6245 * [I] HWND : window handle 6246 * 6210 6247 * RETURN: 6211 6248 * COLORREF associated with the the background. … … 6221 6258 * DESCRIPTION: 6222 6259 * Retrieves the text color. 6223 * 6224 * PARAMETER(S): 6225 * [I] HWND : window handle 6226 * 6260 * 6261 * PARAMETER(S): 6262 * [I] HWND : window handle 6263 * 6227 6264 * RETURN: 6228 6265 * COLORREF associated with the text. … … 6238 6275 * DESCRIPTION: 6239 6276 * Determines which section of the item was selected (if any). 6240 * 6277 * 6241 6278 * PARAMETER(S): 6242 6279 * [I] HWND : window handle … … 6264 6301 if (uView == LVS_REPORT) 6265 6302 { 6266 bottomindex = topindex + LISTVIEW_GetCountPerColumn(hwnd) + 1; 6303 bottomindex = topindex + LISTVIEW_GetCountPerColumn(hwnd) + 1; 6267 6304 bottomindex = min(bottomindex,GETITEMCOUNT(infoPtr)); 6268 6305 } … … 6290 6327 } 6291 6328 } 6292 6329 6293 6330 rcItem.left = LVIR_LABEL; 6294 6331 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE) … … 6302 6339 } 6303 6340 } 6304 6341 6305 6342 lpHitTestInfo->flags = LVHT_ONITEMSTATEICON; 6306 6343 lpHitTestInfo->iItem = i; … … 6310 6347 } 6311 6348 } 6312 6349 6313 6350 lpHitTestInfo->flags = LVHT_NOWHERE; 6314 6351 … … 6319 6356 * DESCRIPTION: 6320 6357 * Determines which listview item is located at the specified position. 6321 * 6358 * 6322 6359 * PARAMETER(S): 6323 6360 * [I] HWND : window handle … … 6339 6376 lpHitTestInfo->flags = LVHT_TOLEFT; 6340 6377 } 6341 else if (infoPtr->rcList.right < lpHitTestInfo->pt.x) 6378 else if (infoPtr->rcList.right < lpHitTestInfo->pt.x) 6342 6379 { 6343 6380 lpHitTestInfo->flags = LVHT_TORIGHT; … … 6347 6384 lpHitTestInfo->flags |= LVHT_ABOVE; 6348 6385 } 6349 else if (infoPtr->rcList.bottom < lpHitTestInfo->pt.y) 6386 else if (infoPtr->rcList.bottom < lpHitTestInfo->pt.y) 6350 6387 { 6351 6388 lpHitTestInfo->flags |= LVHT_BELOW; … … 6354 6391 if (lpHitTestInfo->flags == 0) 6355 6392 { 6356 /* NOTE (mm 20001022): We must not allow iSubItem to be touched, for 6393 /* NOTE (mm 20001022): We must not allow iSubItem to be touched, for 6357 6394 * an app might pass only a structure with space up to iItem! 6358 6395 * (MS Office 97 does that for instance in the file open dialog) … … 6360 6397 nItem = LISTVIEW_HitTestItem(hwnd, lpHitTestInfo, FALSE); 6361 6398 } 6362 6399 6363 6400 return nItem; 6364 6401 } … … 6367 6404 * DESCRIPTION: 6368 6405 * Inserts a new column. 6369 * 6406 * 6370 6407 * PARAMETER(S): 6371 6408 * [I] HWND : window handle … … 6377 6414 * FAILURE : -1 6378 6415 */ 6379 static LRESULT LISTVIEW_InsertColumnA(HWND hwnd, INT nColumn, 6416 static LRESULT LISTVIEW_InsertColumnA(HWND hwnd, INT nColumn, 6380 6417 LPLVCOLUMNA lpColumn) 6381 6418 { … … 6384 6421 INT nNewColumn = -1; 6385 6422 6386 TRACE("(hwnd=%x, nColumn=%d, lpColumn=%p)\n",hwnd, nColumn, 6423 TRACE("(hwnd=%x, nColumn=%d, lpColumn=%p)\n",hwnd, nColumn, 6387 6424 lpColumn); 6388 6425 6389 if (lpColumn != NULL) 6426 if (lpColumn != NULL) 6390 6427 { 6391 6428 /* initialize memory */ 6392 6429 ZeroMemory(&hdi, sizeof(HDITEMA)); 6393 6430 6394 if (lpColumn->mask & LVCF_FMT) 6431 if (lpColumn->mask & LVCF_FMT) 6395 6432 { 6396 6433 /* format member is valid */ … … 6417 6454 } 6418 6455 } 6419 6456 6420 6457 if (lpColumn->fmt & LVCFMT_BITMAP_ON_RIGHT) 6421 6458 { … … 6428 6465 /* ??? */ 6429 6466 } 6430 6467 6431 6468 if (lpColumn->fmt & LVCFMT_IMAGE) 6432 6469 { … … 6436 6473 } 6437 6474 6438 if (lpColumn->mask & LVCF_WIDTH) 6475 if (lpColumn->mask & LVCF_WIDTH) 6439 6476 { 6440 6477 hdi.mask |= HDI_WIDTH; 6441 6478 hdi.cxy = lpColumn->cx; 6442 6479 } 6443 6444 if (lpColumn->mask & LVCF_TEXT) 6480 6481 if (lpColumn->mask & LVCF_TEXT) 6445 6482 { 6446 6483 hdi.mask |= HDI_TEXT | HDI_FORMAT; … … 6449 6486 hdi.fmt |= HDF_STRING; 6450 6487 } 6451 6452 if (lpColumn->mask & LVCF_IMAGE) 6488 6489 if (lpColumn->mask & LVCF_IMAGE) 6453 6490 { 6454 6491 hdi.mask |= HDI_IMAGE; … … 6456 6493 } 6457 6494 6458 if (lpColumn->mask & LVCF_ORDER) 6495 if (lpColumn->mask & LVCF_ORDER) 6459 6496 { 6460 6497 hdi.mask |= HDI_ORDER; … … 6465 6502 nNewColumn = SendMessageA(infoPtr->hwndHeader, HDM_INSERTITEMA, 6466 6503 (WPARAM)nColumn, (LPARAM)&hdi); 6467 6504 6468 6505 /* Need to reset the item width when inserting a new column */ 6469 6506 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); … … 6476 6513 } 6477 6514 6478 static LRESULT LISTVIEW_InsertColumnW(HWND hwnd, INT nColumn, 6515 static LRESULT LISTVIEW_InsertColumnW(HWND hwnd, INT nColumn, 6479 6516 LPLVCOLUMNW lpColumn) 6480 6517 { 6481 LVCOLUMNA 6482 LRESULT 6483 6518 LVCOLUMNA lvca; 6519 LRESULT lres; 6520 6484 6521 memcpy(&lvca,lpColumn,sizeof(lvca)); 6485 6522 if (lpColumn->mask & LVCF_TEXT) { … … 6506 6543 (remarks on LVITEM: LVM_INSERTITEM will insert the new item in the proper sort postion... 6507 6544 if: 6508 LVS_SORTXXX must be specified, 6509 LVS_OWNERDRAW is not set, 6545 LVS_SORTXXX must be specified, 6546 LVS_OWNERDRAW is not set, 6510 6547 <item>.pszText is not LPSTR_TEXTCALLBACK. 6511 6548 6512 (LVS_SORT* flags): "For the LVS_SORTASCENDING... styles, item indices 6513 are sorted based on item text..." 6549 (LVS_SORT* flags): "For the LVS_SORTASCENDING... styles, item indices 6550 are sorted based on item text..." 6514 6551 */ 6515 6552 static INT WINAPI LISTVIEW_InsertCompare( LPVOID first, LPVOID second, LPARAM lParam) … … 6528 6565 * nESCRIPTION: 6529 6566 * Inserts a new item in the listview control. 6530 * 6567 * 6531 6568 * PARAMETER(S): 6532 6569 * [I] HWND : window handle … … 6577 6614 { 6578 6615 if ( ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING)) 6579 6580 6581 6582 6583 6584 nItem = DPA_InsertPtr( infoPtr->hdpaItems, 6585 6586 6587 6588 6589 6590 6591 nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem, 6616 && !(lStyle & LVS_OWNERDRAWFIXED) 6617 && (LPSTR_TEXTCALLBACKA != lpLVItem->pszText) ) 6618 { 6619 /* Insert the item in the proper sort order based on the pszText 6620 member. See comments for LISTVIEW_InsertCompare() for greater detail */ 6621 nItem = DPA_InsertPtr( infoPtr->hdpaItems, 6622 GETITEMCOUNT( infoPtr ) + 1, hdpaSubItems ); 6623 DPA_Sort( infoPtr->hdpaItems, LISTVIEW_InsertCompare, hwnd ); 6624 nItem = DPA_GetPtrIndex( infoPtr->hdpaItems, hdpaSubItems ); 6625 } 6626 else 6627 { 6628 nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem, 6592 6629 hdpaSubItems); 6593 6630 } 6594 6631 if (nItem != -1) 6595 6632 { … … 6599 6636 if (lpLVItem->mask & LVIF_STATE) 6600 6637 { 6601 6638 lpItem->state &= ~(LVIS_FOCUSED|LVIS_SELECTED); 6602 6639 if (lpLVItem->stateMask & LVIS_SELECTED) 6603 6640 { 6604 6641 LISTVIEW_SetSelection(hwnd, nItem); 6605 6606 6642 } 6643 else if (lpLVItem->stateMask & LVIS_FOCUSED) 6607 6644 { 6608 6645 LISTVIEW_SetItemFocus(hwnd, nItem); 6609 } 6646 } 6610 6647 } 6611 6648 6612 6649 /* send LVN_INSERTITEM notification */ 6613 6650 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); … … 6618 6655 nmlv.lParam = lpItem->lParam;; 6619 6656 ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv); 6620 6657 6621 6658 if ((uView == LVS_SMALLICON) || (uView == LVS_LIST)) 6622 6623 nItemWidth = LISTVIEW_CalculateWidth(hwnd, lpLVItem->iItem); 6624 6625 6626 6627 6628 6659 { 6660 nItemWidth = LISTVIEW_CalculateWidth(hwnd, lpLVItem->iItem); 6661 if (nItemWidth > infoPtr->nItemWidth) 6662 { 6663 infoPtr->nItemWidth = nItemWidth; 6664 } 6665 } 6629 6666 6630 6667 /* align items (set position of each item) */ … … 6640 6677 } 6641 6678 } 6642 6679 6643 6680 LISTVIEW_UpdateScroll(hwnd); 6644 6681 /* refresh client area */ … … 6657 6694 COMCTL32_Free(lpItem); 6658 6695 } 6659 6696 6660 6697 return nItem; 6661 6698 } … … 6685 6722 * DESCRIPTION: 6686 6723 * Redraws a range of items. 6687 * 6724 * 6688 6725 * PARAMETER(S): 6689 6726 * [I] HWND : window handle … … 6697 6734 static LRESULT LISTVIEW_RedrawItems(HWND hwnd, INT nFirst, INT nLast) 6698 6735 { 6699 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6736 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6700 6737 BOOL bResult = FALSE; 6701 6738 RECT rcItem; … … 6710 6747 for (i = nFirst; i <= nLast; i++) 6711 6748 { 6712 6713 6714 6749 rcItem.left = LVIR_BOUNDS; 6750 LISTVIEW_GetItemRect(hwnd, i, &rcItem); 6751 InvalidateRect(hwnd, &rcItem, TRUE); 6715 6752 } 6716 6753 } … … 6726 6763 * DESCRIPTION: 6727 6764 * Sets the background color. 6728 * 6765 * 6729 6766 * PARAMETER(S): 6730 6767 * [I] HWND : window handle … … 6741 6778 infoPtr->clrBk = clrBk; 6742 6779 InvalidateRect(hwnd, NULL, TRUE); 6743 6780 6744 6781 return TRUE; 6745 6782 } … … 6751 6788 * Sets the callback mask. This mask will be used when the parent 6752 6789 * window stores state information (some or all). 6753 * 6790 * 6754 6791 * PARAMETER(S): 6755 6792 * [I] HWND : window handle … … 6772 6809 * DESCRIPTION: 6773 6810 * Sets the attributes of a header item. 6774 * 6811 * 6775 6812 * PARAMETER(S): 6776 6813 * [I] HWND : window handle … … 6782 6819 * FAILURE : FALSE 6783 6820 */ 6784 static LRESULT LISTVIEW_SetColumnA(HWND hwnd, INT nColumn, 6821 static LRESULT LISTVIEW_SetColumnA(HWND hwnd, INT nColumn, 6785 6822 LPLVCOLUMNA lpColumn) 6786 6823 { … … 6789 6826 HDITEMA hdi, hdiget; 6790 6827 6791 if ((lpColumn != NULL) && (nColumn >= 0) && 6828 if ((lpColumn != NULL) && (nColumn >= 0) && 6792 6829 (nColumn < Header_GetItemCount(infoPtr->hwndHeader))) 6793 6830 { … … 6795 6832 ZeroMemory(&hdi, sizeof(HDITEMA)); 6796 6833 6797 if (lpColumn->mask & LVCF_FMT) 6834 if (lpColumn->mask & LVCF_FMT) 6798 6835 { 6799 6836 /* format member is valid */ … … 6803 6840 hdiget.mask = HDI_FORMAT; 6804 6841 if (Header_GetItemA(infoPtr->hwndHeader, nColumn, &hdiget)) 6805 6806 6842 /* preserve HDF_STRING if present */ 6843 hdi.fmt = hdiget.fmt & HDF_STRING; 6807 6844 6808 6845 /* set text alignment (leftmost column must be left-aligned) */ … … 6826 6863 } 6827 6864 } 6828 6865 6829 6866 if (lpColumn->fmt & LVCFMT_BITMAP_ON_RIGHT) 6830 6867 { … … 6836 6873 hdi.fmt |= HDF_IMAGE; 6837 6874 } 6838 6875 6839 6876 if (lpColumn->fmt & LVCFMT_IMAGE) 6840 6877 { … … 6844 6881 } 6845 6882 6846 if (lpColumn->mask & LVCF_WIDTH) 6883 if (lpColumn->mask & LVCF_WIDTH) 6847 6884 { 6848 6885 hdi.mask |= HDI_WIDTH; 6849 6886 hdi.cxy = lpColumn->cx; 6850 6887 } 6851 6852 if (lpColumn->mask & LVCF_TEXT) 6888 6889 if (lpColumn->mask & LVCF_TEXT) 6853 6890 { 6854 6891 hdi.mask |= HDI_TEXT | HDI_FORMAT; … … 6857 6894 hdi.fmt |= HDF_STRING; 6858 6895 } 6859 6860 if (lpColumn->mask & LVCF_IMAGE) 6896 6897 if (lpColumn->mask & LVCF_IMAGE) 6861 6898 { 6862 6899 hdi.mask |= HDI_IMAGE; … … 6864 6901 } 6865 6902 6866 if (lpColumn->mask & LVCF_ORDER) 6903 if (lpColumn->mask & LVCF_ORDER) 6867 6904 { 6868 6905 hdi.mask |= HDI_ORDER; … … 6873 6910 bResult = Header_SetItemA(infoPtr->hwndHeader, nColumn, &hdi); 6874 6911 } 6875 6912 6876 6913 return bResult; 6877 6914 } … … 6899 6936 6900 6937 if (!lpiArray) 6901 6938 return FALSE; 6902 6939 6903 6940 return TRUE; … … 6924 6961 LRESULT lret; 6925 6962 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 6926 UINT uView = lStyle & LVS_TYPEMASK; 6963 UINT uView = lStyle & LVS_TYPEMASK; 6927 6964 HDC hdc; 6928 6965 HFONT header_font; … … 6944 6981 /* set column width only if in report or list mode */ 6945 6982 if ((uView != LVS_REPORT) && (uView != LVS_LIST)) 6946 return (FALSE); 6983 return (FALSE); 6947 6984 6948 6985 /* take care of invalid cx values */ … … 6951 6988 else if (uView == LVS_LIST && (cx < 1)) 6952 6989 return FALSE; 6953 6990 6954 6991 /* resize all columns if in LVS_LIST mode */ 6955 6992 if(uView == LVS_LIST) { … … 6967 7004 if(cx < LISTVIEW_GetLabelWidth(hwnd, item_index)) 6968 7005 cx = LISTVIEW_GetLabelWidth(hwnd, item_index); 6969 } 7006 } 6970 7007 } /* autosize based on listview header width */ 6971 7008 else if(cx == LVSCW_AUTOSIZE_USEHEADER) 6972 7009 { 6973 7010 header_item_count = Header_GetItemCount(infoPtr->hwndHeader); 6974 7011 6975 7012 /* if iCol is the last column make it fill the remainder of the controls width */ 6976 7013 if(iCol == (header_item_count - 1)) { … … 6978 7015 hdi.mask = HDI_WIDTH; 6979 7016 cx = 0; 6980 7017 6981 7018 for(item_index = 0; item_index < (header_item_count - 1); item_index++) { 6982 7019 Header_GetItemA(infoPtr->hwndHeader, item_index, (LPARAM)(&hdi)); 6983 7020 cx+=hdi.cxy; 6984 7021 } 6985 7022 6986 7023 /* retrieve the layout of the header */ 6987 7024 GetWindowRect(infoPtr->hwndHeader, &rcHeader); 6988 7025 6989 7026 cx = (rcHeader.right - rcHeader.left) - cx; 6990 } 7027 } 6991 7028 else 6992 7029 { 6993 7030 /* retrieve header font */ 6994 7031 header_font = SendMessageA(infoPtr->hwndHeader, WM_GETFONT, 0L, 0L); 6995 7032 6996 7033 /* retrieve header text */ 6997 7034 hdi.mask = HDI_TEXT; 6998 7035 hdi.cchTextMax = sizeof(text_buffer); 6999 hdi.pszText = text_buffer; 7000 7036 hdi.pszText = text_buffer; 7037 7001 7038 Header_GetItemA(infoPtr->hwndHeader, iCol, (LPARAM)(&hdi)); 7002 7039 7003 7040 /* determine the width of the text in the header */ 7004 7041 hdc = GetDC(hwnd); … … 7006 7043 7007 7044 GetTextExtentPoint32A(hdc, text_buffer, strlen(text_buffer), &size); 7008 7009 SelectObject(hdc, old_font); /* restore the old font */ 7045 7046 SelectObject(hdc, old_font); /* restore the old font */ 7010 7047 ReleaseDC(hwnd, hdc); 7011 7048 7012 7049 /* set the width of this column to the width of the text */ 7013 7050 cx = size.cx; … … 7016 7053 7017 7054 /* call header to update the column change */ 7018 hdi.mask = HDI_WIDTH; 7055 hdi.mask = HDI_WIDTH; 7019 7056 7020 7057 hdi.cxy = cx; 7021 7058 lret = Header_SetItemA(infoPtr->hwndHeader, (WPARAM)iCol, (LPARAM)&hdi); 7022 7059 7023 7060 InvalidateRect(hwnd, NULL, TRUE); /* force redraw of the listview */ 7024 7061 7025 7062 return lret; 7026 7063 } … … 7046 7083 /* make sure we can get the listview info */ 7047 7084 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 7048 7085 return (0); 7049 7086 7050 7087 /* store previous style */ … … 7081 7118 /* make sure we can get the listview info */ 7082 7119 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 7083 7120 return (-1); 7084 7121 7085 7122 /* store previous index */ … … 7118 7155 * DESCRIPTION: 7119 7156 * Sets image lists. 7120 * 7121 * PARAMETER(S): 7122 * [I] HWND : window handle 7123 * [I] INT : image list type 7157 * 7158 * PARAMETER(S): 7159 * [I] HWND : window handle 7160 * [I] INT : image list type 7124 7161 * [I] HIMAGELIST : image list handle 7125 7162 * … … 7134 7171 INT oldHeight; 7135 7172 7136 switch (nType) 7173 switch (nType) 7137 7174 { 7138 7175 case LVSIL_NORMAL: … … 7165 7202 * DESCRIPTION: 7166 7203 * Sets the attributes of an item. 7167 * 7168 * PARAMETER(S): 7169 * [I] HWND : window handle 7170 * [I] LPLVITEM : item information 7204 * 7205 * PARAMETER(S): 7206 * [I] HWND : window handle 7207 * [I] LPLVITEM : item information 7171 7208 * 7172 7209 * RETURN: … … 7203 7240 * DESCRIPTION: 7204 7241 * Preallocates memory (does *not* set the actual count of items !) 7205 * 7242 * 7206 7243 * PARAMETER(S): 7207 7244 * [I] HWND : window handle … … 7223 7260 7224 7261 /* 7225 * Internally remove all the selections. 7262 * Internally remove all the selections. 7226 7263 */ 7227 7264 do … … 7234 7271 } 7235 7272 while (infoPtr->hdpaSelectionRanges->nItemCount>0); 7236 7273 7237 7274 precount = infoPtr->hdpaItems->nItemCount; 7238 7275 topvisible = ListView_GetTopIndex(hwnd) + … … 7243 7280 LISTVIEW_UpdateSize(hwnd); 7244 7281 LISTVIEW_UpdateScroll(hwnd); 7245 if (min(precount,infoPtr->hdpaItems->nItemCount)<topvisible) 7282 if (min(precount,infoPtr->hdpaItems->nItemCount)<topvisible) 7246 7283 InvalidateRect(hwnd, NULL, TRUE); 7247 7284 } … … 7257 7294 * DESCRIPTION: 7258 7295 * Sets the position of an item. 7259 * 7296 * 7260 7297 * PARAMETER(S): 7261 7298 * [I] HWND : window handle … … 7279 7316 7280 7317 TRACE("(hwnd=%x,nItem=%d,X=%ld,Y=%ld)\n", hwnd, nItem, nPosX, nPosY); 7281 7318 7282 7319 if (lStyle & LVS_OWNERDATA) 7283 7320 return FALSE; … … 7307 7344 * DESCRIPTION: 7308 7345 * Sets the state of one or many items. 7309 * 7346 * 7310 7347 * PARAMETER(S): 7311 7348 * [I] HWND : window handle … … 7331 7368 lvItem.state = lpLVItem->state; 7332 7369 lvItem.stateMask = lpLVItem->stateMask ; 7333 7370 7334 7371 /* apply to all items */ 7335 7372 for (i = 0; i< GETITEMCOUNT(infoPtr); i++) … … 7358 7395 * DESCRIPTION: 7359 7396 * Sets the text of an item or subitem. 7360 * 7397 * 7361 7398 * PARAMETER(S): 7362 7399 * [I] HWND : window handle … … 7383 7420 bResult = ListView_SetItemA(hwnd, &lvItem); 7384 7421 } 7385 7422 7386 7423 return bResult; 7387 7424 } … … 7413 7450 * DESCRIPTION: 7414 7451 * Sets the text background color. 7415 * 7452 * 7416 7453 * PARAMETER(S): 7417 7454 * [I] HWND : window handle … … 7435 7472 * DESCRIPTION: 7436 7473 * Sets the text foreground color. 7437 * 7438 * PARAMETER(S): 7439 * [I] HWND : window handle 7440 * [I] COLORREF : text color 7474 * 7475 * PARAMETER(S): 7476 * [I] HWND : window handle 7477 * [I] COLORREF : text color 7441 7478 * 7442 7479 * RETURN: … … 7461 7498 * DESCRIPTION: 7462 7499 * Callback internally used by LISTVIEW_SortItems() 7463 * 7500 * 7464 7501 * PARAMETER(S): 7465 7502 * [I] LPVOID : first LISTVIEW_ITEM to compare … … 7472 7509 * if first and second are equivalent : zero 7473 7510 */ 7474 static INT WINAPI LISTVIEW_CallBackCompare( 7475 LPVOID first, 7476 LPVOID second, 7511 static INT WINAPI LISTVIEW_CallBackCompare( 7512 LPVOID first, 7513 LPVOID second, 7477 7514 LPARAM lParam) 7478 7515 { … … 7494 7531 * DESCRIPTION: 7495 7532 * Sorts the listview items. 7496 * 7533 * 7497 7534 * PARAMETER(S): 7498 7535 * [I] HWND : window handle … … 7517 7554 7518 7555 if (!infoPtr || !infoPtr->hdpaItems) 7519 7520 7556 return FALSE; 7557 7521 7558 nCount = GETITEMCOUNT(infoPtr); 7522 7559 /* if there are 0 or 1 items, there is no need to sort */ … … 7528 7565 DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, hwnd); 7529 7566 7530 /* Adjust selections and indices so that they are the way they should 7531 * be after the sort (otherwise, the list items move around, but 7532 * whatever is at the item's previous original position will be 7567 /* Adjust selections and indices so that they are the way they should 7568 * be after the sort (otherwise, the list items move around, but 7569 * whatever is at the item's previous original position will be 7533 7570 * selected instead) 7534 7571 */ … … 7564 7601 * DESCRIPTION: 7565 7602 * Updates an items or rearranges the listview control. 7566 * 7603 * 7567 7604 * PARAMETER(S): 7568 7605 * [I] HWND : window handle … … 7604 7641 * DESCRIPTION: 7605 7642 * Creates the listview control. 7606 * 7643 * 7607 7644 * PARAMETER(S): 7608 7645 * [I] HWND : window handle … … 7622 7659 7623 7660 /* determine the type of structures to use */ 7624 infoPtr->notifyFormat = SendMessageA(GetParent(hwnd), WM_NOTIFYFORMAT, 7661 infoPtr->notifyFormat = SendMessageA(GetParent(hwnd), WM_NOTIFYFORMAT, 7625 7662 (WPARAM)hwnd, (LPARAM)NF_QUERY); 7626 7663 if (infoPtr->notifyFormat != NFR_ANSI) … … 7628 7665 FIXME("ANSI notify format is NOT used\n"); 7629 7666 } 7630 7667 7631 7668 /* initialize color information */ 7632 7669 infoPtr->clrBk = GetSysColor(COLOR_WINDOW); … … 7650 7687 infoPtr->hDefaultFont = CreateFontIndirectA(&logFont); 7651 7688 infoPtr->hFont = infoPtr->hDefaultFont; 7652 7689 7653 7690 /* create header */ 7654 infoPtr->hwndHeader = CreateWindowA(WC_HEADERA, (LPCSTR)NULL,7655 WS_CHILD | HDS_HORZ | HDS_BUTTONS, 7656 0, 0, 0, 0, hwnd, (HMENU)0, 7691 infoPtr->hwndHeader = CreateWindowA(WC_HEADERA, (LPCSTR)NULL, 7692 WS_CHILD | HDS_HORZ | HDS_BUTTONS, 7693 0, 0, 0, 0, hwnd, (HMENU)0, 7657 7694 lpcs->hInstance, NULL); 7658 7695 7659 7696 /* set header font */ 7660 SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont, 7697 SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont, 7661 7698 (LPARAM)TRUE); 7662 7699 7663 7700 if (uView == LVS_ICON) 7664 7701 { … … 7675 7712 { 7676 7713 /* set HDS_HIDDEN flag to hide the header bar */ 7677 SetWindowLongA(infoPtr->hwndHeader, GWL_STYLE, 7714 SetWindowLongA(infoPtr->hwndHeader, GWL_STYLE, 7678 7715 GetWindowLongA(infoPtr->hwndHeader, GWL_STYLE) | HDS_HIDDEN); 7679 7716 } 7680 7717 7681 7718 7682 7719 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); … … 7703 7740 7704 7741 /* initialize the hover time to -1(indicating the default system hover time) */ 7705 infoPtr->dwHoverTime = -1; 7742 infoPtr->dwHoverTime = -1; 7706 7743 7707 7744 #ifdef __WIN32OS2__ … … 7719 7756 * DESCRIPTION: 7720 7757 * Erases the background of the listview control. 7721 * 7758 * 7722 7759 * PARAMETER(S): 7723 7760 * [I] HWND : window handle 7724 7761 * [I] WPARAM : device context handle 7725 7762 * [I] LPARAM : not used 7726 * 7763 * 7727 7764 * RETURN: 7728 7765 * SUCCESS : TRUE 7729 7766 * FAILURE : FALSE 7730 7767 */ 7731 static LRESULT LISTVIEW_EraseBackground(HWND hwnd, WPARAM wParam, 7768 static LRESULT LISTVIEW_EraseBackground(HWND hwnd, WPARAM wParam, 7732 7769 LPARAM lParam) 7733 7770 { … … 7735 7772 BOOL bResult; 7736 7773 7737 if (infoPtr->clrBk == CLR_NONE) 7774 if (infoPtr->clrBk == CLR_NONE) 7738 7775 { 7739 7776 bResult = SendMessageA(GetParent(hwnd), WM_ERASEBKGND, wParam, lParam); 7740 7777 } 7741 else 7778 else 7742 7779 { 7743 7780 RECT rc; … … 7757 7794 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 7758 7795 7759 if (infoPtr->clrBk != CLR_NONE) 7796 if (infoPtr->clrBk != CLR_NONE) 7760 7797 { 7761 7798 HBRUSH hBrush = CreateSolidBrush(infoPtr->clrBk); … … 7768 7805 * DESCRIPTION: 7769 7806 * Retrieves the listview control font. 7770 * 7807 * 7771 7808 * PARAMETER(S): 7772 7809 * [I] HWND : window handle … … 7785 7822 * DESCRIPTION: 7786 7823 * Performs vertical scrolling. 7787 * 7824 * 7788 7825 * PARAMETER(S): 7789 7826 * [I] HWND : window handle 7790 7827 * [I] INT : scroll code 7791 * [I] SHORT : current scroll position if scroll code is SB_THUMBPOSITION 7828 * [I] SHORT : current scroll position if scroll code is SB_THUMBPOSITION 7792 7829 * or SB_THUMBTRACK. 7793 7830 * [I] HWND : scrollbar control window handle … … 7819 7856 } 7820 7857 break; 7821 7858 7822 7859 case SB_LINEDOWN: 7823 7860 if (scrollInfo.nPos < scrollInfo.nMax) … … 7826 7863 } 7827 7864 break; 7828 7865 7829 7866 case SB_PAGEUP: 7830 7867 if (scrollInfo.nPos > scrollInfo.nMin) … … 7840 7877 } 7841 7878 break; 7842 7879 7843 7880 case SB_PAGEDOWN: 7844 7881 if (scrollInfo.nPos < scrollInfo.nMax) … … 7874 7911 } 7875 7912 } 7876 7913 7877 7914 return 0; 7878 7915 } … … 7881 7918 * DESCRIPTION: 7882 7919 * Performs horizontal scrolling. 7883 * 7920 * 7884 7921 * PARAMETER(S): 7885 7922 * [I] HWND : window handle 7886 7923 * [I] INT : scroll code 7887 * [I] SHORT : current scroll position if scroll code is SB_THUMBPOSITION 7924 * [I] SHORT : current scroll position if scroll code is SB_THUMBPOSITION 7888 7925 * or SB_THUMBTRACK. 7889 7926 * [I] HWND : scrollbar control window handle … … 7904 7941 scrollInfo.cbSize = sizeof(SCROLLINFO); 7905 7942 scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; 7906 7943 7907 7944 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 7908 7945 { … … 7917 7954 } 7918 7955 break; 7919 7956 7920 7957 case SB_LINERIGHT: 7921 7958 if (scrollInfo.nPos < scrollInfo.nMax) … … 7924 7961 } 7925 7962 break; 7926 7963 7927 7964 case SB_PAGELEFT: 7928 7965 if (scrollInfo.nPos > scrollInfo.nMin) … … 7938 7975 } 7939 7976 break; 7940 7977 7941 7978 case SB_PAGERIGHT: 7942 7979 if (scrollInfo.nPos < scrollInfo.nMax) … … 7979 8016 } 7980 8017 } 7981 8018 7982 8019 return 0; 7983 8020 } … … 8031 8068 /*** 8032 8069 * DESCRIPTION: 8033 * ??? 8034 * 8035 * PARAMETER(S): 8036 * [I] HWND : window handle 8037 * [I] INT : virtual key 8070 * ??? 8071 * 8072 * PARAMETER(S): 8073 * [I] HWND : window handle 8074 * [I] INT : virtual key 8038 8075 * [I] LONG : key data 8039 8076 * … … 8046 8083 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 8047 8084 HWND hwndParent = GetParent(hwnd); 8048 NMLVKEYDOWN nmKeyDown; 8085 NMLVKEYDOWN nmKeyDown; 8049 8086 NMHDR nmh; 8050 8087 INT nItem = -1; … … 8055 8092 /* send LVN_KEYDOWN notification */ 8056 8093 ZeroMemory(&nmKeyDown, sizeof(NMLVKEYDOWN)); 8057 nmKeyDown.hdr.hwndFrom = hwnd; 8058 nmKeyDown.hdr.idFrom = nCtrlId; 8059 nmKeyDown.hdr.code = LVN_KEYDOWN; 8060 nmKeyDown.wVKey = nVirtualKey; 8061 nmKeyDown.flags = 0; 8062 SendMessageA(hwndParent, WM_NOTIFY, (WPARAM)nCtrlId, (LPARAM)&nmKeyDown); 8063 8094 nmKeyDown.hdr.hwndFrom = hwnd; 8095 nmKeyDown.hdr.idFrom = nCtrlId; 8096 nmKeyDown.hdr.code = LVN_KEYDOWN; 8097 nmKeyDown.wVKey = nVirtualKey; 8098 nmKeyDown.flags = 0; 8099 SendMessageA(hwndParent, WM_NOTIFY, (WPARAM)nCtrlId, (LPARAM)&nmKeyDown); 8100 8064 8101 /* initialize */ 8065 8102 nmh.hwndFrom = hwnd; … … 8074 8111 nmh.code = NM_RETURN; 8075 8112 ListView_Notify(hwndParent, nCtrlId, &nmh); 8076 8113 8077 8114 /* send LVN_ITEMACTIVATE notification */ 8078 8115 nmh.code = LVN_ITEMACTIVATE; … … 8102 8139 nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_ABOVE); 8103 8140 break; 8104 8141 8105 8142 case VK_RIGHT: 8106 8143 nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TORIGHT); … … 8118 8155 else 8119 8156 { 8120 nItem = infoPtr->nFocusedItem - LISTVIEW_GetCountPerColumn(hwnd) 8157 nItem = infoPtr->nFocusedItem - LISTVIEW_GetCountPerColumn(hwnd) 8121 8158 * LISTVIEW_GetCountPerRow(hwnd); 8122 8159 } … … 8154 8191 * DESCRIPTION: 8155 8192 * Kills the focus. 8156 * 8193 * 8157 8194 * PARAMETER(S): 8158 8195 * [I] HWND : window handle … … 8170 8207 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 8171 8208 UINT uView = lStyle & LVS_TYPEMASK; 8172 8209 8173 8210 TRACE("(hwnd=%x)\n", hwnd); 8174 8211 … … 8184 8221 /* NEED drawing optimization ; redraw the selected items */ 8185 8222 if (uView & LVS_REPORT) 8186 { 8223 { 8187 8224 nTop = LISTVIEW_GetTopIndex(hwnd); 8188 nBottom = nTop + 8225 nBottom = nTop + 8189 8226 LISTVIEW_GetCountPerColumn(hwnd) + 1; 8190 8227 } … … 8210 8247 * DESCRIPTION: 8211 8248 * Processes double click messages (left mouse button). 8212 * 8249 * 8213 8250 * PARAMETER(S): 8214 8251 * [I] HWND : window handle … … 8220 8257 * Zero 8221 8258 */ 8222 static LRESULT LISTVIEW_LButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 8259 static LRESULT LISTVIEW_LButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 8223 8260 WORD wPosY) 8224 8261 { … … 8249 8286 nmlv.iItem = -1; 8250 8287 nmlv.iSubItem = 0; 8251 } 8288 } 8252 8289 nmlv.ptAction.x = wPosX; 8253 8290 nmlv.ptAction.y = wPosY; … … 8271 8308 * DESCRIPTION: 8272 8309 * Processes mouse down messages (left mouse button). 8273 * 8310 * 8274 8311 * PARAMETER(S): 8275 8312 * [I] HWND : window handle … … 8281 8318 * Zero 8282 8319 */ 8283 static LRESULT LISTVIEW_LButtonDown(HWND hwnd, WORD wKey, WORD wPosX, 8320 static LRESULT LISTVIEW_LButtonDown(HWND hwnd, WORD wKey, WORD wPosX, 8284 8321 WORD wPosY) 8285 8322 { … … 8292 8329 INT nItem; 8293 8330 8294 TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX, 8331 TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX, 8295 8332 wPosY); 8296 8333 8297 /* send NM_RELEASEDCAPTURE notification */ 8334 /* send NM_RELEASEDCAPTURE notification */ 8298 8335 nmh.hwndFrom = hwnd; 8299 8336 nmh.idFrom = nCtrlId; 8300 8337 nmh.code = NM_RELEASEDCAPTURE; 8301 8338 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 8302 8339 8303 8340 if (infoPtr->bFocus == FALSE) 8304 8341 { … … 8308 8345 /* set left button down flag */ 8309 8346 infoPtr->bLButtonDown = TRUE; 8310 8347 8311 8348 ptPosition.x = wPosX; 8312 8349 ptPosition.y = wPosY; … … 8317 8354 { 8318 8355 if ((ListView_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED) 8319 && infoPtr->nEditLabelItem == -1) 8356 && infoPtr->nEditLabelItem == -1) 8320 8357 { 8321 8358 infoPtr->nEditLabelItem = nItem; … … 8349 8386 else 8350 8387 { 8351 8352 8353 8354 8388 BOOL was_selected = 8389 (ListView_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED); 8390 8391 /* set selection (clears other pre-existing selections) */ 8355 8392 LISTVIEW_SetSelection(hwnd, nItem); 8356 8393 … … 8377 8414 * DESCRIPTION: 8378 8415 * Processes mouse up messages (left mouse button). 8379 * 8416 * 8380 8417 * PARAMETER(S): 8381 8418 * [I] HWND : window handle … … 8387 8424 * Zero 8388 8425 */ 8389 static LRESULT LISTVIEW_LButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 8426 static LRESULT LISTVIEW_LButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 8390 8427 WORD wPosY) 8391 8428 { … … 8394 8431 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 8395 8432 8396 if (infoPtr->bLButtonDown != FALSE) 8433 if (infoPtr->bLButtonDown != FALSE) 8397 8434 { 8398 8435 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); … … 8444 8481 * DESCRIPTION: 8445 8482 * Creates the listview control (called before WM_CREATE). 8446 * 8447 * PARAMETER(S): 8448 * [I] HWND : window handle 8449 * [I] WPARAM : unhandled 8483 * 8484 * PARAMETER(S): 8485 * [I] HWND : window handle 8486 * [I] WPARAM : unhandled 8450 8487 * [I] LPARAM : widow creation info 8451 * 8488 * 8452 8489 * RETURN: 8453 8490 * Zero … … 8466 8503 #endif 8467 8504 SetWindowLongA(hwnd, 0, (LONG)infoPtr); 8468 if (infoPtr == NULL) 8505 if (infoPtr == NULL) 8469 8506 { 8470 8507 ERR("could not allocate info memory!\n"); … … 8472 8509 } 8473 8510 8474 if ((LISTVIEW_INFO *)GetWindowLongA(hwnd, 0) != infoPtr) 8511 if ((LISTVIEW_INFO *)GetWindowLongA(hwnd, 0) != infoPtr) 8475 8512 { 8476 8513 ERR("pointer assignment error!\n"); … … 8484 8521 * DESCRIPTION: 8485 8522 * Destroys the listview control (called after WM_DESTROY). 8486 * 8487 * PARAMETER(S): 8488 * [I] HWND : window handle 8489 * 8523 * 8524 * PARAMETER(S): 8525 * [I] HWND : window handle 8526 * 8490 8527 * RETURN: 8491 8528 * Zero … … 8526 8563 * DESCRIPTION: 8527 8564 * Handles notifications from children. 8528 * 8565 * 8529 8566 * PARAMETER(S): 8530 8567 * [I] HWND : window handle 8531 8568 * [I] INT : control identifier 8532 8569 * [I] LPNMHDR : notification information 8533 * 8570 * 8534 8571 * RETURN: 8535 8572 * Zero … … 8538 8575 { 8539 8576 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8540 8541 if (lpnmh->hwndFrom == infoPtr->hwndHeader) 8577 8578 if (lpnmh->hwndFrom == infoPtr->hwndHeader) 8542 8579 { 8543 8580 /* handle notification from header control */ … … 8560 8597 nmlv.iItem = -1; 8561 8598 nmlv.iSubItem = pnmHeader->iItem; 8562 8599 8563 8600 ListView_LVNotify(GetParent(hwnd),lCtrlId, &nmlv); 8564 8601 … … 8585 8622 * DESCRIPTION: 8586 8623 * Determines the type of structure to use. 8587 * 8624 * 8588 8625 * PARAMETER(S): 8589 8626 * [I] HWND : window handle of the sender 8590 * [I] HWND : listview window handle 8627 * [I] HWND : listview window handle 8591 8628 * [I] INT : command specifying the nature of the WM_NOTIFYFORMAT 8592 8629 * … … 8601 8638 { 8602 8639 /* determine the type of structure to use */ 8603 infoPtr->notifyFormat = SendMessageA(hwndFrom, WM_NOTIFYFORMAT, 8640 infoPtr->notifyFormat = SendMessageA(hwndFrom, WM_NOTIFYFORMAT, 8604 8641 (WPARAM)hwnd, (LPARAM)NF_QUERY); 8605 8642 if (infoPtr->notifyFormat == NFR_UNICODE) … … 8615 8652 * DESCRIPTION: 8616 8653 * Paints/Repaints the listview control. 8617 * 8654 * 8618 8655 * PARAMETER(S): 8619 8656 * [I] HWND : window handle … … 8646 8683 * DESCRIPTION: 8647 8684 * Processes double click messages (right mouse button). 8648 * 8685 * 8649 8686 * PARAMETER(S): 8650 8687 * [I] HWND : window handle … … 8656 8693 * Zero 8657 8694 */ 8658 static LRESULT LISTVIEW_RButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 8695 static LRESULT LISTVIEW_RButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 8659 8696 WORD wPosY) 8660 8697 { 8661 8698 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 8662 8699 NMHDR nmh; 8663 8664 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);8665 8666 /* send NM_RELEASEDCAPTURE notification */8667 nmh.hwndFrom = hwnd;8668 nmh.idFrom = nCtrlId;8669 nmh.code = NM_RELEASEDCAPTURE;8670 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);8671 8672 /* send NM_RDBLCLK notification */8673 nmh.code = NM_RDBLCLK;8674 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);8675 8676 return 0;8677 }8678 8679 /***8680 * DESCRIPTION:8681 * Processes mouse down messages (right mouse button).8682 *8683 * PARAMETER(S):8684 * [I] HWND : window handle8685 * [I] WORD : key flag8686 * [I] WORD : x coordinate8687 * [I] WORD : y coordinate8688 *8689 * RETURN:8690 * Zero8691 */8692 static LRESULT LISTVIEW_RButtonDown(HWND hwnd, WORD wKey, WORD wPosX,8693 WORD wPosY)8694 {8695 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);8696 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);8697 POINT ptPosition;8698 NMHDR nmh;8699 INT nItem;8700 8700 8701 8701 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); … … 8706 8706 nmh.code = NM_RELEASEDCAPTURE; 8707 8707 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 8708 8708 8709 /* send NM_RDBLCLK notification */ 8710 nmh.code = NM_RDBLCLK; 8711 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 8712 8713 return 0; 8714 } 8715 8716 /*** 8717 * DESCRIPTION: 8718 * Processes mouse down messages (right mouse button). 8719 * 8720 * PARAMETER(S): 8721 * [I] HWND : window handle 8722 * [I] WORD : key flag 8723 * [I] WORD : x coordinate 8724 * [I] WORD : y coordinate 8725 * 8726 * RETURN: 8727 * Zero 8728 */ 8729 static LRESULT LISTVIEW_RButtonDown(HWND hwnd, WORD wKey, WORD wPosX, 8730 WORD wPosY) 8731 { 8732 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8733 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 8734 POINT ptPosition; 8735 NMHDR nmh; 8736 INT nItem; 8737 8738 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 8739 8740 /* send NM_RELEASEDCAPTURE notification */ 8741 nmh.hwndFrom = hwnd; 8742 nmh.idFrom = nCtrlId; 8743 nmh.code = NM_RELEASEDCAPTURE; 8744 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 8745 8709 8746 /* make sure the listview control window has the focus */ 8710 8747 if (infoPtr->bFocus == FALSE) … … 8733 8770 LISTVIEW_RemoveAllSelections(hwnd); 8734 8771 } 8735 8772 8736 8773 return 0; 8737 8774 } … … 8740 8777 * DESCRIPTION: 8741 8778 * Processes mouse up messages (right mouse button). 8742 * 8779 * 8743 8780 * PARAMETER(S): 8744 8781 * [I] HWND : window handle … … 8750 8787 * Zero 8751 8788 */ 8752 static LRESULT LISTVIEW_RButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 8789 static LRESULT LISTVIEW_RButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 8753 8790 WORD wPosY) 8754 8791 { … … 8758 8795 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 8759 8796 8760 if (infoPtr->bRButtonDown != FALSE) 8797 if (infoPtr->bRButtonDown != FALSE) 8761 8798 { 8762 8799 NMLISTVIEW nmlv; … … 8793 8830 /* set button flag */ 8794 8831 infoPtr->bRButtonDown = FALSE; 8795 8832 8796 8833 /* Change to screen coordinate for WM_CONTEXTMENU */ 8797 8834 ClientToScreen(hwnd, &pt); 8798 8835 8799 8836 /* Send a WM_CONTEXTMENU message in response to the RBUTTONUP */ 8800 8837 SendMessageA( hwnd, WM_CONTEXTMENU, (WPARAM) hwnd, MAKELPARAM(pt.x, pt.y)); 8801 8838 } 8802 8839 8803 8840 return 0; 8804 8841 } … … 8806 8843 /*** 8807 8844 * DESCRIPTION: 8808 * Sets the focus. 8809 * 8845 * Sets the focus. 8846 * 8810 8847 * PARAMETER(S): 8811 8848 * [I] HWND : window handle … … 8839 8876 /*** 8840 8877 * DESCRIPTION: 8841 * Sets the font. 8842 * 8878 * Sets the font. 8879 * 8843 8880 * PARAMETER(S): 8844 8881 * [I] HWND : window handle … … 8868 8905 { 8869 8906 /* set header font */ 8870 SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)hFont, 8907 SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)hFont, 8871 8908 MAKELPARAM(fRedraw, 0)); 8872 8909 } … … 8879 8916 /* invalidate listview control client area */ 8880 8917 InvalidateRect(hwnd, NULL, TRUE); 8881 8918 8882 8919 if (fRedraw != FALSE) 8883 8920 { … … 8890 8927 /*** 8891 8928 * DESCRIPTION: 8892 * Message handling for WM_SETREDRAW. 8929 * Message handling for WM_SETREDRAW. 8893 8930 * For the Listview, it invalidates the entire window (the doc specifies otherwise) 8894 * 8931 * 8895 8932 * PARAMETER(S): 8896 8933 * [I] HWND : window handle … … 8923 8960 if(bRedraw) 8924 8961 { 8925 RedrawWindow(hwnd, NULL, 0, 8962 RedrawWindow(hwnd, NULL, 0, 8926 8963 RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN | RDW_ERASENOW); 8927 8964 } … … 8934 8971 * Resizes the listview control. This function processes WM_SIZE 8935 8972 * messages. At this time, the width and height are not used. 8936 * 8973 * 8937 8974 * PARAMETER(S): 8938 8975 * [I] HWND : window handle … … 8945 8982 static LRESULT LISTVIEW_Size(HWND hwnd, int Width, int Height) 8946 8983 { 8947 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 8984 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 8948 8985 UINT uView = lStyle & LVS_TYPEMASK; 8949 8986 … … 8965 9002 8966 9003 LISTVIEW_UpdateScroll(hwnd); 8967 9004 8968 9005 /* invalidate client area + erase background */ 8969 9006 InvalidateRect(hwnd, NULL, TRUE); … … 8975 9012 * DESCRIPTION: 8976 9013 * Sets the size information. 8977 * 9014 * 8978 9015 * PARAMETER(S): 8979 9016 * [I] HWND : window handle … … 8988 9025 UINT uView = lStyle & LVS_TYPEMASK; 8989 9026 RECT rcList; 8990 9027 8991 9028 GetClientRect(hwnd, &rcList); 8992 9029 infoPtr->rcList.left = 0; … … 8994 9031 infoPtr->rcList.top = 0; 8995 9032 infoPtr->rcList.bottom = max(rcList.bottom - rcList.top, 1); 8996 9033 8997 9034 if (uView == LVS_LIST) 8998 9035 { … … 9001 9038 INT nHScrollHeight = GetSystemMetrics(SM_CYHSCROLL); 9002 9039 if (infoPtr->rcList.bottom > nHScrollHeight) 9003 { 9040 { 9004 9041 infoPtr->rcList.bottom -= nHScrollHeight; 9005 9042 } … … 9026 9063 /*** 9027 9064 * DESCRIPTION: 9028 * Processes WM_STYLECHANGED messages. 9029 * 9065 * Processes WM_STYLECHANGED messages. 9066 * 9030 9067 * PARAMETER(S): 9031 9068 * [I] HWND : window handle … … 9036 9073 * Zero 9037 9074 */ 9038 static INT LISTVIEW_StyleChanged(HWND hwnd, WPARAM wStyleType, 9075 static INT LISTVIEW_StyleChanged(HWND hwnd, WPARAM wStyleType, 9039 9076 LPSTYLESTRUCT lpss) 9040 9077 { … … 9044 9081 RECT rcList = infoPtr->rcList; 9045 9082 9046 TRACE("(hwnd=%x, styletype=%x, stylestruct=%p)\n", 9083 TRACE("(hwnd=%x, styletype=%x, stylestruct=%p)\n", 9047 9084 hwnd, wStyleType, lpss); 9048 9085 … … 9053 9090 ShowWindow(infoPtr->hwndHeader, SW_HIDE); 9054 9091 } 9055 9092 9056 9093 if ((lpss->styleOld & WS_HSCROLL) != 0) 9057 9094 { 9058 9095 ShowScrollBar(hwnd, SB_HORZ, FALSE); 9059 9096 } 9060 9097 9061 9098 if ((lpss->styleOld & WS_VSCROLL) != 0) 9062 9099 { 9063 9100 ShowScrollBar(hwnd, SB_VERT, FALSE); 9064 9101 } 9065 9102 9066 9103 if (uNewView == LVS_ICON) 9067 9104 { … … 9087 9124 hl.pwpos = ℘ 9088 9125 Header_Layout(infoPtr->hwndHeader, &hl); 9089 SetWindowPos(infoPtr->hwndHeader, hwnd, wp.x, wp.y, wp.cx, wp.cy, 9126 SetWindowPos(infoPtr->hwndHeader, hwnd, wp.x, wp.y, wp.cx, wp.cy, 9090 9127 wp.flags); 9091 9128 if (!(LVS_NOCOLUMNHEADER & lpss->styleNew)) 9092 9129 ShowWindow(infoPtr->hwndHeader, SW_SHOWNORMAL); 9093 9130 9094 9131 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); 9095 9132 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); … … 9125 9162 /* add scrollbars if needed */ 9126 9163 LISTVIEW_UpdateScroll(hwnd); 9127 9164 9128 9165 /* invalidate client area + erase background */ 9129 9166 InvalidateRect(hwnd, NULL, TRUE); … … 9133 9170 } 9134 9171 9135 /* If they change the view and we have an active edit control 9172 /* If they change the view and we have an active edit control 9136 9173 we will need to kill the control since the redraw will 9137 9174 misplace the edit control. … … 9699 9736 } 9700 9737 9738 #ifdef DEBUG 9739 void dprintfMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 9740 { 9741 char *msg = NULL; 9742 9743 switch (uMsg) 9744 { 9745 case LVM_APPROXIMATEVIEWRECT: 9746 msg = "LVM_APPROXIMATEVIEWRECT"; 9747 break; 9748 case LVM_ARRANGE: 9749 msg = "LVM_ARRANGE"; 9750 break; 9751 case LVM_CREATEDRAGIMAGE: 9752 msg = "LVM_CREATEDRAGIMAGE"; 9753 break; 9754 case LVM_DELETEALLITEMS: 9755 msg = "LVM_DELETEALLITEMS"; 9756 break; 9757 case LVM_DELETECOLUMN: 9758 msg = "LVM_DELETECOLUMN"; 9759 break; 9760 case LVM_DELETEITEM: 9761 msg = "LVM_DELETEITEM"; 9762 break; 9763 case LVM_EDITLABELW: 9764 msg = "LVM_EDITLABELW"; 9765 break; 9766 case LVM_EDITLABELA: 9767 msg = "LVM_EDITLABELA"; 9768 break; 9769 case LVM_ENSUREVISIBLE: 9770 msg = "LVM_ENSUREVISIBLE"; 9771 break; 9772 case LVM_FINDITEMA: 9773 msg = "LVM_FINDITEMA"; 9774 break; 9775 case LVM_GETBKCOLOR: 9776 msg = "LVM_GETBKCOLOR"; 9777 break; 9778 case LVM_GETBKIMAGEA: 9779 msg = "LVM_GETBKIMAGEA"; 9780 break; 9781 case LVM_GETBKIMAGEW: 9782 msg = "LVM_GETBKIMAGEW"; 9783 break; 9784 case LVM_GETCALLBACKMASK: 9785 msg = "LVM_GETCALLBACKMASK"; 9786 break; 9787 case LVM_GETCOLUMNA: 9788 msg = "LVM_GETCOLUMNA"; 9789 break; 9790 case LVM_GETCOLUMNW: 9791 msg = "LVM_GETCOLUMNW"; 9792 break; 9793 case LVM_GETCOLUMNORDERARRAY: 9794 msg = "LVM_GETCOLUMNORDERARRAY"; 9795 break; 9796 case LVM_GETCOLUMNWIDTH: 9797 msg = "LVM_GETCOLUMNWIDTH"; 9798 break; 9799 case LVM_GETCOUNTPERPAGE: 9800 msg = "LVM_GETCOUNTPERPAGE"; 9801 break; 9802 case LVM_GETEDITCONTROL: 9803 msg = "LVM_GETEDITCONTROL"; 9804 break; 9805 case LVM_GETEXTENDEDLISTVIEWSTYLE: 9806 msg = "LVM_GETEXTENDEDLISTVIEWSTYLE"; 9807 break; 9808 case LVM_GETHEADER: 9809 msg = "LVM_GETHEADER"; 9810 break; 9811 case LVM_GETHOTCURSOR: 9812 msg = "LVM_GETHOTCURSOR"; 9813 break; 9814 case LVM_GETHOTITEM: 9815 msg = "LVM_GETHOTITEM"; 9816 break; 9817 case LVM_GETHOVERTIME: 9818 msg = "LVM_GETHOVERTIME"; 9819 break; 9820 case LVM_GETIMAGELIST: 9821 msg = "LVM_GETIMAGELIST"; 9822 break; 9823 case LVM_GETISEARCHSTRINGA: 9824 msg = "LVM_GETISEARCHSTRINGA"; 9825 break; 9826 case LVM_GETISEARCHSTRINGW: 9827 msg = "LVM_GETISEARCHSTRINGW"; 9828 break; 9829 case LVM_GETITEMA: 9830 msg = "LVM_GETITEMA"; 9831 break; 9832 case LVM_GETITEMW: 9833 msg = "LVM_GETITEMW"; 9834 break; 9835 case LVM_GETITEMCOUNT: 9836 msg = "LVM_GETITEMCOUNT"; 9837 break; 9838 case LVM_GETITEMPOSITION: 9839 msg = "LVM_GETITEMPOSITION"; 9840 break; 9841 case LVM_GETITEMRECT: 9842 msg = "LVM_GETITEMRECT"; 9843 break; 9844 case LVM_GETITEMSPACING: 9845 msg = "LVM_GETITEMSPACING"; 9846 break; 9847 case LVM_GETITEMSTATE: 9848 msg = "LVM_GETITEMSTATE"; 9849 break; 9850 case LVM_GETITEMTEXTA: 9851 msg = "LVM_GETITEMTEXTA"; 9852 break; 9853 case LVM_GETITEMTEXTW: 9854 msg = "LVM_GETITEMTEXTW"; 9855 break; 9856 case LVM_GETNEXTITEM: 9857 msg = "LVM_GETNEXTITEM"; 9858 break; 9859 case LVM_GETNUMBEROFWORKAREAS: 9860 msg = "LVM_GETNUMBEROFWORKAREAS"; 9861 break; 9862 case LVM_GETORIGIN: 9863 msg = "LVM_GETORIGIN"; 9864 break; 9865 case LVM_GETSELECTEDCOUNT: 9866 msg = "LVM_GETSELECTEDCOUNT"; 9867 break; 9868 case LVM_GETSELECTIONMARK: 9869 msg = "LVM_GETSELECTIONMARK"; 9870 break; 9871 case LVM_GETSTRINGWIDTHA: 9872 msg = "LVM_GETSTRINGWIDTHA"; 9873 break; 9874 case LVM_GETSTRINGWIDTHW: 9875 msg = "LVM_GETSTRINGWIDTHW"; 9876 break; 9877 case LVM_GETSUBITEMRECT: 9878 msg = "LVM_GETSUBITEMRECT"; 9879 break; 9880 case LVM_GETTEXTBKCOLOR: 9881 msg = "LVM_GETTEXTBKCOLOR"; 9882 break; 9883 case LVM_GETTEXTCOLOR: 9884 msg = "LVM_GETTEXTCOLOR"; 9885 break; 9886 case LVM_GETTOOLTIPS: 9887 msg = "LVM_GETTOOLTIPS"; 9888 break; 9889 case LVM_GETTOPINDEX: 9890 msg = "LVM_GETTOPINDEX"; 9891 break; 9892 case LVM_GETVIEWRECT: 9893 msg = "LVM_GETVIEWRECT"; 9894 break; 9895 case LVM_GETWORKAREAS: 9896 msg = "LVM_GETWORKAREAS"; 9897 break; 9898 case LVM_HITTEST: 9899 msg = "LVM_HITTEST"; 9900 break; 9901 case LVM_INSERTCOLUMNA: 9902 msg = "LVM_INSERTCOLUMNA"; 9903 break; 9904 case LVM_INSERTCOLUMNW: 9905 msg = "LVM_INSERTCOLUMNW"; 9906 break; 9907 case LVM_INSERTITEMA: 9908 msg = "LVM_INSERTITEMA"; 9909 break; 9910 case LVM_INSERTITEMW: 9911 msg = "LVM_INSERTITEMW"; 9912 break; 9913 case LVM_REDRAWITEMS: 9914 msg = "LVM_REDRAWITEMS"; 9915 break; 9916 case LVM_SCROLL: 9917 msg = "LVM_SCROLL"; 9918 break; 9919 case LVM_SETBKCOLOR: 9920 msg = "LVM_SETBKCOLOR"; 9921 break; 9922 case LVM_SETBKIMAGEA: 9923 msg = "LVM_SETBKIMAGEA"; 9924 break; 9925 case LVM_SETBKIMAGEW: 9926 msg = "LVM_SETBKIMAGEW"; 9927 break; 9928 case LVM_SETCALLBACKMASK: 9929 msg = "LVM_SETCALLBACKMASK"; 9930 break; 9931 case LVM_SETCOLUMNA: 9932 msg = "LVM_SETCOLUMNA"; 9933 break; 9934 case LVM_SETCOLUMNW: 9935 msg = "LVM_SETCOLUMNW"; 9936 break; 9937 case LVM_SETCOLUMNORDERARRAY: 9938 msg = "LVM_SETCOLUMNORDERARRAY"; 9939 break; 9940 case LVM_SETCOLUMNWIDTH: 9941 msg = "LVM_SETCOLUMNWIDTH"; 9942 break; 9943 case LVM_SETEXTENDEDLISTVIEWSTYLE: 9944 msg = "LVM_SETEXTENDEDLISTVIEWSTYLE"; 9945 break; 9946 case LVM_SETHOTCURSOR: 9947 msg = "LVM_SETHOTCURSOR"; 9948 break; 9949 case LVM_SETHOTITEM: 9950 msg = "LVM_SETHOTITEM"; 9951 break; 9952 case LVM_SETHOVERTIME: 9953 msg = "LVM_SETHOVERTIME"; 9954 break; 9955 case LVM_SETICONSPACING: 9956 msg = "LVM_SETICONSPACING"; 9957 break; 9958 case LVM_SETIMAGELIST: 9959 msg = "LVM_SETIMAGELIST"; 9960 break; 9961 case LVM_SETITEMA: 9962 msg = "LVM_SETITEMA"; 9963 break; 9964 case LVM_SETITEMW: 9965 msg = "LVM_SETITEMW"; 9966 break; 9967 case LVM_SETITEMCOUNT: 9968 msg = "LVM_SETITEMCOUNT"; 9969 break; 9970 case LVM_SETITEMPOSITION: 9971 msg = "LVM_SETITEMPOSITION"; 9972 break; 9973 case LVM_SETITEMPOSITION32: 9974 msg = "LVM_SETITEMPOSITION32"; 9975 break; 9976 case LVM_SETITEMSTATE: 9977 msg = "LVM_SETITEMSTATE"; 9978 break; 9979 case LVM_SETITEMTEXTA: 9980 msg = "LVM_SETITEMTEXTA"; 9981 break; 9982 case LVM_SETITEMTEXTW: 9983 msg = "LVM_SETITEMTEXTW"; 9984 break; 9985 case LVM_SETSELECTIONMARK: 9986 msg = "LVM_SETSELECTIONMARK"; 9987 break; 9988 case LVM_SETTEXTBKCOLOR: 9989 msg = "LVM_SETTEXTBKCOLOR"; 9990 break; 9991 case LVM_SETTEXTCOLOR: 9992 msg = "LVM_SETTEXTCOLOR"; 9993 break; 9994 case LVM_SETTOOLTIPS: 9995 msg = "LVM_SETTOOLTIPS"; 9996 break; 9997 case LVM_SETWORKAREAS: 9998 msg = "LVM_SETWORKAREAS"; 9999 break; 10000 case LVM_SORTITEMS: 10001 msg = "LVM_SORTITEMS"; 10002 break; 10003 case LVM_SUBITEMHITTEST: 10004 msg = "LVM_SUBITEMHITTEST"; 10005 break; 10006 case LVM_UPDATE: 10007 msg = "LVM_UPDATE"; 10008 break; 10009 default: 10010 return; 10011 } 10012 dprintf(("SysListView %x %s %x %x", hwnd, msg, wParam, lParam)); 10013 } 10014 #endif 9701 10015 #endif //__WIN32OS2__ 9702 10016 … … 9709 10023 LPARAM lParam) 9710 10024 { 10025 #if defined(DEBUG) && defined(__WIN32OS2__) 10026 dprintfMsg(hwnd, uMsg, wParam, lParam); 10027 #else 9711 10028 TRACE("hwnd=%x uMsg=%x wParam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam); 10029 #endif 10030 9712 10031 if (!GetWindowLongA(hwnd, 0) && (uMsg != WM_NCCREATE)) 9713 10032 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 9714 10033 switch (uMsg) 9715 10034 { 9716 case LVM_APPROXIMATEVIEWRECT: 9717 return LISTVIEW_ApproximateViewRect(hwnd, (INT)wParam, 10035 case LVM_APPROXIMATEVIEWRECT: 10036 return LISTVIEW_ApproximateViewRect(hwnd, (INT)wParam, 9718 10037 LOWORD(lParam), HIWORD(lParam)); 9719 case LVM_ARRANGE: 10038 case LVM_ARRANGE: 9720 10039 return LISTVIEW_Arrange(hwnd, (INT)wParam); 9721 10040 … … 9756 10075 return LISTVIEW_GetBkImage(hwnd,wParam,lParam,TRUE); 9757 10076 #endif 9758 /* 10077 /* case LVM_GETBKIMAGE: */ 9759 10078 9760 10079 case LVM_GETCALLBACKMASK: … … 9764 10083 return LISTVIEW_GetColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam); 9765 10084 9766 /* 10085 /* case LVM_GETCOLUMNW: */ 9767 10086 9768 10087 case LVM_GETCOLUMNORDERARRAY: … … 9784 10103 return LISTVIEW_GetHeader(hwnd); 9785 10104 9786 /* 10105 /* case LVM_GETHOTCURSOR: */ 9787 10106 #ifdef __WIN32OS2__ 9788 10107 case LVM_GETHOTCURSOR: … … 9799 10118 return LISTVIEW_GetImageList(hwnd, (INT)wParam); 9800 10119 9801 /* 10120 /* case LVM_GETISEARCHSTRING: */ 9802 10121 9803 10122 #ifdef __WIN32OS2__ … … 9812 10131 return LISTVIEW_GetItemA(hwnd, (LPLVITEMA)lParam, FALSE); 9813 10132 9814 /* 10133 /* case LVM_GETITEMW: */ 9815 10134 9816 10135 case LVM_GETITEMCOUNT: … … 9820 10139 return LISTVIEW_GetItemPosition(hwnd, (INT)wParam, (LPPOINT)lParam); 9821 10140 9822 case LVM_GETITEMRECT: 10141 case LVM_GETITEMRECT: 9823 10142 return LISTVIEW_GetItemRect(hwnd, (INT)wParam, (LPRECT)lParam); 9824 10143 9825 case LVM_GETITEMSPACING: 10144 case LVM_GETITEMSPACING: 9826 10145 return LISTVIEW_GetItemSpacing(hwnd, (BOOL)wParam); 9827 10146 9828 case LVM_GETITEMSTATE: 10147 case LVM_GETITEMSTATE: 9829 10148 return LISTVIEW_GetItemState(hwnd, (INT)wParam, (UINT)lParam); 9830 10149 9831 10150 case LVM_GETITEMTEXTA: 9832 10151 LISTVIEW_GetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam); 9833 10152 break; 9834 10153 9835 /* 10154 /* case LVM_GETITEMTEXTW: */ 9836 10155 9837 10156 case LVM_GETNEXTITEM: 9838 10157 return LISTVIEW_GetNextItem(hwnd, (INT)wParam, LOWORD(lParam)); 9839 10158 9840 /* 10159 /* case LVM_GETNUMBEROFWORKAREAS: */ 9841 10160 9842 10161 #ifdef __WIN32OS2__ … … 9851 10170 return LISTVIEW_GetSelectedCount(hwnd); 9852 10171 9853 case LVM_GETSELECTIONMARK: 10172 case LVM_GETSELECTIONMARK: 9854 10173 return LISTVIEW_GetSelectionMark(hwnd); 9855 10174 … … 9857 10176 return LISTVIEW_GetStringWidthA (hwnd, (LPCSTR)lParam); 9858 10177 9859 /* 9860 /* 10178 /* case LVM_GETSTRINGWIDTHW: */ 10179 /* case LVM_GETSUBITEMRECT: */ 9861 10180 9862 10181 #ifdef __WIN32OS2__ … … 9871 10190 return LISTVIEW_GetTextColor(hwnd); 9872 10191 9873 /* 10192 /* case LVM_GETTOOLTIPS: */ 9874 10193 #ifdef __WIN32OS2__ 9875 10194 case LVM_GETTOOLTIPS: … … 9880 10199 return LISTVIEW_GetTopIndex(hwnd); 9881 10200 9882 /* 10201 /* case LVM_GETUNICODEFORMAT: */ 9883 10202 9884 10203 case LVM_GETVIEWRECT: 9885 10204 return LISTVIEW_GetViewRect(hwnd, (LPRECT)lParam); 9886 10205 9887 /* 10206 /* case LVM_GETWORKAREAS: */ 9888 10207 #ifdef __WIN32OS2__ 9889 10208 case LVM_GETWORKAREAS: … … 9910 10229 9911 10230 #ifdef __WIN32OS2__ 9912 case LVM_SCROLL: 10231 case LVM_SCROLL: 9913 10232 return LISTVIEW_Scroll(hwnd, (INT)wParam, (INT)lParam); 9914 10233 #endif … … 9919 10238 return LISTVIEW_SetBkColor(hwnd, (COLORREF)lParam); 9920 10239 9921 /* 10240 /* case LVM_SETBKIMAGE: */ 9922 10241 #ifdef __WIN32OS2__ 9923 10242 case LVM_SETBKIMAGEA: … … 9947 10266 return LISTVIEW_SetExtendedListViewStyle(hwnd, (DWORD)wParam, (DWORD)lParam); 9948 10267 9949 /* 10268 /* case LVM_SETHOTCURSOR: */ 9950 10269 #ifdef __WIN32OS2__ 9951 10270 case LVM_SETHOTCURSOR: … … 9959 10278 return LISTVIEW_SetHoverTime(hwnd, (DWORD)wParam); 9960 10279 9961 /* 10280 /* case LVM_SETICONSPACING: */ 9962 10281 #ifdef __WIN32OS2__ 9963 10282 case LVM_SETICONSPACING: 9964 10283 return LISTVIEW_SetIconSpacing(hwnd,wParam,lParam); 9965 10284 #endif 9966 10285 9967 10286 case LVM_SETIMAGELIST: 9968 10287 return LISTVIEW_SetImageList(hwnd, (INT)wParam, (HIMAGELIST)lParam); … … 9971 10290 return LISTVIEW_SetItemA(hwnd, (LPLVITEMA)lParam); 9972 10291 9973 /* 9974 9975 case LVM_SETITEMCOUNT: 10292 /* case LVM_SETITEMW: */ 10293 10294 case LVM_SETITEMCOUNT: 9976 10295 return LISTVIEW_SetItemCount(hwnd, (INT)wParam, (DWORD)lParam); 9977 10296 9978 10297 case LVM_SETITEMPOSITION: 9979 10298 return LISTVIEW_SetItemPosition(hwnd, (INT)wParam, (INT)LOWORD(lParam), … … 9982 10301 case LVM_SETITEMPOSITION32: 9983 10302 return LISTVIEW_SetItemPosition(hwnd, (INT)wParam, ((POINT*)lParam)->x, 9984 10303 ((POINT*)lParam)->y); 9985 10304 9986 10305 case LVM_SETITEMSTATE: … … 9990 10309 return LISTVIEW_SetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam); 9991 10310 9992 /* 10311 /* case LVM_SETITEMTEXTW: */ 9993 10312 9994 10313 case LVM_SETSELECTIONMARK: … … 10008 10327 return LISTVIEW_SetWorkAreas(hwnd,wParam,lParam); 10009 10328 #endif 10010 /* 10011 /* 10012 /* 10329 /* case LVM_SETTOOLTIPS: */ 10330 /* case LVM_SETUNICODEFORMAT: */ 10331 /* case LVM_SETWORKAREAS: */ 10013 10332 10014 10333 case LVM_SORTITEMS: 10015 10334 return LISTVIEW_SortItems(hwnd, wParam, lParam); 10016 10335 10017 /* 10336 /* case LVM_SUBITEMHITTEST: */ 10018 10337 #ifdef __WIN32OS2__ 10019 10338 case LVM_SUBITEMHITTEST: … … 10021 10340 #endif 10022 10341 10023 case LVM_UPDATE: 10342 case LVM_UPDATE: 10024 10343 return LISTVIEW_Update(hwnd, (INT)wParam); 10025 10344 … … 10032 10351 case WM_CREATE: 10033 10352 return LISTVIEW_Create(hwnd, wParam, lParam); 10034 10353 10035 10354 case WM_ERASEBKGND: 10036 10355 return LISTVIEW_EraseBackground(hwnd, wParam, lParam); … … 10043 10362 10044 10363 case WM_HSCROLL: 10045 return LISTVIEW_HScroll(hwnd, (INT)LOWORD(wParam), 10364 return LISTVIEW_HScroll(hwnd, (INT)LOWORD(wParam), 10046 10365 (INT)HIWORD(wParam), (HWND)lParam); 10047 10366 … … 10053 10372 10054 10373 case WM_LBUTTONDBLCLK: 10055 return LISTVIEW_LButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 10374 return LISTVIEW_LButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 10056 10375 HIWORD(lParam)); 10057 10376 10058 10377 case WM_LBUTTONDOWN: 10059 return LISTVIEW_LButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 10378 return LISTVIEW_LButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 10060 10379 HIWORD(lParam)); 10061 10380 case WM_LBUTTONUP: 10062 return LISTVIEW_LButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 10381 return LISTVIEW_LButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 10063 10382 HIWORD(lParam)); 10064 10383 case WM_MOUSEMOVE: … … 10080 10399 return LISTVIEW_NotifyFormat(hwnd, (HWND)wParam, (INT)lParam); 10081 10400 10082 case WM_PAINT: 10083 return LISTVIEW_Paint(hwnd, (HDC)wParam); 10401 case WM_PAINT: 10402 return LISTVIEW_Paint(hwnd, (HDC)wParam); 10084 10403 10085 10404 case WM_RBUTTONDBLCLK: 10086 return LISTVIEW_RButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 10405 return LISTVIEW_RButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 10087 10406 HIWORD(lParam)); 10088 10407 10089 10408 case WM_RBUTTONDOWN: 10090 return LISTVIEW_RButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 10409 return LISTVIEW_RButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 10091 10410 HIWORD(lParam)); 10092 10411 10093 10412 case WM_RBUTTONUP: 10094 return LISTVIEW_RButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 10413 return LISTVIEW_RButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 10095 10414 HIWORD(lParam)); 10096 10415 … … 10101 10420 return LISTVIEW_SetFont(hwnd, (HFONT)wParam, (WORD)lParam); 10102 10421 10103 case WM_SETREDRAW: 10422 case WM_SETREDRAW: 10104 10423 return LISTVIEW_SetRedraw(hwnd, (BOOL)wParam); 10105 10424 … … 10110 10429 return LISTVIEW_StyleChanged(hwnd, wParam, (LPSTYLESTRUCT)lParam); 10111 10430 10112 /* 10431 /* case WM_TIMER: */ 10113 10432 #ifdef __WIN32OS2__ 10114 10433 case WM_TIMER: … … 10117 10436 10118 10437 case WM_VSCROLL: 10119 return LISTVIEW_VScroll(hwnd, (INT)LOWORD(wParam), 10438 return LISTVIEW_VScroll(hwnd, (INT)LOWORD(wParam), 10120 10439 (INT)HIWORD(wParam), (HWND)lParam); 10121 10440 … … 10123 10442 if (wParam & (MK_SHIFT | MK_CONTROL)) 10124 10443 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 10125 return LISTVIEW_MouseWheel(hwnd, (short int)HIWORD(wParam));/* 10126 10127 /* 10444 return LISTVIEW_MouseWheel(hwnd, (short int)HIWORD(wParam));/* case WM_WINDOWPOSCHANGED: */ 10445 10446 /* case WM_WININICHANGE: */ 10128 10447 10129 10448 default: 10130 10449 if (uMsg >= WM_USER) 10131 10450 { 10132 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, 10451 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, 10133 10452 lParam); 10134 10453 } … … 10148 10467 * DESCRIPTION: 10149 10468 * Registers the window class. 10150 * 10469 * 10151 10470 * PARAMETER(S): 10152 10471 * None … … 10173 10492 * DESCRIPTION: 10174 10493 * Unregisters the window class. 10175 * 10494 * 10176 10495 * PARAMETER(S): 10177 10496 * None … … 10188 10507 * DESCRIPTION: 10189 10508 * Handle any WM_COMMAND messages 10190 * 10509 * 10191 10510 * PARAMETER(S): 10192 10511 * … … 10197 10516 switch (HIWORD(wParam)) 10198 10517 { 10199 10200 10201 /* 10202 * Adjust the edit window size 10203 10204 10205 10206 10518 case EN_UPDATE: 10519 { 10520 /* 10521 * Adjust the edit window size 10522 */ 10523 char buffer[1024]; 10524 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 10525 HDC hdc = GetDC(infoPtr->hwndEdit); 10207 10526 HFONT hFont, hOldFont = 0; 10208 RECTrect;10209 SIZEsz;10210 intlen;10211 10212 10213 10527 RECT rect; 10528 SIZE sz; 10529 int len; 10530 10531 len = GetWindowTextA(infoPtr->hwndEdit, buffer, 1023); 10532 GetWindowRect(infoPtr->hwndEdit, &rect); 10214 10533 10215 10534 /* Select font to get the right dimension of the string */ … … 10220 10539 } 10221 10540 10222 10223 10541 if (GetTextExtentPoint32A(hdc, buffer, strlen(buffer), &sz)) 10542 { 10224 10543 TEXTMETRICA textMetric; 10225 10544 … … 10228 10547 sz.cx += (textMetric.tmMaxCharWidth * 2); 10229 10548 10230 SetWindowPos ( 10231 10232 HWND_TOP, 10233 0, 10234 10235 10236 10237 10238 10549 SetWindowPos ( 10550 infoPtr->hwndEdit, 10551 HWND_TOP, 10552 0, 10553 0, 10554 sz.cx, 10555 rect.bottom - rect.top, 10556 SWP_DRAWFRAME|SWP_NOMOVE); 10557 } 10239 10558 if(hFont != 0) 10240 10559 { … … 10242 10561 } 10243 10562 10244 10245 10246 10247 10248 10249 10250 10563 ReleaseDC(hwnd, hdc); 10564 10565 break; 10566 } 10567 10568 default: 10569 return SendMessageA (GetParent (hwnd), WM_COMMAND, wParam, lParam); 10251 10570 } 10252 10571 … … 10263 10582 * RETURN: 10264 10583 */ 10265 LRESULT CALLBACK EditLblWndProc(HWND hwnd, UINT uMsg, 10266 10584 LRESULT CALLBACK EditLblWndProc(HWND hwnd, UINT uMsg, 10585 WPARAM wParam, LPARAM lParam) 10267 10586 { 10268 10587 BOOL cancel = FALSE; … … 10272 10591 switch (uMsg) 10273 10592 { 10274 10275 10276 10277 10593 case WM_GETDLGCODE: 10594 return DLGC_WANTARROWS | DLGC_WANTALLKEYS; 10595 10596 case WM_KILLFOCUS: 10278 10597 if(bIgnoreKillFocus) 10279 10598 { 10280 10599 return TRUE; 10281 10600 } 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10601 break; 10602 10603 case WM_DESTROY: 10604 { 10605 WNDPROC editProc = einfo->EditWndProc; 10606 SetWindowLongA(hwnd, GWL_WNDPROC, (LONG)editProc); 10607 COMCTL32_Free(einfo); 10608 infoPtr->pedititem = NULL; 10609 return CallWindowProcA(editProc, hwnd, uMsg, wParam, lParam); 10610 } 10611 10612 case WM_KEYDOWN: 10613 if (VK_ESCAPE == (INT)wParam) 10614 { 10615 cancel = TRUE; 10297 10616 break; 10298 10617 10299 10300 10301 10302 10303 10304 return CallWindowProcA(einfo->EditWndProc, hwnd, 10305 10618 } 10619 else if (VK_RETURN == (INT)wParam) 10620 break; 10621 10622 default: 10623 return CallWindowProcA(einfo->EditWndProc, hwnd, 10624 uMsg, wParam, lParam); 10306 10625 } 10307 10626 10308 10627 if (einfo->EditLblCb) 10309 10628 { 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10629 char *buffer = NULL; 10630 10631 10632 if (!cancel) 10633 { 10634 int len = 1 + GetWindowTextLengthA(hwnd); 10635 10636 if (len > 1) 10637 { 10638 if (NULL != (buffer = (char *)COMCTL32_Alloc(len*sizeof(char)))) 10639 { 10640 GetWindowTextA(hwnd, buffer, len); 10641 } 10642 } 10643 } 10325 10644 /* Processing LVN_ENDLABELEDIT message could kill the focus */ 10326 10645 /* eg. Using a messagebox */ 10327 10646 bIgnoreKillFocus = TRUE; 10328 10329 10330 10331 10332 10333 10647 einfo->EditLblCb(GetParent(hwnd), buffer, einfo->param); 10648 10649 if (buffer) 10650 COMCTL32_Free(buffer); 10651 10652 einfo->EditLblCb = NULL; 10334 10653 bIgnoreKillFocus = FALSE; 10335 10654 } … … 10348 10667 * RETURN: 10349 10668 */ 10350 HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y, 10351 INT width, INT height, HWND parent, HINSTANCE hinst, 10352 10669 HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y, 10670 INT width, INT height, HWND parent, HINSTANCE hinst, 10671 EditlblCallback EditLblCb, DWORD param) 10353 10672 { 10354 10673 HWND hedit; … … 10360 10679 10361 10680 if (NULL == (infoPtr->pedititem = COMCTL32_Alloc(sizeof(EDITLABEL_ITEM)))) 10362 10681 return 0; 10363 10682 10364 10683 style |= WS_CHILDWINDOW|WS_CLIPSIBLINGS|ES_LEFT|WS_BORDER; … … 10384 10703 10385 10704 ReleaseDC(parent, hdc); 10386 if (!(hedit = CreateWindowA("Edit", text, style, x, y, sz.cx, height, 10387 10388 { 10389 10390 10705 if (!(hedit = CreateWindowA("Edit", text, style, x, y, sz.cx, height, 10706 parent, 0, hinst, 0))) 10707 { 10708 COMCTL32_Free(infoPtr->pedititem); 10709 return 0; 10391 10710 } 10392 10711 10393 10712 infoPtr->pedititem->param = param; 10394 10713 infoPtr->pedititem->EditLblCb = EditLblCb; 10395 infoPtr->pedititem->EditWndProc = (WNDPROC)SetWindowLongA(hedit, 10396 10714 infoPtr->pedititem->EditWndProc = (WNDPROC)SetWindowLongA(hedit, 10715 GWL_WNDPROC, (LONG) EditLblWndProc); 10397 10716 10398 10717 SendMessageA(hedit, WM_SETFONT, infoPtr->hFont, FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.