- Timestamp:
- Jul 12, 1999, 5:58:51 PM (26 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/comctl32undoc.c
r164 r295 1 /* $Id: comctl32undoc.c,v 1. 7 1999-06-23 19:45:00 achimhaExp $ */1 /* $Id: comctl32undoc.c,v 1.8 1999-07-12 15:58:46 cbratschi Exp $ */ 2 2 /* 3 3 * Undocumented functions from COMCTL32.DLL … … 11 11 * 12 12 */ 13 14 /* CB: todo 15 - porting/implementing string functions 16 - DPA_LoadStream 17 - DPA_SaveStream 18 */ 13 19 14 20 #include "comctl32.h" … … 28 34 * dwFlags [I] flags 29 35 * pfnSort [I] pointer to sort function 30 * dwParam5 [I]36 * pfnMerge [I] pointer to merge function 31 37 * lParam [I] application specific value 32 38 * … … 37 43 BOOL WINAPI 38 44 DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, 39 PFNDPACOMPARE pfnCompare, LPVOID pfnParam5, LPARAM lParam) 40 { 41 /* LPVOID *pWork1, *pWork2; */ 42 INT nCount1, nCount2; 45 PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam) 46 { 47 LPVOID pWork1, pWork2; 48 INT nResult; 49 INT nCount, nIndex; 50 INT nNewItems; 43 51 44 52 // TRACE (commctrl, "(%p %p %08lx %p %p %08lx): stub!\n", 45 // 53 // hdpa1, hdpa2, dwFlags, pfnCompare, pfnParam5, lParam); 46 54 47 55 if (IsBadWritePtr (hdpa1, sizeof(DPA))) 48 56 return FALSE; 49 57 50 58 if (IsBadWritePtr (hdpa2, sizeof(DPA))) 51 59 return FALSE; 52 60 53 61 if (IsBadCodePtr ((FARPROC)pfnCompare)) 54 55 56 if (IsBadCodePtr ((FARPROC)pfn Param5))57 62 return FALSE; 63 64 if (IsBadCodePtr ((FARPROC)pfnMerge)) 65 return FALSE; 58 66 59 67 if (dwFlags & DPAM_SORT) { 60 // TRACE (commctrl, "sorting dpa's!\n"); 61 DPA_Sort (hdpa1, pfnCompare, lParam); 62 DPA_Sort (hdpa2, pfnCompare, lParam); 63 } 64 65 if (hdpa2->nItemCount <= 0) 66 return TRUE; 67 68 nCount1 = hdpa1->nItemCount - 1; 69 70 nCount2 = hdpa2->nItemCount - 1; 71 72 // FIXME (commctrl, "nCount1=%d nCount2=%d\n", nCount1, nCount2); 73 // FIXME (commctrl, "semi stub!\n"); 68 // TRACE("sorting dpa's!\n"); 69 if (hdpa1->nItemCount > 0) 70 DPA_Sort (hdpa1, pfnCompare, lParam); 71 // TRACE ("dpa 1 sorted!\n"); 72 if (hdpa2->nItemCount > 0) 73 DPA_Sort (hdpa2, pfnCompare, lParam); 74 // TRACE ("dpa 2 sorted!\n"); 75 } 76 77 if (hdpa2->nItemCount < 1) 78 return TRUE; 79 80 // TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n", 81 // hdpa1->nItemCount, hdpa2->nItemCount); 82 83 84 /* preliminary hack - simply append the pointer list hdpa2 to hdpa1*/ 85 for (nCount = 0; nCount < hdpa2->nItemCount; nCount++) 86 DPA_InsertPtr (hdpa1, hdpa1->nItemCount + 1, hdpa2->ptrs[nCount]); 87 74 88 #if 0 75 76 do { 77 78 79 if (nResult == 0) { 80 81 } 82 else if (nResult > 0) { 83 84 } 85 else { 86 87 } 88 89 } 90 while (nCount2 >= 0); 91 89 /* incomplete implementation */ 90 91 pWork1 = &(hdpa1->ptrs[hdpa1->nItemCount - 1]); 92 pWork2 = &(hdpa2->ptrs[hdpa2->nItemCount - 1]); 93 94 nIndex = hdpa1->nItemCount - 1; 95 nCount = hdpa2->nItemCount - 1; 96 97 do 98 { 99 nResult = (pfnCompare)(pWork1, pWork2, lParam); 100 101 if (nResult == 0) 102 { 103 PVOID ptr; 104 105 ptr = (pfnMerge)(1, pWork1, pWork2, lParam); 106 if (!ptr) 107 return FALSE; 108 109 nCount--; 110 pWork2--; 111 pWork1 = ptr; 112 } 113 else if (nResult < 0) 114 { 115 if (!dwFlags & 8) 116 { 117 PVOID ptr; 118 119 ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1); 120 121 (pfnMerge)(2, ptr, NULL, lParam); 122 } 123 } 124 else 125 { 126 if (!dwFlags & 4) 127 { 128 PVOID ptr; 129 130 ptr = (pfnMerge)(3, pWork2, NULL, lParam); 131 if (!ptr) 132 return FALSE; 133 DPA_InsertPtr (hdpa1, nIndex, ptr); 134 } 135 nCount--; 136 pWork2--; 137 } 138 139 nIndex--; 140 pWork1--; 141 142 } 143 while (nCount >= 0); 92 144 #endif 93 94 145 95 146 return TRUE; … … 145 196 146 197 if (lpSrc) 147 198 lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize); 148 199 else 149 200 lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize); 150 201 151 202 return lpDest; … … 210 261 } MRUINFO, *LPMRUINFO; 211 262 212 263 213 264 typedef struct tagMRU 214 265 { … … 223 274 LPVOID WINAPI 224 275 CreateMRUListLazyA (LPMRUINFO lpmi, DWORD dwParam2, 225 276 DWORD dwParam3, DWORD dwParam4); 226 277 227 278 … … 249 300 #if 0 250 301 if (!(hmru->dwParam1 & 1001)) { 251 252 253 302 RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ, 303 hmru->lpszMRUString, 304 lstrlenA (hmru->lpszMRUString)); 254 305 } 255 306 … … 269 320 270 321 // FIXME (commctrl, "(%lx %lx %lx) empty stub!\n", 271 // 322 // dwParam1, dwParam2, dwParam3); 272 323 273 324 return 0; … … 280 331 281 332 // FIXME (commctrl, "(%lx %lx %lx %lx) empty stub!\n", 282 // 333 // dwParam1, dwParam2, dwParam3, dwParam4); 283 334 284 335 return TRUE; … … 304 355 305 356 if (lpmi) { 306 // 307 // 308 // 357 // FIXME (commctrl, "(%lx %lx %lx %lx \"%s\" %lx)\n", 358 // lpmi->dwParam1, lpmi->dwParam2, lpmi->dwParam3, 359 // (DWORD)lpmi->hkeyMain, lpmi->lpszSubKey, lpmi->dwParam6); 309 360 } 310 361 … … 338 389 339 390 if (!lpDest && lpSrc) 340 391 return lstrlenA (lpSrc); 341 392 342 393 if (nMaxLen == 0) 343 394 return 0; 344 395 345 396 if (lpSrc == NULL) { 346 347 397 lpDest[0] = '\0'; 398 return 0; 348 399 } 349 400 350 401 len = lstrlenA (lpSrc); 351 402 if (len >= nMaxLen) 352 403 len = nMaxLen - 1; 353 404 354 405 RtlMoveMemory (lpDest, lpSrc, len); … … 373 424 { 374 425 // TRACE (commctrl, "(%p %p)\n", lppDest, lpSrc); 375 426 376 427 if (lpSrc) { 377 378 379 380 381 428 LPSTR ptr = COMCTL32_ReAlloc (*lppDest, lstrlenA (lpSrc) + 1); 429 if (!ptr) 430 return FALSE; 431 lstrcpyA (ptr, lpSrc); 432 *lppDest = ptr; 382 433 } 383 434 else { 384 385 386 387 435 if (*lppDest) { 436 COMCTL32_Free (*lppDest); 437 *lppDest = NULL; 438 } 388 439 } 389 440 … … 411 462 412 463 if (!lpDest && lpSrc) 413 464 return lstrlenW (lpSrc); 414 465 415 466 if (nMaxLen == 0) 416 467 return 0; 417 468 418 469 if (lpSrc == NULL) { 419 420 470 lpDest[0] = L'\0'; 471 return 0; 421 472 } 422 473 423 474 len = lstrlenW (lpSrc); 424 475 if (len >= nMaxLen) 425 476 len = nMaxLen - 1; 426 477 427 478 RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR)); … … 446 497 { 447 498 // TRACE (commctrl, "(%p %p)\n", lppDest, lpSrc); 448 499 449 500 if (lpSrc) { 450 451 452 453 454 455 501 INT len = lstrlenW (lpSrc) + 1; 502 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR)); 503 if (!ptr) 504 return FALSE; 505 lstrcpyW (ptr, lpSrc); 506 *lppDest = ptr; 456 507 } 457 508 else { 458 459 460 461 509 if (*lppDest) { 510 COMCTL32_Free (*lppDest); 511 *lppDest = NULL; 512 } 462 513 } 463 514 … … 494 545 if (hdsa) 495 546 { 496 547 hdsa->nItemCount = 0; 497 548 hdsa->pData = NULL; 498 499 500 549 hdsa->nMaxCount = 0; 550 hdsa->nItemSize = nSize; 551 hdsa->nGrow = MAX(1, nGrow); 501 552 } 502 553 … … 522 573 523 574 if (!hdsa) 524 575 return FALSE; 525 576 526 577 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData))) 527 578 return FALSE; 528 579 529 580 return COMCTL32_Free (hdsa); … … 532 583 533 584 /************************************************************************** 534 * DSA_GetItem [COMCTL32.322] 585 * DSA_GetItem [COMCTL32.322] 535 586 * 536 587 * PARAMS … … 550 601 551 602 // TRACE (commctrl, "(%p %d %p)\n", hdsa, nIndex, pDest); 552 603 553 604 if (!hdsa) 554 605 return FALSE; 555 606 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) 556 607 return FALSE; 557 608 558 609 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); … … 564 615 565 616 /************************************************************************** 566 * DSA_GetItemPtr [COMCTL32.323] 617 * DSA_GetItemPtr [COMCTL32.323] 567 618 * 568 619 * Retrieves a pointer to the specified item. … … 585 636 586 637 if (!hdsa) 587 638 return NULL; 588 639 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) 589 640 return NULL; 590 641 591 642 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 592 643 593 644 // TRACE (commctrl, "-- ret=%p\n", pSrc); 594 645 … … 598 649 599 650 /************************************************************************** 600 * DSA_SetItem [COMCTL32.325] 651 * DSA_SetItem [COMCTL32.325] 601 652 * 602 653 * Sets the contents of an item in the array. … … 617 668 INT nSize, nNewItems; 618 669 LPVOID pDest, lpTemp; 619 670 620 671 // TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); 621 672 622 673 if ((!hdsa) || nIndex < 0) 623 624 674 return FALSE; 675 625 676 if (hdsa->nItemCount <= nIndex) { 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 } 677 /* within the old array */ 678 if (hdsa->nMaxCount > nIndex) { 679 /* within the allocated space, set a new boundary */ 680 hdsa->nItemCount = nIndex + 1; 681 } 682 else { 683 /* resize the block of memory */ 684 nNewItems = 685 hdsa->nGrow * ((INT)((nIndex - 1) / hdsa->nGrow) + 1); 686 nSize = hdsa->nItemSize * nNewItems; 687 688 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize); 689 if (!lpTemp) 690 return FALSE; 691 692 hdsa->nMaxCount = nNewItems; 693 hdsa->nItemCount = nIndex + 1; 694 hdsa->pData = lpTemp; 695 } 645 696 } 646 697 … … 648 699 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 649 700 // TRACE("-- move dest=%p src=%p size=%d\n", 650 // 701 // pDest, pSrc, hdsa->nItemSize); 651 702 memmove (pDest, pSrc, hdsa->nItemSize); 652 703 … … 656 707 657 708 /************************************************************************** 658 * DSA_InsertItem [COMCTL32.325] 709 * DSA_InsertItem [COMCTL32.325] 659 710 * 660 711 * PARAMS … … 674 725 LPVOID lpTemp, lpDest; 675 726 LPDWORD p; 676 727 677 728 // TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); 678 729 679 730 if ((!hdsa) || nIndex < 0) 680 731 return -1; 681 732 682 733 for (i = 0; i < hdsa->nItemSize; i += 4) { 683 684 // 685 // 686 // 687 // 688 } 689 734 p = *(DWORD**)((char *) pSrc + i); 735 // if (IsBadStringPtrA ((char*)p, 256)) 736 // TRACE("-- %d=%p\n", i, (DWORD*)p); 737 // else 738 // TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p)); 739 } 740 690 741 /* when nIndex > nItemCount then append */ 691 742 if (nIndex >= hdsa->nItemCount) 692 743 nIndex = hdsa->nItemCount; 693 744 694 745 /* do we need to resize ? */ 695 746 if (hdsa->nItemCount >= hdsa->nMaxCount) { 696 697 698 699 700 701 702 703 704 hdsa->pData = lpTemp; 747 nNewItems = hdsa->nMaxCount + hdsa->nGrow; 748 nSize = hdsa->nItemSize * nNewItems; 749 750 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize); 751 if (!lpTemp) 752 return -1; 753 754 hdsa->nMaxCount = nNewItems; 755 hdsa->pData = lpTemp; 705 756 } 706 757 707 758 /* do we need to move elements ? */ 708 759 if (nIndex < hdsa->nItemCount) { 709 710 711 712 // 713 // 714 760 lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 761 lpDest = (char *) lpTemp + hdsa->nItemSize; 762 nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize; 763 // TRACE("-- move dest=%p src=%p size=%d\n", 764 // lpDest, lpTemp, nSize); 765 memmove (lpDest, lpTemp, nSize); 715 766 } 716 767 … … 719 770 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 720 771 // TRACE("-- move dest=%p src=%p size=%d\n", 721 // 772 // lpDest, pSrc, hdsa->nItemSize); 722 773 memmove (lpDest, pSrc, hdsa->nItemSize); 723 774 … … 727 778 728 779 /************************************************************************** 729 * DSA_DeleteItem [COMCTL32.326] 780 * DSA_DeleteItem [COMCTL32.326] 730 781 * 731 782 * PARAMS … … 743 794 LPVOID lpDest,lpSrc; 744 795 INT nSize; 745 796 746 797 // TRACE (commctrl, "(%p %d)\n", hdsa, nIndex); 747 798 748 799 if (!hdsa) 749 800 return -1; 750 801 if (nIndex < 0 || nIndex >= hdsa->nItemCount) 751 802 return -1; 752 803 753 804 /* do we need to move ? */ 754 805 if (nIndex < hdsa->nItemCount - 1) { 755 756 757 758 // 759 // 760 761 } 762 806 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 807 lpSrc = (char *) lpDest + hdsa->nItemSize; 808 nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1); 809 // TRACE (commctrl, "-- move dest=%p src=%p size=%d\n", 810 // lpDest, lpSrc, nSize); 811 memmove (lpDest, lpSrc, nSize); 812 } 813 763 814 hdsa->nItemCount--; 764 815 765 816 /* free memory ? */ 766 817 if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) { 767 768 769 770 771 772 773 774 818 nSize = hdsa->nItemSize * hdsa->nItemCount; 819 820 lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize); 821 if (!lpDest) 822 return -1; 823 824 hdsa->nMaxCount = hdsa->nItemCount; 825 hdsa->pData = lpDest; 775 826 } 776 827 … … 797 848 // TRACE (commctrl, "(%p)\n", hdsa); 798 849 799 if (!hdsa) 800 850 if (!hdsa) 851 return FALSE; 801 852 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData))) 802 853 return FALSE; 803 854 804 855 hdsa->nItemCount = 0; … … 835 886 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA)); 836 887 if (hdpa) { 837 838 839 840 841 888 hdpa->nGrow = MAX(8, nGrow); 889 hdpa->hHeap = COMCTL32_hHeap; 890 hdpa->nMaxCount = hdpa->nGrow * 2; 891 hdpa->ptrs = 892 (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID)); 842 893 } 843 894 … … 865 916 866 917 if (!hdpa) 867 918 return FALSE; 868 919 869 920 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) 870 921 return FALSE; 871 922 872 923 return HeapFree (hdpa->hHeap, 0, hdpa); … … 894 945 895 946 if (!hdpa) 896 947 return FALSE; 897 948 898 949 hdpa->nGrow = MAX(8, nGrow); … … 929 980 930 981 if (!hdpa) 931 982 return NULL; 932 983 933 984 // TRACE (commctrl, "(%p %p)\n", hdpa, hdpaNew); 934 985 935 986 if (!hdpaNew) { 936 937 938 939 940 987 /* create a new DPA */ 988 hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 989 sizeof(DPA)); 990 hdpaTemp->hHeap = hdpa->hHeap; 991 hdpaTemp->nGrow = hdpa->nGrow; 941 992 } 942 993 else 943 994 hdpaTemp = hdpaNew; 944 995 945 996 if (hdpaTemp->ptrs) { 946 947 948 949 950 997 /* remove old pointer array */ 998 HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs); 999 hdpaTemp->ptrs = NULL; 1000 hdpaTemp->nItemCount = 0; 1001 hdpaTemp->nMaxCount = 0; 951 1002 } 952 1003 953 1004 /* create a new pointer array */ 954 1005 nNewItems = hdpaTemp->nGrow * 955 1006 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1); 956 1007 nSize = nNewItems * sizeof(LPVOID); 957 1008 hdpaTemp->ptrs = 958 1009 (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize); 959 1010 hdpaTemp->nMaxCount = nNewItems; 960 1011 … … 962 1013 hdpaTemp->nItemCount = hdpa->nItemCount; 963 1014 memmove (hdpaTemp->ptrs, hdpa->ptrs, 964 1015 hdpaTemp->nItemCount * sizeof(LPVOID)); 965 1016 966 1017 return hdpaTemp; … … 988 1039 989 1040 if (!hdpa) 990 1041 return NULL; 991 1042 if (!hdpa->ptrs) 992 1043 return NULL; 993 1044 if ((i < 0) || (i >= hdpa->nItemCount)) 994 1045 return NULL; 995 1046 996 1047 // TRACE (commctrl, "-- %p\n", hdpa->ptrs[i]); … … 1020 1071 1021 1072 if (!hdpa->ptrs) 1022 1073 return -1; 1023 1074 1024 1075 for (i = 0; i < hdpa->nItemCount; i++) { 1025 1026 1076 if (hdpa->ptrs[i] == p) 1077 return i; 1027 1078 } 1028 1079 … … 1055 1106 1056 1107 if ((!hdpa) || (i < 0)) 1057 1108 return -1; 1058 1109 1059 1110 if (!hdpa->ptrs) { 1060 1061 1062 1063 1064 1065 1111 hdpa->ptrs = 1112 (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1113 2 * hdpa->nGrow * sizeof(LPVOID)); 1114 if (!hdpa->ptrs) 1115 return -1; 1116 hdpa->nMaxCount = hdpa->nGrow * 2; 1066 1117 nIndex = 0; 1067 1118 } 1068 1119 else { 1069 1070 // 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 // 1085 1086 1087 // 1088 1089 1090 1091 // 1092 // 1093 1094 1095 1120 if (hdpa->nItemCount >= hdpa->nMaxCount) { 1121 // TRACE (commctrl, "-- resizing\n"); 1122 nNewItems = hdpa->nMaxCount + hdpa->nGrow; 1123 nSize = nNewItems * sizeof(LPVOID); 1124 1125 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1126 hdpa->ptrs, nSize); 1127 if (!lpTemp) 1128 return -1; 1129 hdpa->nMaxCount = nNewItems; 1130 hdpa->ptrs = lpTemp; 1131 } 1132 1133 if (i >= hdpa->nItemCount) { 1134 nIndex = hdpa->nItemCount; 1135 // TRACE (commctrl, "-- appending at %d\n", nIndex); 1136 } 1137 else { 1138 // TRACE (commctrl, "-- inserting at %d\n", i); 1139 lpTemp = hdpa->ptrs + i; 1140 lpDest = lpTemp + 1; 1141 nSize = (hdpa->nItemCount - i) * sizeof(LPVOID); 1142 // TRACE (commctrl, "-- move dest=%p src=%p size=%x\n", 1143 // lpDest, lpTemp, nSize); 1144 memmove (lpDest, lpTemp, nSize); 1145 nIndex = i; 1146 } 1096 1147 } 1097 1148 … … 1123 1174 { 1124 1175 LPVOID *lpTemp; 1125 1176 1126 1177 // TRACE (commctrl, "(%p %d %p)\n", hdpa, i, p); 1127 1178 1128 1179 if ((!hdpa) || i < 0) 1129 1130 1180 return FALSE; 1181 1131 1182 if (hdpa->nItemCount <= i) { 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 hdpa->ptrs = lpTemp; 1150 } 1183 /* within the old array */ 1184 if (hdpa->nMaxCount > i) { 1185 /* within the allocated space, set a new boundary */ 1186 hdpa->nItemCount = i; 1187 } 1188 else { 1189 /* resize the block of memory */ 1190 INT nNewItems = 1191 hdpa->nGrow * ((INT)((i - 1) / hdpa->nGrow) + 1); 1192 INT nSize = nNewItems * sizeof(LPVOID); 1193 1194 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1195 hdpa->ptrs, nSize); 1196 if (!lpTemp) 1197 return FALSE; 1198 1199 hdpa->nItemCount = nNewItems; 1200 hdpa->ptrs = lpTemp; 1201 } 1151 1202 } 1152 1203 … … 1177 1228 LPVOID *lpDest, *lpSrc, lpTemp = NULL; 1178 1229 INT nSize; 1179 1230 1180 1231 // TRACE (commctrl, "(%p %d)\n", hdpa, i); 1181 1232 1182 1233 if ((!hdpa) || i < 0 || i >= hdpa->nItemCount) 1183 1234 return NULL; 1184 1235 1185 1236 lpTemp = hdpa->ptrs[i]; … … 1187 1238 /* do we need to move ?*/ 1188 1239 if (i < hdpa->nItemCount - 1) { 1189 1190 1191 1192 // 1193 // 1194 1195 } 1196 1240 lpDest = hdpa->ptrs + i; 1241 lpSrc = lpDest + 1; 1242 nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID); 1243 // TRACE (commctrl,"-- move dest=%p src=%p size=%x\n", 1244 // lpDest, lpSrc, nSize); 1245 memmove (lpDest, lpSrc, nSize); 1246 } 1247 1197 1248 hdpa->nItemCount --; 1198 1249 1199 1250 /* free memory ?*/ 1200 1251 if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) { 1201 1202 1203 1204 1205 1206 1207 1208 1209 hdpa->ptrs = (LPVOID*)lpDest; 1252 INT nNewItems = MIN(hdpa->nGrow * 2, hdpa->nItemCount); 1253 nSize = nNewItems * sizeof(LPVOID); 1254 lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1255 hdpa->ptrs, nSize); 1256 if (!lpDest) 1257 return NULL; 1258 1259 hdpa->nMaxCount = nNewItems; 1260 hdpa->ptrs = (LPVOID*)lpDest; 1210 1261 } 1211 1262 … … 1232 1283 // TRACE (commctrl, "(%p)\n", hdpa); 1233 1284 1234 if (!hdpa) 1235 1285 if (!hdpa) 1286 return FALSE; 1236 1287 1237 1288 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) 1238 1289 return FALSE; 1239 1290 1240 1291 hdpa->nItemCount = 0; 1241 1292 hdpa->nMaxCount = hdpa->nGrow * 2; 1242 1293 hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1243 1294 hdpa->nMaxCount * sizeof(LPVOID)); 1244 1295 1245 1296 return TRUE; … … 1265 1316 static VOID 1266 1317 DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, 1267 1318 PFNDPACOMPARE pfnCompare, LPARAM lParam) 1268 1319 { 1269 1320 LPVOID t, v; … … 1271 1322 1272 1323 // TRACE (commctrl, "l=%i r=%i\n", l, r); 1273 1324 1274 1325 i = l; 1275 1326 j = r; 1276 1327 v = lpPtrs[(int)(l+r)/2]; 1277 1328 do { 1278 1279 1280 if (i <= j) 1281 1282 1283 1284 1285 1329 while ((pfnCompare)(lpPtrs[i], v, lParam) > 0) i++; 1330 while ((pfnCompare)(lpPtrs[j], v, lParam) < 0) j--; 1331 if (i <= j) 1332 { 1333 t = lpPtrs[i]; 1334 lpPtrs[i++] = lpPtrs[j]; 1335 lpPtrs[j--] = t; 1336 } 1286 1337 } while (i <= j); 1287 1338 if (l < j) DPA_QuickSort (lpPtrs, l, j, pfnCompare, lParam); … … 1309 1360 { 1310 1361 if (!hdpa || !pfnCompare) 1311 1362 return FALSE; 1312 1363 1313 1364 // TRACE (commctrl, "(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam); 1314 1365 1315 1366 if ((hdpa->nItemCount > 1) && (hdpa->ptrs)) 1316 1317 1367 DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1, 1368 pfnCompare, lParam); 1318 1369 1319 1370 return TRUE; … … 1346 1397 INT WINAPI 1347 1398 DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart, 1348 1399 PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions) 1349 1400 { 1350 1401 if (!hdpa || !pfnCompare || !pFind) 1351 1402 return -1; 1352 1403 1353 1404 // TRACE (commctrl, "(%p %p %d %p 0x%08lx 0x%08x)\n", 1354 // 1405 // hdpa, pFind, nStart, pfnCompare, lParam, uOptions); 1355 1406 1356 1407 if (uOptions & DPAS_SORTED) { 1357 1358 1359 1360 1361 // 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 // 1375 1376 1377 1378 1379 1380 // 1381 1382 1383 1384 1385 // 1386 1387 1408 /* array is sorted --> use binary search */ 1409 INT l, r, x, n; 1410 LPVOID *lpPtr; 1411 1412 // TRACE (commctrl, "binary search\n"); 1413 1414 l = (nStart == -1) ? 0 : nStart; 1415 r = hdpa->nItemCount - 1; 1416 lpPtr = hdpa->ptrs; 1417 while (r >= l) { 1418 x = (l + r) / 2; 1419 n = (pfnCompare)(pFind, lpPtr[x], lParam); 1420 if (n < 0) 1421 r = x - 1; 1422 else 1423 l = x + 1; 1424 if (n == 0) { 1425 // TRACE (commctrl, "-- ret=%d\n", n); 1426 return n; 1427 } 1428 } 1429 1430 if (uOptions & DPAS_INSERTBEFORE) { 1431 // TRACE (commctrl, "-- ret=%d\n", r); 1432 return r; 1433 } 1434 1435 if (uOptions & DPAS_INSERTAFTER) { 1436 // TRACE (commctrl, "-- ret=%d\n", l); 1437 return l; 1438 } 1388 1439 } 1389 1440 else { 1390 1391 1392 1393 1394 // 1395 1396 1397 1398 1399 1400 // 1401 1402 1403 1441 /* array is not sorted --> use linear search */ 1442 LPVOID *lpPtr; 1443 INT nIndex; 1444 1445 // TRACE (commctrl, "linear search\n"); 1446 1447 nIndex = (nStart == -1)? 0 : nStart; 1448 lpPtr = hdpa->ptrs; 1449 for (; nIndex < hdpa->nItemCount; nIndex++) { 1450 if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) { 1451 // TRACE (commctrl, "-- ret=%d\n", nIndex); 1452 return nIndex; 1453 } 1454 } 1404 1455 } 1405 1456 … … 1431 1482 1432 1483 if (hHeap) 1433 1484 hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA)); 1434 1485 else 1435 1486 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA)); 1436 1487 1437 1488 if (hdpa) { 1438 1439 1440 1441 1442 1443 1489 hdpa->nGrow = MIN(8, nGrow); 1490 hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap; 1491 hdpa->nMaxCount = hdpa->nGrow * 2; 1492 hdpa->ptrs = 1493 (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, 1494 hdpa->nMaxCount * sizeof(LPVOID)); 1444 1495 } 1445 1496 … … 1476 1527 1477 1528 // TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n", 1478 // 1479 // 1529 // lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr, 1530 // lpNotify->dwParam5); 1480 1531 1481 1532 if (!lpNotify->hwndTo) 1482 1533 return 0; 1483 1534 1484 1535 if (lpNotify->hwndFrom == -1) { 1485 1486 1536 lpNmh = lpHdr; 1537 idFrom = lpHdr->idFrom; 1487 1538 } 1488 1539 else { 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1540 if (lpNotify->hwndFrom) { 1541 HWND hwndParent = GetParent (lpNotify->hwndFrom); 1542 if (hwndParent) { 1543 hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER); 1544 if (hwndParent) 1545 idFrom = GetDlgCtrlID (lpNotify->hwndFrom); 1546 } 1547 } 1548 1549 lpNmh = (lpHdr) ? lpHdr : &nmhdr; 1550 1551 lpNmh->hwndFrom = lpNotify->hwndFrom; 1552 lpNmh->idFrom = idFrom; 1553 lpNmh->code = uCode; 1503 1554 } 1504 1555 … … 1523 1574 LRESULT WINAPI 1524 1575 COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo, 1525 1576 UINT uCode, LPNMHDR lpHdr) 1526 1577 { 1527 1578 NOTIFYDATA notify; 1528 1579 1529 1580 // TRACE (commctrl, "(0x%04x 0x%04x %d %p)\n", 1530 // 1581 // hwndFrom, hwndTo, uCode, lpHdr); 1531 1582 1532 1583 notify.hwndFrom = hwndFrom; … … 1556 1607 LRESULT WINAPI 1557 1608 COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode, 1558 1609 LPNMHDR lpHdr, DWORD dwParam5) 1559 1610 { 1560 1611 NOTIFYDATA notify; … … 1562 1613 1563 1614 // TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n", 1564 // 1615 // hwndFrom, hwndTo, uCode, lpHdr, dwParam5); 1565 1616 1566 1617 hwndNotify = hwndTo; 1567 1618 if (!hwndTo) { 1568 1569 1570 1571 1572 1619 if (IsWindow (hwndFrom)) { 1620 hwndNotify = GetParent (hwndFrom); 1621 if (!hwndNotify) 1622 return 0; 1623 } 1573 1624 } 1574 1625 … … 1605 1656 1606 1657 if (*lpStr2 == 0) 1607 1658 return ((LPSTR)lpStr1); 1608 1659 len1 = 0; 1609 1660 while (lpStr1[len1] != 0) ++len1; … … 1611 1662 while (lpStr2[len2] != 0) ++len2; 1612 1663 if (len2 == 0) 1613 1664 return ((LPSTR)(lpStr1 + len1)); 1614 1665 first = tolower (*lpStr2); 1615 1666 while (len1 >= len2) { 1616 1617 1618 1619 1620 1621 1622 } 1623 1667 if (tolower(*lpStr1) == first) { 1668 for (i = 1; i < len2; ++i) 1669 if (tolower (lpStr1[i]) != tolower(lpStr2[i])) 1670 break; 1671 if (i >= len2) 1672 return ((LPSTR)lpStr1); 1673 } 1674 ++lpStr1; --len1; 1624 1675 } 1625 1676 return (NULL); … … 1641 1692 * 1642 1693 * Enumerates all items in a dynamic pointer array. 1643 *1644 * PARAMS1645 * hdpa [I] handle to the dynamic pointer array1646 * enumProc [I]1647 * lParam [I]1648 *1649 * RETURNS1650 * none1651 */1652 1653 VOID WINAPI1654 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)1655 {1656 INT i;1657 1658 // TRACE (commctrl, "(%p %p %08lx)\n", hdpa, enumProc, lParam);1659 1660 if (!hdpa)1661 return;1662 if (hdpa->nItemCount <= 0)1663 return;1664 1665 for (i = 0; i < hdpa->nItemCount; i++) {1666 if ((enumProc)(hdpa->ptrs[i], lParam) == 0)1667 return;1668 }1669 1670 return;1671 }1672 1673 1674 /**************************************************************************1675 * DPA_DestroyCallback [COMCTL32.386]1676 *1677 * Enumerates all items in a dynamic pointer array and destroys it.1678 1694 * 1679 1695 * PARAMS … … 1683 1699 * 1684 1700 * RETURNS 1701 * none 1702 */ 1703 1704 1705 VOID WINAPI 1706 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam) 1707 { 1708 INT i; 1709 1710 // TRACE (commctrl, "(%p %p %08lx)\n", hdpa, enumProc, lParam); 1711 1712 if (!hdpa) 1713 return; 1714 if (hdpa->nItemCount <= 0) 1715 return; 1716 1717 for (i = 0; i < hdpa->nItemCount; i++) { 1718 if ((enumProc)(hdpa->ptrs[i], lParam) == 0) 1719 return; 1720 } 1721 1722 return; 1723 } 1724 1725 1726 /************************************************************************** 1727 * DPA_DestroyCallback [COMCTL32.386] 1728 * 1729 * Enumerates all items in a dynamic pointer array and destroys it. 1730 * 1731 * PARAMS 1732 * hdpa [I] handle to the dynamic pointer array 1733 * enumProc [I] 1734 * lParam [I] 1735 * 1736 * RETURNS 1685 1737 * Success: TRUE 1686 1738 * Failure: FALSE … … 1720 1772 1721 1773 if (!hdsa) 1722 1774 return; 1723 1775 if (hdsa->nItemCount <= 0) 1724 1776 return; 1725 1777 1726 1778 for (i = 0; i < hdsa->nItemCount; i++) { 1727 1728 1729 1779 LPVOID lpItem = DSA_GetItemPtr (hdsa, i); 1780 if ((enumProc)(lpItem, lParam) == 0) 1781 return; 1730 1782 } 1731 1783 … … 1796 1848 */ 1797 1849 LPSTR WINAPI COMCTL32_StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch) { 1798 // return lstrrchr(lpStart, lpEnd, wMatch); 1850 // return lstrrchr(lpStart, lpEnd, wMatch); 1799 1851 } 1800 1852 … … 1804 1856 */ 1805 1857 LPWSTR WINAPI COMCTL32_StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch) { 1806 // return lstrrchrw(lpStart, lpEnd, wMatch); 1858 // return lstrrchrw(lpStart, lpEnd, wMatch); 1807 1859 } 1808 1860 … … 1838 1890 // if( CRTDLL_wcschr(lpSet, *(WORD*)lpLoop)) 1839 1891 // return (INT)(lpLoop-lpStr); 1840 1892 1841 1893 // return (INT)(lpLoop-lpStr); 1842 1894 } -
trunk/src/comctl32/imagelist.c
r164 r295 1 /* $Id: imagelist.c,v 1. 4 1999-06-23 19:45:00 achimhaExp $ */1 /* $Id: imagelist.c,v 1.5 1999-07-12 15:58:47 cbratschi Exp $ */ 2 2 /* 3 3 * ImageList implementation … … 21 21 * - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use 22 22 * ImageList_DrawIndirect. Since ImageList_DrawIndirect is still 23 * partially imlemented, the functions mentioned above will be 23 * partially imlemented, the functions mentioned above will be 24 24 * limited in functionality too. 25 25 */ 26 27 /* CB: todo 28 - ImageList_Read 29 - ImageList_Write 30 */ 26 31 27 32 /* This must be defined because the HIMAGELIST type is just a pointer … … 32 37 #define __WINE_IMAGELIST_C 33 38 34 #include "imagelist.h" 39 #include "imagelist.h" 35 40 #include "commctrl.h" 36 41 #include "comctl32.h" … … 57 62 58 63 /************************************************************************* 59 * IMAGELIST_InternalExpandBitmaps [Internal] 64 * IMAGELIST_InternalExpandBitmaps [Internal] 60 65 * 61 66 * Expands the bitmaps of an image list by the given number of images. … … 101 106 102 107 if (himl->hbmMask) { 103 hbmNewBitmap = 108 hbmNewBitmap = 104 109 CreateBitmap (nNewWidth, himl->cy, 1, 1, NULL); 105 110 … … 138 143 139 144 INT WINAPI 140 ImageList_Add (HIMAGELIST himl, 145 ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask) 141 146 { 142 147 HDC hdcSrc, hdcDst; … … 146 151 147 152 if (!himl || !hbmImage) 148 153 return -1; 149 154 150 155 GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp); … … 164 169 BitBlt (hdcDst, himl->cCurImage * himl->cx, 0, 165 170 bmp.bmWidth, himl->cy, hdcSrc, 0, 0, SRCCOPY); 166 171 167 172 if (himl->hbmMask) { 168 173 if (hbmMask) { 169 174 /* copy mask bitmap */ 170 175 SelectObject (hdcDst, himl->hbmMask); 171 176 SelectObject (hdcSrc, hbmMask); 172 177 BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy, 173 178 hdcSrc, 0, 0, SRCCOPY); 174 179 } 175 180 else { 176 181 /* copy monochrome image to the mask bitmap */ 177 182 SelectObject (hdcDst, himl->hbmMask); 178 183 SelectObject (hdcSrc, hbmImage); 179 180 181 182 184 SetBkColor (hdcSrc, GetNearestColor (hdcSrc, 185 GetPixel (hdcSrc, 0, 0))); 186 BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy, 187 hdcSrc, nStartX, 0, SRCCOPY); 183 188 } 184 189 } … … 216 221 217 222 /************************************************************************* 218 * ImageList_AddMasked [COMCTL32.41] 223 * ImageList_AddMasked [COMCTL32.41] 219 224 * 220 225 * Adds an image or images to an image list and creates a mask from the … … 239 244 240 245 if (himl == NULL) 241 246 return -1; 242 247 243 248 if (!GetObjectA (hBitmap, sizeof(BITMAP), &bmp)) 244 249 return -1; 245 250 246 251 nImageCount = bmp.bmWidth / himl->cx; … … 261 266 262 267 if (himl->hbmMask) { 263 264 265 266 268 COLORREF bkColor = (clrMask != CLR_DEFAULT) ? clrMask : 269 GetNearestColor (hdcBitmap, GetPixel (hdcBitmap, 0, 0)); 270 271 /* create mask from image */ 267 272 hdcMask = CreateCompatibleDC (0); 268 273 SelectObject (hdcMask, himl->hbmMask); 269 274 270 271 272 273 275 /* create monochrome image to the mask bitmap */ 276 SetBkColor (hdcBitmap, bkColor); 277 BitBlt (hdcMask, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy, 278 hdcBitmap, 0, 0, SRCCOPY); 274 279 275 280 DeleteDC (hdcMask); … … 278 283 DeleteDC (hdcImage); 279 284 DeleteDC (hdcBitmap); 280 285 281 286 return nIndex; 282 287 } … … 284 289 285 290 /************************************************************************* 286 * ImageList_BeginDrag [COMCTL32.42] 291 * ImageList_BeginDrag [COMCTL32.42] 287 292 * 288 293 * Creates a temporary image list that contains one image. It will be used … … 302 307 BOOL WINAPI 303 308 ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack, 304 309 INT dxHotspot, INT dyHotspot) 305 310 { 306 311 HDC hdcSrc, hdcDst; … … 309 314 310 315 if (himlTrack == NULL) 311 316 return FALSE; 312 317 313 318 if (himlInternalDrag) … … 315 320 316 321 himlInternalDrag = 317 318 322 ImageList_Create (himlTrack->cx, himlTrack->cy, 323 himlTrack->flags, 1, 1); 319 324 if (himlInternalDrag == NULL) { 320 325 // ERR(imagelist, "Error creating drag image list!\n"); … … 350 355 351 356 /************************************************************************* 352 * ImageList_Copy [COMCTL32.43] 353 * 354 * Copies an image of the source image list to an image of the 357 * ImageList_Copy [COMCTL32.43] 358 * 359 * Copies an image of the source image list to an image of the 355 360 * destination image list. Images can be copied or swapped. 356 361 * … … 373 378 374 379 BOOL WINAPI 375 ImageList_Copy (HIMAGELIST himlDst, INT iDst, 376 377 { 378 HDC hdcSrc, hdcDst; 380 ImageList_Copy (HIMAGELIST himlDst, INT iDst, HIMAGELIST himlSrc, 381 INT iSrc, INT uFlags) 382 { 383 HDC hdcSrc, hdcDst; 379 384 380 385 // TRACE(imagelist, "iDst=%d iSrc=%d\n", iDst, iSrc); 381 386 382 387 if ((himlSrc == NULL) || (himlDst == NULL)) 383 388 return FALSE; 384 389 if ((iDst < 0) || (iDst >= himlDst->cCurImage)) 385 390 return FALSE; 386 391 if ((iSrc < 0) || (iSrc >= himlSrc->cCurImage)) 387 392 return FALSE; 388 393 389 394 hdcSrc = CreateCompatibleDC (0); … … 401 406 himlSrc->uBitsPixel, NULL); 402 407 hbmTempMask = CreateBitmap (himlSrc->cx, himlSrc->cy, 1, 403 408 1, NULL); 404 409 405 410 /* copy (and stretch) destination to temporary bitmaps.(save) */ … … 494 499 HIMAGELIST WINAPI 495 500 ImageList_Create (INT cx, INT cy, UINT flags, 496 501 INT cInitial, INT cGrow) 497 502 { 498 503 HIMAGELIST himl; … … 500 505 INT nCount; 501 506 HBITMAP hbmTemp; 502 static WORD aBitBlend25[] = 507 static WORD aBitBlend25[] = 503 508 {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00}; 504 509 … … 542 547 if (himl->flags & ILC_MASK) { 543 548 himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy, 544 549 1, 1, NULL); 545 550 if (himl->hbmMask == 0) { 546 551 // ERR(imagelist, "Error creating mask bitmap!\n"); … … 567 572 568 573 /************************************************************************* 569 * ImageList_Destroy [COMCTL32.45] 574 * ImageList_Destroy [COMCTL32.45] 570 575 * 571 576 * Destroys an image list. … … 581 586 BOOL WINAPI 582 587 ImageList_Destroy (HIMAGELIST himl) 583 { 588 { 584 589 if (!himl) 585 590 return FALSE; 586 591 587 592 /* delete image bitmaps */ … … 596 601 if (himl->hbrBlend50) 597 602 DeleteObject (himl->hbrBlend50); 598 603 599 604 COMCTL32_Free (himl); 600 605 … … 604 609 605 610 /************************************************************************* 606 * ImageList_DragEnter [COMCTL32.46] 611 * ImageList_DragEnter [COMCTL32.46] 607 612 * 608 613 * Locks window update and displays the drag image at the given position. … … 626 631 { 627 632 if (himlInternalDrag == NULL) 628 633 return FALSE; 629 634 630 635 if (hwndLock) 631 636 hwndInternalDrag = hwndLock; 632 637 else 633 638 hwndInternalDrag = GetDesktopWindow (); 634 639 635 640 xInternalPos = x; … … 638 643 hdcBackBuffer = CreateCompatibleDC (0); 639 644 hbmBackBuffer = CreateCompatibleBitmap (hdcBackBuffer, 640 645 himlInternalDrag->cx, himlInternalDrag->cy); 641 646 642 647 ImageList_DragShowNolock (TRUE); … … 647 652 648 653 /************************************************************************* 649 * ImageList_DragLeave [COMCTL32.47] 654 * ImageList_DragLeave [COMCTL32.47] 650 655 * 651 656 * Unlocks window update and hides the drag image. … … 663 668 { 664 669 if (hwndLock) 665 670 hwndInternalDrag = hwndLock; 666 671 else 667 672 hwndInternalDrag = GetDesktopWindow (); 668 673 669 674 ImageList_DragShowNolock (FALSE); … … 677 682 678 683 /************************************************************************* 679 * ImageList_DragMove [COMCTL32.48] 684 * ImageList_DragMove [COMCTL32.48] 680 685 * 681 686 * Moves the drag image. … … 709 714 710 715 /************************************************************************* 711 * ImageList_DragShowNolock [COMCTL32.49] 716 * ImageList_DragShowNolock [COMCTL32.49] 712 717 * 713 718 * Shows or hides the drag image. … … 733 738 734 739 hdcDrag = GetDCEx (hwndInternalDrag, 0, 735 740 DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE); 736 741 737 742 if (bShow) { 738 739 740 741 742 743 /* show drag image */ 744 745 /* save background */ 746 747 /* draw drag image */ 743 748 744 749 } 745 750 else { 746 747 748 751 /* hide drag image */ 752 753 /* restore background */ 749 754 750 755 } … … 780 785 BOOL WINAPI 781 786 ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc, 782 787 INT x, INT y, UINT fStyle) 783 788 { 784 789 IMAGELISTDRAWPARAMS imldp; … … 833 838 BOOL WINAPI 834 839 ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, 835 836 840 INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg, 841 UINT fStyle) 837 842 { 838 843 IMAGELISTDRAWPARAMS imldp; … … 858 863 859 864 /************************************************************************* 860 * ImageList_DrawIndirect [COMCTL32.52] 865 * ImageList_DrawIndirect [COMCTL32.52] 861 866 * 862 867 * Draws an image using ... … … 888 893 889 894 if (pimldp == NULL) 890 895 return FALSE; 891 896 if (pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS)) 892 897 return FALSE; 893 898 if (pimldp->himl == NULL) 894 899 return FALSE; 895 900 if ((pimldp->i < 0) || (pimldp->i > pimldp->himl->cCurImage)) 896 901 return FALSE; 897 902 898 903 himlLocal = pimldp->himl; … … 914 919 bMaskTrans = TRUE; 915 920 } 916 921 917 922 /* ILD_IMAGE state (changes) */ 918 923 if (pimldp->fStyle & ILD_IMAGE) … … 922 927 bImageTrans = FALSE; 923 928 } 924 929 925 930 /* ILD_MASK state (changes) */ 926 931 if ((pimldp->fStyle & ILD_MASK) && (himlLocal->hbmMask)) … … 947 952 if (bMask) 948 953 { 949 950 951 952 953 954 955 954 /* draw the mask */ 955 SelectObject (hdcImageList, himlLocal->hbmMask); 956 SetBkColor (hdcImageList, RGB(255, 255, 255)); 957 SetTextColor (hdcImageList, RGB(0, 0, 0)); 958 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 959 hdcImageList, himlLocal->cx * pimldp->i, 0, 960 bMaskTrans ? SRCAND : SRCCOPY); 956 961 } 957 962 958 963 if (bImage) 959 964 { 960 961 965 /* draw the image */ 966 SelectObject (hdcImageList, himlLocal->hbmImage); 962 967 963 968 if (!bImageTrans) … … 993 998 SelectObject (hdcImageList, himlLocal->hbmMask); 994 999 BitBlt (hdcTempImage, 0, 0, himlLocal->cx, 995 himlLocal->cy, hdcImageList, 1000 himlLocal->cy, hdcImageList, 996 1001 pimldp->i * himlLocal->cx, 0, SRCPAINT); 997 1002 998 1003 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 999 1004 hdcTempImage, 0, 0, SRCAND); 1000 1005 1001 1006 /* fill */ … … 1011 1016 SelectObject (hdcImageList, himlLocal->hbmMask); 1012 1017 BitBlt (hdcTempImage, 0, 0, himlLocal->cx, 1013 himlLocal->cy, hdcImageList, 1018 himlLocal->cy, hdcImageList, 1014 1019 pimldp->i * himlLocal->cx, 0, SRCPAINT); 1015 1020 … … 1020 1025 DeleteDC (hdcTempImage); 1021 1026 } 1022 } 1027 } 1023 1028 1024 1029 /* Draw overlay image */ 1025 1030 if (pimldp->fStyle & 0x0700) { 1026 1027 1028 1029 1030 if (pimldp->himl->hbmMask) { 1031 nOvlIdx = (pimldp->fStyle & 0x0700) >> 8; 1032 if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) { 1033 nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1]; 1034 if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage)) { 1035 if (pimldp->himl->hbmMask) { 1031 1036 SelectObject (hdcImageList, pimldp->himl->hbmMask); 1032 1037 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 1033 1038 hdcImageList, pimldp->himl->cx * nOvlIdx, 0, 1034 1035 } 1039 SRCAND); 1040 } 1036 1041 SelectObject (hdcImageList, pimldp->himl->hbmImage); 1037 1042 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, … … 1043 1048 1044 1049 DeleteDC (hdcImageList); 1045 1050 1046 1051 return TRUE; 1047 1052 } … … 1151 1156 { 1152 1157 if (himl == NULL) 1153 1158 return CLR_NONE; 1154 1159 1155 1160 return himl->clrBk; … … 1187 1192 1188 1193 /************************************************************************* 1189 * ImageList_GetIcon [COMCTL32.57] 1194 * ImageList_GetIcon [COMCTL32.57] 1190 1195 * 1191 1196 * Creates an icon from a masked image of an image list. … … 1209 1214 1210 1215 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) 1211 1216 return 0; 1212 1217 1213 1218 hdcSrc = CreateCompatibleDC(0); … … 1222 1227 SelectObject (hdcDst, ii.hbmMask); 1223 1228 if (himl->hbmMask) { 1224 1225 1226 1229 SelectObject (hdcSrc, himl->hbmMask); 1230 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1231 hdcSrc, i * himl->cx, 0, SRCCOPY); 1227 1232 } 1228 1233 else 1229 1234 PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); 1230 1235 1231 1236 /* draw image*/ … … 1233 1238 SelectObject (hdcSrc, himl->hbmImage); 1234 1239 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1235 1236 1237 hIcon = CreateIconIndirect (&ii); 1240 hdcSrc, i * himl->cx, 0, SRCCOPY); 1241 1242 hIcon = CreateIconIndirect (&ii); 1238 1243 1239 1244 DeleteDC (hdcSrc); … … 1268 1273 { 1269 1274 if (himl == NULL) 1270 1275 return FALSE; 1271 1276 if ((himl->cx <= 0) || (himl->cy <= 0)) 1272 1277 return FALSE; 1273 1278 1274 1279 if (cx) 1275 1280 *cx = himl->cx; 1276 1281 if (cy) 1277 1282 *cy = himl->cy; 1278 1283 1279 1284 return TRUE; … … 1298 1303 { 1299 1304 if (himl == NULL) 1300 1305 return 0; 1301 1306 1302 1307 return himl->cCurImage; … … 1323 1328 { 1324 1329 if ((himl == NULL) || (pImageInfo == NULL)) 1325 1330 return FALSE; 1326 1331 if ((i < 0) || (i >= himl->cCurImage)) 1327 1332 return FALSE; 1328 1333 1329 1334 pImageInfo->hbmImage = himl->hbmImage; 1330 1335 pImageInfo->hbmMask = himl->hbmMask; 1331 1336 1332 1337 pImageInfo->rcImage.top = 0; 1333 1338 pImageInfo->rcImage.bottom = himl->cy; 1334 1339 pImageInfo->rcImage.left = i * himl->cx; 1335 1340 pImageInfo->rcImage.right = (i+1) * himl->cx; 1336 1341 1337 1342 return TRUE; 1338 1343 } … … 1340 1345 1341 1346 /************************************************************************* 1342 * ImageList_GetImageRect [COMCTL32.61] 1347 * ImageList_GetImageRect [COMCTL32.61] 1343 1348 * 1344 1349 * Retrieves the rectangle of the specified image in an image list. … … 1361 1366 { 1362 1367 if ((himl == NULL) || (lpRect == NULL)) 1363 1368 return FALSE; 1364 1369 if ((i < 0) || (i >= himl->cCurImage)) 1365 1370 return FALSE; 1366 1371 1367 1372 lpRect->left = i * himl->cx; … … 1397 1402 1398 1403 HIMAGELIST WINAPI 1399 ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, 1400 COLORREF clrMask, UINT uType,UINT uFlags)1404 ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow, 1405 COLORREF clrMask, UINT uType, UINT uFlags) 1401 1406 { 1402 1407 HIMAGELIST himl = NULL; … … 1413 1418 BITMAP bmp; 1414 1419 GetObjectA (handle, sizeof(BITMAP), &bmp); 1420 1421 /* To match windows behavior, if cx is set to zero and 1422 the flag DI_DEFAULTSIZE is specified, cx becomes the 1423 system metric value for icons. If the flag is not specified 1424 the function sets the size to the height of the bitmap */ 1425 if (cx == 0) 1426 { 1427 if (uFlags & DI_DEFAULTSIZE) 1428 cx = GetSystemMetrics (SM_CXICON); 1429 else 1430 cx = bmp.bmHeight; 1431 } 1432 1415 1433 nImageCount = bmp.bmWidth / cx; 1416 1434 … … 1425 1443 GetIconInfo (handle, &ii); 1426 1444 GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp); 1427 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1445 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1428 1446 ILC_MASK | ILC_COLOR, 1, cGrow); 1429 1447 ImageList_Add (himl, ii.hbmColor, ii.hbmMask); … … 1433 1451 1434 1452 DeleteObject (handle); 1435 1453 1436 1454 return himl; 1437 1455 } … … 1462 1480 HIMAGELIST WINAPI 1463 1481 ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow, 1464 COLORREF clrMask, UINT uType,UINT uFlags)1482 COLORREF clrMask, UINT uType, UINT uFlags) 1465 1483 { 1466 1484 HIMAGELIST himl = NULL; … … 1489 1507 GetIconInfo (handle, &ii); 1490 1508 GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); 1491 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1509 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1492 1510 ILC_MASK | ILC_COLOR, 1, cGrow); 1493 1511 ImageList_Add (himl, ii.hbmColor, ii.hbmMask); … … 1497 1515 1498 1516 DeleteObject (handle); 1499 1517 1500 1518 return himl; 1501 1519 } … … 1503 1521 1504 1522 /************************************************************************* 1505 * ImageList_Merge [COMCTL32.65] 1523 * ImageList_Merge [COMCTL32.65] 1506 1524 * 1507 1525 * Creates a new image list that contains a merged image from the specified … … 1523 1541 HIMAGELIST WINAPI 1524 1542 ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2, 1525 1543 INT dx, INT dy) 1526 1544 { 1527 1545 HIMAGELIST himlDst = NULL; … … 1532 1550 1533 1551 if ((himl1 == NULL) || (himl2 == NULL)) 1534 1552 return NULL; 1535 1553 1536 1554 /* check indices */ … … 1584 1602 nX1 = i1 * himl1->cx; 1585 1603 nX2 = i2 * himl2->cx; 1586 1604 1587 1605 /* copy image */ 1588 1606 SelectObject (hdcSrcImage, himl1->hbmImage); 1589 1607 SelectObject (hdcDstImage, himlDst->hbmImage); 1590 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1608 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1591 1609 hdcSrcImage, 0, 0, BLACKNESS); 1592 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1610 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1593 1611 hdcSrcImage, nX1, 0, SRCCOPY); 1594 1612 1595 1613 SelectObject (hdcSrcImage, himl2->hbmMask); 1596 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1614 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1597 1615 hdcSrcImage, nX2, 0, SRCAND); 1598 1616 1599 1617 SelectObject (hdcSrcImage, himl2->hbmImage); 1600 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1618 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1601 1619 hdcSrcImage, nX2, 0, SRCPAINT); 1602 1620 … … 1604 1622 SelectObject (hdcSrcImage, himl1->hbmMask); 1605 1623 SelectObject (hdcDstImage, himlDst->hbmMask); 1606 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1624 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1607 1625 hdcSrcImage, 0, 0, WHITENESS); 1608 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1626 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1609 1627 hdcSrcImage, nX1, 0, SRCCOPY); 1610 1628 1611 1629 SelectObject (hdcSrcImage, himl2->hbmMask); 1612 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1630 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1613 1631 hdcSrcImage, nX2, 0, SRCAND); 1614 1632 … … 1616 1634 DeleteDC (hdcDstImage); 1617 1635 } 1618 1636 1619 1637 return himlDst; 1620 1638 } … … 1711 1729 // TRACE(imagelist, " - Max. number of images: %d / %d (Old/New)\n", 1712 1730 // himl->cMaxImage, himl->cCurImage + himl->cGrow - 1); 1713 1731 1714 1732 hbmNewImage = 1715 1733 CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL); … … 1726 1744 if (i > 0) { 1727 1745 // TRACE (imagelist, "Pre image copy: Copy %d images\n", i); 1728 1746 1729 1747 SelectObject (hdcSrc, himl->hbmImage); 1730 1748 SelectObject (hdcDst, hbmNewImage); … … 1777 1795 1778 1796 /************************************************************************* 1779 * ImageList_Replace [COMCTL32.68] 1797 * ImageList_Replace [COMCTL32.68] 1780 1798 * 1781 1799 * Replaces an image in an image list with a new image. … … 1794 1812 BOOL WINAPI 1795 1813 ImageList_Replace (HIMAGELIST himl, INT i, HBITMAP hbmImage, 1796 1814 HBITMAP hbmMask) 1797 1815 { 1798 1816 HDC hdcImageList, hdcImage; … … 1803 1821 return FALSE; 1804 1822 } 1805 1823 1806 1824 if ((i >= himl->cCurImage) || (i < 0)) { 1807 1825 // ERR (imagelist, "Invalid image index!\n"); … … 1864 1882 1865 1883 if (himl == NULL) 1866 1884 return -1; 1867 1885 if ((i >= himl->cCurImage) || (i < -1)) 1868 1886 return -1; 1869 1887 1870 1888 GetIconInfo (hIcon, &ii); 1871 1889 // if (ii.hbmMask == 0) 1872 // 1890 // ERR (imagelist, "no mask!\n"); 1873 1891 // if (ii.hbmColor == 0) 1874 // 1892 // ERR (imagelist, "no color!\n"); 1875 1893 GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); 1876 1894 … … 1888 1906 // TRACE (imagelist, "hdcImageList=0x%x!\n", hdcImageList); 1889 1907 // if (hdcImageList == 0) 1890 // 1908 // ERR (imagelist, "invalid hdcImageList!\n"); 1891 1909 1892 1910 hdcImage = CreateCompatibleDC (0); 1893 1911 // TRACE (imagelist, "hdcImage=0x%x!\n", hdcImage); 1894 1912 // if (hdcImage == 0) 1895 // 1913 // ERR (imagelist, "invalid hdcImage!\n"); 1896 1914 1897 1915 hbmOldDst = SelectObject (hdcImageList, himl->hbmImage); … … 1913 1931 1914 1932 if (hdcImageList) 1915 1933 DeleteDC (hdcImageList); 1916 1934 if (hdcImage) 1917 1935 DeleteDC (hdcImage); 1918 1936 if (ii.hbmColor) 1919 1937 DeleteObject (ii.hbmColor); 1920 1938 if (ii.hbmMask) 1921 1939 DeleteObject (ii.hbmMask); 1922 1940 1923 1941 return nIndex; … … 1926 1944 1927 1945 /************************************************************************* 1928 * ImageList_SetBkColor [COMCTL32.70] 1946 * ImageList_SetBkColor [COMCTL32.70] 1929 1947 * 1930 1948 * Sets the background color of an image list. … … 1945 1963 1946 1964 if (himl == NULL) 1947 1965 return CLR_NONE; 1948 1966 1949 1967 clrOldBk = himl->clrBk; … … 1974 1992 BOOL WINAPI 1975 1993 ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag, 1976 1994 INT dxHotspot, INT dyHotspot) 1977 1995 { 1978 1996 HIMAGELIST himlTemp; … … 1981 1999 1982 2000 if (himlInternalDrag == NULL) 1983 2001 return FALSE; 1984 2002 1985 2003 // TRACE (imagelist, " dxH=%d dyH=%d nX=%d nY=%d\n", 1986 // 2004 // dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY); 1987 2005 1988 2006 himlTemp = ImageList_Merge (himlInternalDrag, 0, himlDrag, iDrag, 1989 2007 dxHotspot, dyHotspot); 1990 2008 1991 2009 ImageList_Destroy (himlInternalDrag); … … 2000 2018 2001 2019 /************************************************************************* 2002 * ImageList_SetFilter [COMCTL32.76] 2020 * ImageList_SetFilter [COMCTL32.76] 2003 2021 * 2004 2022 * Sets a filter (or does something completely different)!!??? … … 2022 2040 { 2023 2041 // FIXME (imagelist, "(%p 0x%x 0x%lx):empty stub!\n", 2024 // 2042 // himl, i, dwFilter); 2025 2043 2026 2044 return FALSE; … … 2049 2067 2050 2068 if (!himl) 2051 2069 return FALSE; 2052 2070 2053 2071 /* remove all images*/ … … 2099 2117 2100 2118 if (!himl) 2101 2119 return FALSE; 2102 2120 if (himl->cCurImage >= iImageCount) 2103 2121 return FALSE; 2104 2122 if (himl->cMaxImage > iImageCount) 2105 2123 return TRUE; 2106 2124 2107 2125 nNewCount = iImageCount + himl->cGrow; … … 2118 2136 SelectObject (hdcBitmap, hbmNewBitmap); 2119 2137 2120 2138 /* copy images */ 2121 2139 BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy, 2122 2140 hdcImageList, 0, 0, SRCCOPY); 2123 2141 2124 2125 2126 2127 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2128 2129 2130 2131 2142 /* delete 'empty' image space */ 2143 SetBkColor (hdcBitmap, RGB(255, 255, 255)); 2144 SetTextColor (hdcBitmap, RGB(0, 0, 0)); 2145 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2146 (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS); 2147 2148 DeleteObject (himl->hbmImage); 2149 himl->hbmImage = hbmNewBitmap; 2132 2150 } 2133 2151 // else 2134 // 2152 // ERR (imagelist, "Could not create new image bitmap !\n"); 2135 2153 2136 2154 if (himl->hbmMask) … … 2143 2161 SelectObject (hdcBitmap, hbmNewBitmap); 2144 2162 2145 2163 /* copy images */ 2146 2164 BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy, 2147 2165 hdcImageList, 0, 0, SRCCOPY); 2148 2166 2149 2150 2151 2152 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2153 2167 /* delete 'empty' image space */ 2168 SetBkColor (hdcBitmap, RGB(255, 255, 255)); 2169 SetTextColor (hdcBitmap, RGB(0, 0, 0)); 2170 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2171 (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS); 2154 2172 2155 2173 DeleteObject (himl->hbmMask); … … 2191 2209 { 2192 2210 if (!himl) 2193 2211 return FALSE; 2194 2212 if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE)) 2195 2213 return FALSE; 2196 2214 if ((iImage < 0) || (iImage > himl->cCurImage)) 2197 2198 2215 return FALSE; 2216 2199 2217 himl->nOvlIdx[iOverlay - 1] = iImage; 2200 2218 return TRUE; … … 2227 2245 //{ 2228 2246 // if (!himl) 2229 // 2247 // return FALSE; 2230 2248 // 2231 2249 // FIXME (imagelist, "empty stub!\n"); -
trunk/src/comctl32/ipaddress.c
r190 r295 1 /* $Id: ipaddress.c,v 1. 5 1999-06-25 15:49:01 achimhaExp $ */1 /* $Id: ipaddress.c,v 1.6 1999-07-12 15:58:47 cbratschi Exp $ */ 2 2 /* 3 3 * IP Address control 4 4 * 5 * Copyright 1999 Chris Morgan<cmorgan@wpi.edu> and 6 * James Abbatiello<abbeyj@wpi.edu> 5 7 * Copyright 1998, 1999 Eric Kohl 6 8 * Copyright 1998 Alex Priem <alexp@sci.kun.nl> … … 8 10 * 9 11 * NOTES 10 11 12 * 12 13 * TODO: 13 14 * -Check ranges when changing field-focus. 14 * 15 * -Check all notifications/behavior. 15 16 * -Optimization: include lpipsi in IPADDRESS_INFO. 16 * 17 * 18 * 19 * 20 * 17 * -CurrentFocus: field that has focus at moment of processing. 18 * -connect Rect32 rcClient. 19 * -handle right and left arrows correctly. Boring. 20 * -split GotoNextField in CheckField and GotoNextField. 21 * -check ipaddress.cpp for missing features. 21 22 * -refresh: draw '.' instead of setpixel. 22 * 23 * -handle VK_ESCAPE. 23 24 */ 24 25 … … 36 37 37 38 38 static BOOL 39 static BOOL 39 40 IPADDRESS_SendNotify (HWND hwnd, UINT command); 40 static BOOL 41 static BOOL 41 42 IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue); 42 43 … … 55 56 IPADDRESS_Refresh (HWND hwnd, HDC hdc) 56 57 { 57 58 59 58 RECT rcClient; 59 HBRUSH hbr; 60 COLORREF clr=GetSysColor (COLOR_3DDKSHADOW); 60 61 int i,x,fieldsize; 61 62 62 63 GetClientRect (hwnd, &rcClient); 63 64 hbr = CreateSolidBrush (RGB(255,255,255)); 64 65 DrawEdge (hdc, &rcClient, EDGE_SUNKEN, BF_RECT | BF_ADJUST); 65 66 FillRect (hdc, &rcClient, hbr); 66 67 DeleteObject (hbr); 67 68 68 x=rcClient.left; 69 fieldsize=(rcClient.right-rcClient.left) /4; 70 71 for (i=0; i<3; i++) { /* Should draw text "." here */ 72 x+=fieldsize; 73 SetPixel (hdc, x, 13, clr); 74 SetPixel (hdc, x, 14, clr); 75 SetPixel (hdc, x+1, 13, clr); 76 SetPixel (hdc, x+1, 14, clr); 77 78 } 79 80 } 81 82 83 69 x=rcClient.left; 70 fieldsize=(rcClient.right-rcClient.left) /4; 71 72 for (i=0; i<3; i++) { /* Should draw text "." here */ 73 x+=fieldsize; 74 SetPixel (hdc, x, 13, clr); 75 SetPixel (hdc, x, 14, clr); 76 SetPixel (hdc, x+1, 13, clr); 77 SetPixel (hdc, x+1, 14, clr); 78 } 79 } 84 80 85 81 … … 88 84 { 89 85 IPADDRESS_INFO *infoPtr; 90 91 92 93 86 RECT rcClient, edit; 87 int i,fieldsize; 88 LPIP_SUBCLASS_INFO lpipsi; 89 94 90 95 91 infoPtr = (IPADDRESS_INFO *)COMCTL32_Alloc (sizeof(IPADDRESS_INFO)); … … 98 94 GetClientRect (hwnd, &rcClient); 99 95 100 fieldsize=(rcClient.right-rcClient.left) /4; 101 102 edit.top =rcClient.top+2; 103 edit.bottom=rcClient.bottom-2; 104 105 lpipsi=(LPIP_SUBCLASS_INFO) 106 GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 107 if (lpipsi == NULL) { 108 lpipsi= (LPIP_SUBCLASS_INFO) COMCTL32_Alloc (sizeof(IP_SUBCLASS_INFO)); 109 lpipsi->hwnd = hwnd; 110 lpipsi->uRefCount++; 111 SetPropA ((HWND)hwnd, IP_SUBCLASS_PROP, 112 (HANDLE)lpipsi); 113 /* infoPtr->lpipsi= lpipsi; */ 114 // } else 115 } 116 // WARN (ipaddress,"IP-create called twice\n"); 117 118 for (i=0; i<=3; i++) { 119 infoPtr->LowerLimit[i]=0; 120 infoPtr->UpperLimit[i]=255; 121 edit.left=rcClient.left+i*fieldsize+3; 122 edit.right=rcClient.left+(i+1)*fieldsize-2; 123 lpipsi->hwndIP[i]= CreateWindowA ("edit", NULL, 124 WS_CHILD | WS_VISIBLE | ES_LEFT, 125 edit.left, edit.top, edit.right-edit.left, edit.bottom-edit.top, 126 hwnd, (HMENU) 1, GetWindowLongA (hwnd, GWL_HINSTANCE), NULL); 127 lpipsi->wpOrigProc[i]= (WNDPROC) 128 SetWindowLongA (lpipsi->hwndIP[i],GWL_WNDPROC, (LONG) 129 IPADDRESS_SubclassProc); 130 SetPropA ((HWND)lpipsi->hwndIP[i], IP_SUBCLASS_PROP, 131 (HANDLE)lpipsi); 132 } 133 134 lpipsi->infoPtr= infoPtr; 96 fieldsize=(rcClient.right-rcClient.left) /4; 97 98 edit.top =rcClient.top+2; 99 edit.bottom=rcClient.bottom-2; 100 101 lpipsi=(LPIP_SUBCLASS_INFO) GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 102 if (lpipsi == NULL) { 103 lpipsi= (LPIP_SUBCLASS_INFO) COMCTL32_Alloc (sizeof(IP_SUBCLASS_INFO)); 104 lpipsi->hwnd = hwnd; 105 lpipsi->uRefCount++; 106 SetPropA ((HWND)hwnd, IP_SUBCLASS_PROP, (HANDLE)lpipsi); 107 /* infoPtr->lpipsi= lpipsi; */ 108 // } else 109 } 110 // WARN (ipaddress,"IP-create called twice\n"); 111 112 for (i=0; i<=3; i++) 113 { 114 infoPtr->LowerLimit[i]=0; 115 infoPtr->UpperLimit[i]=255; 116 edit.left=rcClient.left+i*fieldsize+6; 117 edit.right=rcClient.left+(i+1)*fieldsize-2; 118 lpipsi->hwndIP[i]= CreateWindowA ("edit", NULL, 119 WS_CHILD | WS_VISIBLE | ES_CENTER, 120 edit.left, edit.top, edit.right-edit.left, edit.bottom-edit.top, 121 hwnd, (HMENU) 1, GetWindowLongA (hwnd, GWL_HINSTANCE), NULL); 122 lpipsi->wpOrigProc[i]= (WNDPROC) 123 SetWindowLongA (lpipsi->hwndIP[i],GWL_WNDPROC, (LONG) 124 IPADDRESS_SubclassProc); 125 SetPropA ((HWND)lpipsi->hwndIP[i], IP_SUBCLASS_PROP, (HANDLE)lpipsi); 126 } 127 128 lpipsi->infoPtr= infoPtr; 135 129 136 130 return 0; … … 141 135 IPADDRESS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) 142 136 { 143 137 int i; 144 138 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); 145 139 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 146 140 GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 147 141 148 149 142 for (i=0; i<=3; i++) { 143 SetWindowLongA ((HWND)lpipsi->hwndIP[i], GWL_WNDPROC, 150 144 (LONG)lpipsi->wpOrigProc[i]); 151 145 } 152 146 153 147 COMCTL32_Free (infoPtr); … … 161 155 HDC hdc; 162 156 163 // 157 // TRACE (ipaddress,"\n"); 164 158 hdc = GetDC (hwnd); 165 159 IPADDRESS_Refresh (hwnd, hdc); … … 167 161 168 162 IPADDRESS_SendIPAddressNotify (hwnd, 0, 0); /* FIXME: should use -1 */ 169 IPADDRESS_SendNotify (hwnd, EN_KILLFOCUS); 163 IPADDRESS_SendNotify (hwnd, EN_KILLFOCUS); 170 164 InvalidateRect (hwnd, NULL, TRUE); 171 165 … … 183 177 IPADDRESS_Refresh (hwnd, hdc); 184 178 if(!wParam) 185 179 EndPaint (hwnd, &ps); 186 180 return 0; 187 181 } … … 193 187 HDC hdc; 194 188 195 // 189 // TRACE (ipaddress,"\n"); 196 190 197 191 hdc = GetDC (hwnd); … … 207 201 { 208 202 /* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */ 209 // 203 // TRACE (ipaddress,"\n"); 210 204 return 0; 211 205 } … … 225 219 IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue) 226 220 { 227 221 NMIPADDRESS nmip; 228 222 229 223 // TRACE (ipaddress, "%x %x\n",field,newValue); … … 232 226 nmip.hdr.code = IPN_FIELDCHANGED; 233 227 234 235 228 nmip.iField=field; 229 nmip.iValue=newValue; 236 230 237 231 return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY, … … 245 239 IPADDRESS_ClearAddress (HWND hwnd, WPARAM wParam, LPARAM lParam) 246 240 { 247 248 249 250 241 int i; 242 HDC hdc; 243 char buf[1]; 244 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 251 245 GetPropA ((HWND)hwnd,IP_SUBCLASS_PROP); 252 246 253 // 254 255 256 for (i=0; i<=3; i++) 257 258 247 // TRACE (ipaddress,"\n"); 248 249 buf[0]=0; 250 for (i=0; i<=3; i++) 251 SetWindowTextA (lpipsi->hwndIP[i],buf); 252 259 253 hdc = GetDC (hwnd); 260 254 IPADDRESS_Refresh (hwnd, hdc); 261 255 ReleaseDC (hwnd, hdc); 262 263 256 257 return 0; 264 258 } 265 259 … … 275 269 276 270 for (i=0; i<=3; i++) { 277 278 279 280 271 GetWindowTextA (lpipsi->hwndIP[i],buf,5); 272 if (buf[0]) 273 return 0; 274 } 281 275 282 276 return 1; … … 298 292 ip_addr=0; 299 293 for (i=0; i<=3; i++) { 300 301 302 303 304 305 if (fieldvalue<infoPtr->LowerLimit[i]) 306 307 if (fieldvalue>infoPtr->UpperLimit[i]) 308 309 310 311 294 GetWindowTextA (lpipsi->hwndIP[i],field,4); 295 ip_addr*=256; 296 if (field[0]) { 297 field[3]=0; 298 fieldvalue=atoi(field); 299 if (fieldvalue<infoPtr->LowerLimit[i]) 300 fieldvalue=infoPtr->LowerLimit[i]; 301 if (fieldvalue>infoPtr->UpperLimit[i]) 302 fieldvalue=infoPtr->UpperLimit[i]; 303 ip_addr+=fieldvalue; 304 valid++; 305 } 312 306 } 313 307 … … 322 316 { 323 317 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); 324 325 326 // 327 328 329 330 331 332 333 318 INT index; 319 320 // TRACE (ipaddress,"\n"); 321 322 index=(INT) wParam; 323 if ((index<0) || (index>3)) return 0; 324 325 infoPtr->LowerLimit[index]=lParam & 0xff; 326 infoPtr->UpperLimit[index]=(lParam >>8) & 0xff; 327 return 1; 334 328 } 335 329 … … 338 332 { 339 333 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); 340 341 334 HDC hdc; 335 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 342 336 GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 343 337 int i,ip_address,value; 344 338 char buf[20]; 345 339 346 // 347 348 349 350 351 if ((value>=infoPtr->LowerLimit[i]) && (value<=infoPtr->UpperLimit[i])) 352 353 354 355 356 357 358 359 360 hdc = GetDC (hwnd); 340 // TRACE (ipaddress,"\n"); 341 ip_address=(DWORD) lParam; 342 343 for (i=3; i>=0; i--) { 344 value=ip_address & 0xff; 345 if ((value>=infoPtr->LowerLimit[i]) && (value<=infoPtr->UpperLimit[i])) 346 { 347 sprintf (buf,"%d",value); 348 SetWindowTextA (lpipsi->hwndIP[i],buf); 349 IPADDRESS_SendNotify (hwnd, EN_CHANGE); 350 } 351 ip_address/=256; 352 } 353 354 hdc = GetDC (hwnd); /* & send notifications */ 361 355 IPADDRESS_Refresh (hwnd, hdc); 362 356 ReleaseDC (hwnd, hdc); … … 372 366 { 373 367 /* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */ 374 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 375 GetPropA ((HWND)hwnd,IP_SUBCLASS_PROP);376 377 378 379 // 380 381 382 383 368 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) GetPropA ((HWND)hwnd, 369 IP_SUBCLASS_PROP); 370 INT index; 371 372 index=(INT) wParam; 373 // TRACE (ipaddress," %d\n", index); 374 if ((index<0) || (index>3)) return 0; 375 376 SetFocus (lpipsi->hwndIP[index]); 377 384 378 return 1; 385 379 } … … 391 385 // TRACE (ipaddress, "\n"); 392 386 393 SetFocus (hwnd); 394 IPADDRESS_SendNotify (hwnd, EN_SETFOCUS); 395 IPADDRESS_SetFocusToField (hwnd, 0, 0); 396 397 return TRUE; 398 } 399 400 401 402 /* tab/shift-tab: IPN_FIELDCHANGED, lose focus. 403 dot, space,right arrow: set focus to next child edit. 404 numerics (0..9), control characters: forward to default edit control 405 other characters: dropped 406 */ 407 408 409 410 411 static int 387 SetFocus (hwnd); 388 IPADDRESS_SendNotify (hwnd, EN_SETFOCUS); 389 IPADDRESS_SetFocusToField (hwnd, 0, 0); 390 391 return TRUE; 392 } 393 394 static INT 395 IPADDRESS_CheckField (LPIP_SUBCLASS_INFO lpipsi, int currentfield) 396 { 397 int newField,fieldvalue; 398 char field[20]; 399 IPADDRESS_INFO *infoPtr=lpipsi->infoPtr; 400 401 if(currentfield >= 0 && currentfield < 4) 402 { 403 // TRACE("\n"); 404 GetWindowTextA (lpipsi->hwndIP[currentfield],field,4); 405 if (field[0]) 406 { 407 field[3]=0; 408 newField=-1; 409 fieldvalue=atoi(field); 410 411 if (fieldvalue < infoPtr->LowerLimit[currentfield]) 412 newField=infoPtr->LowerLimit[currentfield]; 413 414 if (fieldvalue > infoPtr->UpperLimit[currentfield]) 415 newField=infoPtr->UpperLimit[currentfield]; 416 417 if (newField >= 0) 418 { 419 sprintf (field,"%d",newField); 420 SetWindowTextA (lpipsi->hwndIP[currentfield], field); 421 return TRUE; 422 } 423 } 424 } 425 return FALSE; 426 } 427 428 429 static INT 412 430 IPADDRESS_GotoNextField (LPIP_SUBCLASS_INFO lpipsi, int currentfield) 413 431 { 414 int newField,fieldvalue; 415 char field[20]; 416 IPADDRESS_INFO *infoPtr=lpipsi->infoPtr; 417 418 // TRACE (ipaddress,"\n"); 419 GetWindowTextA (lpipsi->hwndIP[currentfield],field,4); 420 if (field[0]) { 421 field[3]=0; 422 newField=-1; 423 fieldvalue=atoi(field); 424 if (fieldvalue<infoPtr->LowerLimit[currentfield]) 425 newField=infoPtr->LowerLimit[currentfield]; 426 if (fieldvalue>infoPtr->UpperLimit[currentfield]) 427 newField=infoPtr->UpperLimit[currentfield]; 428 if (newField>=0) { 429 sprintf (field,"%d",newField); 430 SetWindowTextA (lpipsi->hwndIP[currentfield], field); 431 return 1; 432 } 433 } 434 435 if (currentfield<3) 436 SetFocus (lpipsi->hwndIP[currentfield+1]); 437 return 0; 438 } 432 if(currentfield >= -1 && currentfield < 4) 433 { 434 IPADDRESS_CheckField(lpipsi, currentfield); /* check the fields value */ 435 436 if(currentfield < 3) 437 { 438 SetFocus (lpipsi->hwndIP[currentfield+1]); 439 return TRUE; 440 } 441 } 442 return FALSE; 443 } 444 445 446 /* period: move and select the text in the next field to the right if */ 447 /* the current field is not empty(l!=0), we are not in the */ 448 /* left most position, and nothing is selected(startsel==endsel) */ 449 450 /* spacebar: same behavior as period */ 451 452 /* alpha characters: completely ignored */ 453 454 /* digits: accepted when field text length < 2 ignored otherwise. */ 455 /* when 3 numbers have been entered into the field the value */ 456 /* of the field is checked, if the field value exceeds the */ 457 /* maximum value and is changed the field remains the current */ 458 /* field, otherwise focus moves to the field to the right */ 459 460 /* tab: change focus from the current ipaddress control to the next */ 461 /* control in the tab order */ 462 463 /* right arrow: move to the field on the right to the left most */ 464 /* position in that field if no text is selected, */ 465 /* we are in the right most position in the field, */ 466 /* we are not in the right most field */ 467 468 /* left arrow: move to the field on the left to the right most */ 469 /* position in that field if no text is selected, */ 470 /* we are in the left most position in the current field */ 471 /* and we are not in the left most field */ 472 473 /* backspace: delete the character to the left of the cursor position, */ 474 /* if none are present move to the field on the left if */ 475 /* we are not in the left most field and delete the right */ 476 /* most digit in that field while keeping the cursor */ 477 /* on the right side of the field */ 478 439 479 440 480 … … 442 482 IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 443 483 { 444 int i,l,index; 445 IPADDRESS_INFO *infoPtr; 446 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 447 GetPropA ((HWND)hwnd,IP_SUBCLASS_PROP); 448 449 infoPtr = lpipsi->infoPtr; 450 index=0; /* FIXME */ 451 for (i=0; i<=3; i++) 452 if (lpipsi->hwndIP[i]==hwnd) index=i; 453 454 switch (uMsg) { 455 case WM_CHAR: break; 456 case WM_KEYDOWN: { 457 char c=(char) wParam; 458 if (c==VK_TAB) { 459 HWND pwnd; 460 int shift; 461 shift = GetKeyState(VK_SHIFT) & 0x8000; 462 if (shift) 463 pwnd=GetNextDlgTabItem (GetParent (hwnd), 0, TRUE); 464 else 465 pwnd=GetNextDlgTabItem (GetParent (hwnd), 0, FALSE); 466 if (pwnd) SetFocus (pwnd); 467 break; 468 } 469 470 if ((c==' ') || (c=='.') || (c==VK_RIGHT)) { 471 IPADDRESS_GotoNextField (lpipsi,index); 472 wParam=0; 473 lParam=0; 474 break; 475 } 476 if (c==VK_LEFT) { 477 478 } 479 if (c==VK_RETURN) { 480 } 481 if (((c>='0') && (c<='9')) || (iscntrl(c))) { 482 l=GetWindowTextLengthA (lpipsi->hwndIP[index]); 483 if (l==3) 484 if (IPADDRESS_GotoNextField (lpipsi,index)) { 485 wParam=0; 486 lParam=0; 487 } 488 break; 489 } 490 491 wParam=0; 492 lParam=0; 493 break; 494 } 495 } 496 497 return CallWindowProcA (lpipsi->wpOrigProc[index], hwnd, uMsg, wParam, lParam); 484 IPADDRESS_INFO *infoPtr; 485 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) GetPropA ((HWND)hwnd,IP_SUBCLASS_PROP); 486 CHAR c = (CHAR)wParam; 487 INT i, l, index, startsel, endsel; 488 489 infoPtr = lpipsi->infoPtr; 490 index=0; /* FIXME */ 491 for (i=0; i<=3; i++) 492 if (lpipsi->hwndIP[i]==hwnd) index=i; 493 494 switch (uMsg) { 495 case WM_CHAR: 496 if(isdigit(c)) /* process all digits */ 497 { 498 int return_val; 499 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 500 l = GetWindowTextLengthA (lpipsi->hwndIP[index]); 501 if(l==2 && startsel==endsel) /* field is full after this key is processed */ 502 { 503 /* process the digit press before we check the field */ 504 return_val = CallWindowProcA (lpipsi->wpOrigProc[index], hwnd, uMsg, wParam, lParam); 505 506 /* if the field value was changed stay at the current field */ 507 if(!IPADDRESS_CheckField(lpipsi, index)) 508 IPADDRESS_GotoNextField (lpipsi,index); 509 510 return return_val; 511 } 512 513 if(l > 2) /* field is full, stop key messages */ 514 { 515 lParam = 0; 516 wParam = 0; 517 } 518 break; 519 } 520 521 if(c == '.') /* VK_PERIOD */ 522 { 523 l = GetWindowTextLengthA(lpipsi->hwndIP[index]); 524 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 525 if(l != 0 && startsel==endsel && startsel != 0) 526 { 527 IPADDRESS_GotoNextField(lpipsi, index); 528 SendMessageA(lpipsi->hwndIP[index+1], EM_SETSEL, (WPARAM)0, (LPARAM)3); 529 } 530 } 531 532 /* stop all other characters */ 533 wParam = 0; 534 lParam = 0; 535 break; 536 537 case WM_KEYDOWN: 538 if(c == VK_SPACE) 539 { 540 l = GetWindowTextLengthA(lpipsi->hwndIP[index]); 541 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 542 if(l != 0 && startsel==endsel && startsel != 0) 543 { 544 IPADDRESS_GotoNextField(lpipsi, index); 545 SendMessageA(lpipsi->hwndIP[index+1], EM_SETSEL, (WPARAM)0, (LPARAM)3); 546 } 547 } 548 549 if(c == VK_RIGHT) 550 { 551 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 552 l = GetWindowTextLengthA (lpipsi->hwndIP[index]); 553 554 if(startsel==endsel && startsel==l) 555 { 556 IPADDRESS_GotoNextField(lpipsi, index); 557 SendMessageA(lpipsi->hwndIP[index+1], EM_SETSEL, (WPARAM)0,(LPARAM)0); 558 } 559 } 560 561 if(c == VK_LEFT) 562 { 563 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 564 if(startsel==0 && startsel==endsel && index > 0) 565 { 566 IPADDRESS_GotoNextField(lpipsi, index - 2); 567 l = GetWindowTextLengthA(lpipsi->hwndIP[index-1]); 568 SendMessageA(lpipsi->hwndIP[index-1], EM_SETSEL, (WPARAM)l,(LPARAM)l); 569 } 570 } 571 572 if(c == VK_BACK) /* VK_BACKSPACE */ 573 { 574 CHAR buf[4]; 575 576 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 577 l = GetWindowTextLengthA (lpipsi->hwndIP[index]); 578 if(startsel==endsel && startsel==0 && index > 0) 579 { 580 l = GetWindowTextLengthA(lpipsi->hwndIP[index-1]); 581 if(l!=0) 582 { 583 GetWindowTextA (lpipsi->hwndIP[index-1],buf,4); 584 buf[l-1] = '\0'; 585 SetWindowTextA(lpipsi->hwndIP[index-1], buf); 586 SendMessageA(lpipsi->hwndIP[index-1], EM_SETSEL, (WPARAM)l,(LPARAM)l); 587 } 588 IPADDRESS_GotoNextField(lpipsi, index - 2); 589 } 590 } 591 break; 592 593 default: 594 break; 595 } 596 return CallWindowProcA (lpipsi->wpOrigProc[index], hwnd, uMsg, wParam, lParam); 498 597 } 499 598 … … 503 602 switch (uMsg) 504 603 { 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 604 case IPM_CLEARADDRESS: 605 return IPADDRESS_ClearAddress (hwnd, wParam, lParam); 606 607 case IPM_SETADDRESS: 608 return IPADDRESS_SetAddress (hwnd, wParam, lParam); 609 610 case IPM_GETADDRESS: 611 return IPADDRESS_GetAddress (hwnd, wParam, lParam); 612 613 case IPM_SETRANGE: 614 return IPADDRESS_SetRange (hwnd, wParam, lParam); 615 616 case IPM_SETFOCUS: 617 return IPADDRESS_SetFocusToField (hwnd, wParam, lParam); 618 619 case IPM_ISBLANK: 620 return IPADDRESS_IsBlank (hwnd, wParam, lParam); 621 622 case WM_CREATE: 623 return IPADDRESS_Create (hwnd, wParam, lParam); 624 625 case WM_DESTROY: 626 return IPADDRESS_Destroy (hwnd, wParam, lParam); 627 628 case WM_GETDLGCODE: 629 return DLGC_WANTARROWS | DLGC_WANTCHARS; 630 631 case WM_KILLFOCUS: 632 return IPADDRESS_KillFocus (hwnd, wParam, lParam); 633 634 case WM_LBUTTONDOWN: 536 635 return IPADDRESS_LButtonDown (hwnd, wParam, lParam); 537 636 538 539 540 541 542 543 544 545 546 547 548 // 549 // 550 // 551 637 case WM_PAINT: 638 return IPADDRESS_Paint (hwnd, wParam); 639 640 case WM_SETFOCUS: 641 return IPADDRESS_SetFocus (hwnd, wParam, lParam); 642 643 case WM_SIZE: 644 return IPADDRESS_Size (hwnd, wParam, lParam); 645 646 default: 647 // if (uMsg >= WM_USER) 648 // ERR (ipaddress, "unknown msg %04x wp=%08x lp=%08lx\n", 649 // uMsg, wParam, lParam); 650 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 552 651 } 553 652 return 0; … … 570 669 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 571 670 wndClass.lpszClassName = WC_IPADDRESSA; 572 671 573 672 RegisterClassA (&wndClass); 574 673 } -
trunk/src/comctl32/listview.c
r252 r295 3392 3392 if (dispInfo.item.mask & LVIF_DI_SETITEM) 3393 3393 { 3394 Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText); 3394 if (lpSubItem) 3395 Str_SetPtrA(&lpSubItem->pszText, dispInfo.item.pszText); 3395 3396 } 3396 3397 lpLVItem->pszText = dispInfo.item.pszText; … … 3398 3399 else if (lpLVItem->mask & LVIF_TEXT) 3399 3400 { 3400 lpLVItem->pszText = lp Item->pszText;3401 lpLVItem->pszText = lpSubItem->pszText; 3401 3402 } 3402 3403 } … … 3989 3990 lvFindInfo.vkDirection = VK_UP; 3990 3991 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 3991 while ((nItem = L ISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1)3992 while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1) 3992 3993 { 3993 3994 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) … … 4012 4013 lvFindInfo.vkDirection = VK_DOWN; 4013 4014 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 4014 while ((nItem = L ISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1)4015 while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1) 4015 4016 { 4016 4017 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) … … 4036 4037 lvFindInfo.vkDirection = VK_LEFT; 4037 4038 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 4038 while ((nItem = L ISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1)4039 while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1) 4039 4040 { 4040 4041 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) … … 4060 4061 lvFindInfo.vkDirection = VK_RIGHT; 4061 4062 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 4062 while ((nItem = L ISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1)4063 while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1) 4063 4064 { 4064 4065 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) … … 4667 4668 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 4668 4669 BOOL bResult = FALSE; 4669 HDITEMA hdi ;4670 HDITEMA hdi, hdiget; 4670 4671 4671 4672 if ((lpColumn != NULL) && (nColumn >= 0) && … … 4679 4680 /* format member is valid */ 4680 4681 hdi.mask |= HDI_FORMAT; 4682 4683 /* get current format first */ 4684 hdiget.mask = HDI_FORMAT; 4685 if (Header_GetItemA(infoPtr->hwndHeader, nColumn, &hdiget)) 4686 /* preserve HDF_STRING if present */ 4687 hdi.fmt = hdiget.fmt & HDF_STRING; 4681 4688 4682 4689 /* set text alignment (leftmost column must be left-aligned) */ … … 5244 5251 5245 5252 /* create header */ 5246 5247 5253 infoPtr->hwndHeader = CreateWindowA(WC_HEADERA, (LPCSTR)NULL, 5248 5254 WS_CHILD | HDS_HORZ | HDS_BUTTONS, … … 5623 5629 5624 5630 case VK_LEFT: 5625 nItem = L ISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TOLEFT);5631 nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TOLEFT); 5626 5632 break; 5627 5633 5628 5634 case VK_UP: 5629 nItem = L ISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_ABOVE);5635 nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_ABOVE); 5630 5636 break; 5631 5637 5632 5638 case VK_RIGHT: 5633 nItem = L ISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TORIGHT);5639 nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TORIGHT); 5634 5640 break; 5635 5641 5636 5642 case VK_DOWN: 5637 nItem = L ISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_BELOW);5643 nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_BELOW); 5638 5644 break; 5639 5645 -
trunk/src/comctl32/propsheet.c
r267 r295 1 /* $Id: propsheet.c,v 1. 5 1999-07-04 21:05:59cbratschi Exp $ */1 /* $Id: propsheet.c,v 1.6 1999-07-12 15:58:48 cbratschi Exp $ */ 2 2 /* 3 3 * Property Sheets … … 791 791 PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, 792 792 PropSheetInfoStr); 793 793 if (!psInfo) return; 794 794 /* 795 795 * Set the dirty flag of this page. -
trunk/src/comctl32/rebar.c
r252 r295 1 /* $Id: rebar.c,v 1. 6 1999-06-30 15:52:17cbratschi Exp $ */1 /* $Id: rebar.c,v 1.7 1999-07-12 15:58:48 cbratschi Exp $ */ 2 2 /* 3 3 * Rebar control … … 431 431 #if 0 432 432 else if (!lstrcmpA (szClassName, WC_COMBOBOXEXA)) { 433 INT nEditHeight, yPos; 434 RECT rc; 435 HWND hwndEdit; 436 433 437 /* special placement code for extended combo box */ 434 438 439 /* get size of edit line */ 440 hwndEdit = SendMessageA (lpBand->hwndChild, CBEM_GETEDITCONTROL, 0, 0); 441 GetWindowRect (hwndEdit, &rc); 442 nEditHeight = rc.bottom - rc.top; 443 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2; 444 445 /* center combo box inside child area */ 446 SetWindowPos (lpBand->hwndChild, HWND_TOP, 447 lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos, 448 lpBand->rcChild.right - lpBand->rcChild.left, 449 nEditHeight, 450 SWP_SHOWWINDOW); 435 451 436 452 } -
trunk/src/comctl32/status.c
r267 r295 1 /* $Id: status.c,v 1. 8 1999-07-04 21:05:59cbratschi Exp $ */1 /* $Id: status.c,v 1.9 1999-07-12 15:58:48 cbratschi Exp $ */ 2 2 /* 3 3 * Interface code to StatusWindow widget/control … … 665 665 if (style & SBT_OWNERDRAW) 666 666 { 667 if (!(part->style & SBT_OWNERDRAW) && part->text) COMCTL32_Free(part->text); 667 668 part->text = (LPWSTR)text; 668 669 } else … … 720 721 if (style & SBT_OWNERDRAW) 721 722 { 723 if (!(part->style & SBT_OWNERDRAW) && part->text) COMCTL32_Free(part->text); 722 724 part->text = text; 723 725 } else 724 726 { 727 //compare 725 728 if (lstrcmpW(part->text,text) == 0) 726 729 { -
trunk/src/comctl32/tab.c
r267 r295 1 /* $Id: tab.c,v 1. 8 1999-07-04 21:05:59cbratschi Exp $ */1 /* $Id: tab.c,v 1.9 1999-07-12 15:58:48 cbratschi Exp $ */ 2 2 /* 3 3 * Tab control … … 398 398 pt.y = (INT)HIWORD(lParam); 399 399 400 newItem=TAB_InternalHitTest (hwnd, infoPtr,pt, (unsigned int*)&dummy);400 newItem=TAB_InternalHitTest (hwnd, infoPtr,pt,&dummy); 401 401 402 402 // TRACE(tab, "On Tab, item %d\n", newItem); -
trunk/src/comctl32/toolbar.c
r285 r295 1 /* $Id: toolbar.c,v 1.1 0 1999-07-07 17:08:42cbratschi Exp $ */1 /* $Id: toolbar.c,v 1.11 1999-07-12 15:58:49 cbratschi Exp $ */ 2 2 /* 3 3 * Toolbar control … … 16 16 * - Internal COMMCTL32 bitmaps. 17 17 * - Fix TOOLBAR_SetButtonInfo32A. 18 * - Customize dialog (CB: under construction).19 18 * - Drag & drop of buttons 20 19 * … … 30 29 31 30 /* CB: Odin32/WINE bugs 32 - IMAGELIST_Draw draws a line too much at the bottom of the bitmap 31 - IMAGELIST_Draw draws a line too at the bottom of the bitmap (toolbar.exe) 32 imagelist uses default size values instead of real bitmap values 33 33 */ 34 34 … … 132 132 HDC hdcImageList = CreateCompatibleDC (0); 133 133 HDC hdcMask = CreateCompatibleDC (0); 134 HIMAGELIST himl = infoPtr->himl Std;134 HIMAGELIST himl = infoPtr->himlDef; 135 135 HBITMAP hbmMask; 136 136 … … 182 182 { 183 183 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0)) 184 TOOLBAR_DrawFlatSeparator (& btnPtr->rect, hdc);184 TOOLBAR_DrawFlatSeparator (&rc, hdc); 185 185 return; 186 186 } … … 189 189 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 190 190 { 191 DrawEdge (hdc, &rc, EDGE_RAISED, 191 if (!(dwStyle & TBSTYLE_FLAT)) 192 DrawEdge (hdc, &rc, EDGE_RAISED, 192 193 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 193 194 194 if (dwStyle & TBSTYLE_FLAT) 195 { 196 /* if (infoPtr->himlDis) */ 197 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 198 rc.left+1, rc.top+1, ILD_NORMAL); 199 /* else */ 200 /* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */ 201 } else 195 if (infoPtr->himlDis) 196 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 197 rc.left+1, rc.top+1, ILD_NORMAL); 198 else 202 199 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 203 200 … … 210 207 { 211 208 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 212 ImageList_Draw (infoPtr->himl Std, btnPtr->iBitmap, hdc,209 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 213 210 rc.left+2, rc.top+2, ILD_NORMAL); 214 211 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); … … 227 224 228 225 TOOLBAR_DrawPattern (hdc, &rc); 229 if (dwStyle & TBSTYLE_FLAT) 230 { 231 if (infoPtr->himlDef != NULL) 232 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 233 rc.left+2, rc.top+2, ILD_NORMAL); 234 else 235 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 236 rc.left+2, rc.top+2, ILD_NORMAL); 237 } else 238 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 239 rc.left+2, rc.top+2, ILD_NORMAL); 226 227 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 228 rc.left+2, rc.top+2, ILD_NORMAL); 229 240 230 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 241 231 return; … … 254 244 } 255 245 246 /* normal state */ 256 247 if (dwStyle & TBSTYLE_FLAT) 257 248 { … … 260 251 BF_RECT | BF_MIDDLE | BF_SOFT); 261 252 262 if( infoPtr->himlDef != NULL)263 ImageList_Draw (infoPtr->himl Def, btnPtr->iBitmap, hdc,253 if(btnPtr->bHot && infoPtr->himlHot) 254 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc, 264 255 rc.left +2, rc.top +2, ILD_NORMAL); 265 256 else 266 ImageList_Draw (infoPtr->himl Std, btnPtr->iBitmap, hdc,257 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 267 258 rc.left +2, rc.top +2, ILD_NORMAL); 268 259 } else 269 260 { 270 /* normal state */271 261 DrawEdge (hdc, &rc, EDGE_RAISED, 272 262 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 273 263 274 ImageList_Draw (infoPtr->himl Std, btnPtr->iBitmap, hdc,264 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 275 265 rc.left+1, rc.top+1, ILD_NORMAL); 276 266 } … … 831 821 } 832 822 823 static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd); 824 static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd); 825 826 static BOOL TBCUSTOMIZE_FillData(HWND hwnd,TOOLBAR_INFO* infoPtr) 827 { 828 TBUTTON_INFO* btnPtr; 829 INT i; 830 INT leftCount = 0; 831 INT rightCount = 0; 832 INT nItem; 833 834 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_RESETCONTENT,0,0); 835 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_RESETCONTENT,0,0); 836 837 /* insert 'virtual' separator button into 'available buttons' list */ 838 nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"Separator"); 839 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,0); 840 841 /* copy all buttons and append them to the listboxes */ 842 btnPtr = infoPtr->buttons; 843 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 844 { 845 if (IsWindowUnicode(infoPtr->hwndNotify)) 846 { 847 TBNOTIFYW tbNotify; 848 849 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 850 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 851 tbNotify.iItem = i; 852 tbNotify.tbButton = (TBBUTTON*)btnPtr; 853 tbNotify.cchText = 0; 854 tbNotify.pszText = NULL; 855 856 // send TBN_QUERYINSERT notification 857 858 tbNotify.hdr.code = TBN_QUERYINSERT; 859 860 if (!SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue; 861 862 // send TBN_QUERYDELETE notification 863 864 tbNotify.hdr.code = TBN_QUERYDELETE; 865 866 btnPtr->bDelete = (BOOL)SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify); 867 868 //get tool name 869 870 TBCUSTOMIZE_GetToolNameW(infoPtr,btnPtr,i); 871 872 } else 873 { 874 TBNOTIFYA tbNotify; 875 876 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 877 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 878 tbNotify.iItem = i; 879 tbNotify.tbButton = (TBBUTTON*)btnPtr; 880 tbNotify.cchText = 0; 881 tbNotify.pszText = NULL; 882 883 // send TBN_QUERYINSERT notification 884 885 tbNotify.hdr.code = TBN_QUERYINSERT; 886 887 if (!SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue; 888 889 // send TBN_QUERYDELETE notification 890 891 tbNotify.hdr.code = TBN_QUERYDELETE; 892 893 btnPtr->bDelete = (BOOL)SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify); 894 895 //get tool name 896 897 TBCUSTOMIZE_GetToolNameA(infoPtr,btnPtr,i); 898 } 899 900 if (btnPtr->fsState & TBSTATE_HIDDEN) 901 { 902 nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 903 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,btnPtr->nCustomID); 904 leftCount++; 905 } else 906 { 907 nItem = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 908 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,nItem,btnPtr->nCustomID); 909 rightCount++; 910 } 911 } 912 913 if (leftCount == 0 && rightCount == 0) return FALSE; 914 915 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,0,0); 916 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,(rightCount > 0) ? 0:(WPARAM)-1,0); 917 918 TBCUSTOMIZE_AvailSelChange(hwnd); 919 TBCUSTOMIZE_VisSelChange(hwnd); 920 921 return TRUE; 922 } 923 833 924 static BOOL TBCUSTOMIZE_InitDialog(HWND hwnd,WPARAM wParam,LPARAM lParam) 834 925 { … … 836 927 837 928 infoPtr = (TOOLBAR_INFO*)lParam; 838 SetWindowLongA (hwnd, DWL_USER,(DWORD)infoPtr);929 SetWindowLongA(hwnd,DWL_USER,(DWORD)infoPtr); 839 930 840 931 if (infoPtr) 841 932 { 842 TBUTTON_INFO* btnPtr; 843 INT i; 844 INT leftCount = 0; 845 INT rightCount = 0; 846 INT nItem; 847 848 infoPtr->hDsa = DSA_Create(sizeof(TBUTTON_INFO),5); 849 850 /* insert 'virtual' separator button into 'available buttons' list */ 851 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"Separator"); 852 853 /* copy all buttons and append them to the right listbox */ 854 btnPtr = infoPtr->buttons; 855 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 933 INT x; 934 935 //custom ID: 1-nNumButtons, 0 == new separator 936 for (x = 0;x < infoPtr->nNumButtons;x++) 856 937 { 857 DSA_InsertItem (infoPtr->hDsa, i, btnPtr); 858 859 if (IsWindowUnicode(infoPtr->hwndNotify)) 938 infoPtr->buttons[x].nCustomID = x+1; 939 infoPtr->buttons[x].pszName = NULL; 940 } 941 infoPtr->nMaxCustomID = infoPtr->nNumButtons; 942 943 //save tools 944 infoPtr->nNumOldButtons = infoPtr->nNumButtons; 945 infoPtr->oldButtons = COMCTL32_Alloc(infoPtr->nNumOldButtons*sizeof(TBUTTON_INFO)); 946 memcpy(&infoPtr->oldButtons[0],&infoPtr->buttons[0],infoPtr->nNumOldButtons*sizeof(TBUTTON_INFO)); 947 948 if (!TBCUSTOMIZE_FillData(hwnd,infoPtr)) EndDialog(hwnd,FALSE); 949 } 950 951 return TRUE; 952 } 953 954 static BOOL TBCUSTOMIZE_Close(HWND hwnd,WPARAM wParam,LPARAM lParam) 955 { 956 EndDialog(hwnd,FALSE); 957 958 return TRUE; 959 } 960 961 static VOID TBCUSTOMIZE_Reset(HWND hwnd) 962 { 963 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 964 NMHDR nmhdr; 965 INT x; 966 967 //Send TBN_RESET 968 nmhdr.hwndFrom = infoPtr->hwndToolbar; 969 nmhdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 970 nmhdr.code = TBN_RESET; 971 972 SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr); 973 974 for (x = 0;x < infoPtr->nNumOldButtons;x++) COMCTL32_Free(infoPtr->oldButtons[x].pszName); 975 976 //restore data 977 if (infoPtr->nNumButtons != infoPtr->nNumOldButtons) 978 { 979 COMCTL32_Free(infoPtr->buttons); 980 infoPtr->nNumButtons = infoPtr->nNumOldButtons; 981 infoPtr->buttons = COMCTL32_Alloc(infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 982 } 983 memcpy(&infoPtr->buttons[0],&infoPtr->oldButtons[0],infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 984 985 if (!TBCUSTOMIZE_FillData(hwnd,infoPtr)) EndDialog(hwnd,FALSE); 986 987 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 988 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 989 } 990 991 static TBUTTON_INFO* TBCUSTOMIZE_GetBtnPtr(TOOLBAR_INFO* infoPtr,INT customID) 992 { 993 INT x; 994 TBUTTON_INFO* btnPtr = infoPtr->buttons; 995 996 if (customID == 0) return NULL; 997 998 for (x = 0;x < infoPtr->nNumButtons;btnPtr++) 999 if (btnPtr->nCustomID == customID) return btnPtr; 1000 1001 return NULL; 1002 } 1003 1004 static VOID TBCUSTOMIZE_AddTool(HWND hwnd) 1005 { 1006 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1007 LRESULT pos,count; 1008 INT customID; 1009 TBUTTON_INFO* btnPtr; 1010 LRESULT rightSel,rightCount,rightPos; 1011 1012 pos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 1013 if (pos == (LRESULT)-1) return; 1014 1015 count = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCOUNT,0,0); 1016 1017 customID = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,pos,0); 1018 if (customID == 0) btnPtr = NULL; else 1019 { 1020 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1021 if (btnPtr == NULL) return; 1022 1023 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_DELETESTRING,pos,0); 1024 } 1025 1026 rightSel = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1027 rightCount = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1028 1029 if (rightSel != (LRESULT)-1) 1030 rightPos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_INSERTSTRING,rightSel,(LPARAM)""); 1031 else 1032 rightPos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 1033 if (!btnPtr) 1034 { //new separator 1035 TBUTTON_INFO* newButtons; 1036 1037 newButtons = COMCTL32_Alloc((infoPtr->nNumButtons+1)*sizeof(TBUTTON_INFO)); 1038 memcpy(&newButtons[0],&infoPtr->buttons[0],infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 1039 COMCTL32_Free(infoPtr->buttons); 1040 1041 infoPtr->buttons = newButtons; 1042 infoPtr->nNumButtons++; 1043 1044 btnPtr = &infoPtr->buttons[infoPtr->nNumButtons-1]; 1045 ZeroMemory(btnPtr,sizeof(TBUTTON_INFO)); 1046 btnPtr->fsStyle = TBSTYLE_SEP; 1047 btnPtr->bDelete = TRUE; 1048 1049 customID = ++infoPtr->nMaxCustomID; 1050 btnPtr->nCustomID = customID; 1051 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,rightPos,customID); 1052 } else 1053 { 1054 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,rightPos,customID); 1055 btnPtr->fsState &= ~TBSTATE_HIDDEN; 1056 } 1057 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,rightPos,0); 1058 TBCUSTOMIZE_VisSelChange(hwnd); 1059 1060 if (rightCount > 0) 1061 { //change order 1062 TBUTTON_INFO* btnPtr2; 1063 INT customID2,pos1,pos2; 1064 1065 pos1 = 0; 1066 while (infoPtr->buttons[pos1].nCustomID != customID) pos1++; 1067 if (rightPos < rightCount) 1068 { //insert before 1069 customID2 = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,rightPos+1,0); 1070 pos2 = 0; 1071 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1072 } else 1073 { //insert behind 1074 INT x; 1075 1076 customID2 = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,rightPos-1,0); 1077 pos2 = 0; 1078 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1079 //exchange to use first alogrithm 1080 x = pos1; 1081 pos1 = pos2; 1082 pos2 = x; 1083 } 1084 1085 if (pos1+1 != pos2) 1086 { 1087 TBUTTON_INFO temp; 1088 INT x; 1089 1090 memcpy(&temp,&infoPtr->buttons[pos1],sizeof(TBUTTON_INFO)); 1091 if (pos1 < pos2) 860 1092 { 861 TBNOTIFYW tbNotify; 862 863 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 864 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 865 tbNotify.iItem = i; 866 tbNotify.tbButton = (TBBUTTON*)btnPtr; 867 tbNotify.cchText = 0; 868 tbNotify.pszText = NULL; 869 870 // send TBN_QUERYINSERT notification 871 872 tbNotify.hdr.code = TBN_QUERYINSERT; 873 874 if (!SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue; 875 876 // send TBN_QUERYDELETE notification 877 878 tbNotify.hdr.code = TBN_QUERYDELETE; 879 880 btnPtr->bDelete = (BOOL)SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify); 881 882 //get tool name 883 884 TBCUSTOMIZE_GetToolNameW(infoPtr,btnPtr,i); 885 1093 for (x = pos1;x < pos2;x++) 1094 memcpy(&infoPtr->buttons[x],&infoPtr->buttons[x+1],sizeof(TBUTTON_INFO)); 1095 memcpy(&infoPtr->buttons[pos2-1],&temp,sizeof(TBUTTON_INFO)); 886 1096 } else 887 1097 { 888 TBNOTIFYA tbNotify; 889 890 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 891 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 892 tbNotify.iItem = i; 893 tbNotify.tbButton = (TBBUTTON*)btnPtr; 894 tbNotify.cchText = 0; 895 tbNotify.pszText = NULL; 896 897 // send TBN_QUERYINSERT notification 898 899 tbNotify.hdr.code = TBN_QUERYINSERT; 900 901 if (!SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue; 902 903 // send TBN_QUERYDELETE notification 904 905 tbNotify.hdr.code = TBN_QUERYDELETE; 906 907 btnPtr->bDelete = (BOOL)SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify); 908 909 //get tool name 910 911 TBCUSTOMIZE_GetToolNameA(infoPtr,btnPtr,i); 1098 for (x = pos1-1;x >= pos2;x--) 1099 memcpy(&infoPtr->buttons[x+1],&infoPtr->buttons[x],sizeof(TBUTTON_INFO)); 1100 memcpy(&infoPtr->buttons[pos2],&temp,sizeof(TBUTTON_INFO)); 912 1101 } 913 914 if (btnPtr->fsState & TBSTATE_HIDDEN) 1102 } 1103 } 1104 1105 if (pos == count-1 && pos > 0) pos--; 1106 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,pos,0); 1107 TBCUSTOMIZE_AvailSelChange(hwnd); 1108 1109 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1110 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 1111 } 1112 1113 static VOID TBCUSTOMIZE_RemoveTool(HWND hwnd) 1114 { 1115 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1116 LRESULT pos,count; 1117 INT customID; 1118 TBUTTON_INFO* btnPtr; 1119 1120 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1121 if (pos == (LRESULT)-1) return; 1122 1123 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1124 1125 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1126 if (customID == 0) return; //no allowed 1127 1128 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1129 if (btnPtr == NULL || !btnPtr->bDelete) return; 1130 1131 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_DELETESTRING,pos,0); 1132 1133 if (btnPtr->fsStyle & TBSTYLE_SEP) 1134 { //remove separator 1135 TBUTTON_INFO* newButtons; 1136 INT nIndex,x; 1137 1138 //find pos 1139 for (x = 0;x < infoPtr->nNumButtons;x++) if (&infoPtr->buttons[x] == btnPtr) 1140 { 1141 nIndex = x; 1142 break; 1143 } 1144 1145 infoPtr->nNumButtons--; 1146 newButtons = COMCTL32_Alloc(infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 1147 1148 if (nIndex > 0) 1149 memcpy(&newButtons[0],&infoPtr->buttons[0],nIndex*sizeof(TBUTTON_INFO)); 1150 1151 if (nIndex < infoPtr->nNumButtons) 1152 memcpy (&newButtons[nIndex],&infoPtr->buttons[nIndex+1],(infoPtr->nNumButtons-nIndex)*sizeof(TBUTTON_INFO)); 1153 1154 COMCTL32_Free(infoPtr->buttons); 1155 infoPtr->buttons = newButtons; 1156 } else 1157 { 1158 LRESULT leftSel,leftCount,leftPos; 1159 1160 leftSel = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 1161 leftCount = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCOUNT,0,0); 1162 1163 if (leftSel == 0) 1164 if (leftCount > 1) leftSel++; else leftSel = -1; 1165 1166 if (leftSel != (LRESULT)-1) 1167 leftPos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_INSERTSTRING,leftSel,(LPARAM)""); 1168 else 1169 leftPos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 1170 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,leftPos,customID); 1171 1172 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,leftPos,0); 1173 TBCUSTOMIZE_AvailSelChange(hwnd); 1174 1175 btnPtr->fsState |= TBSTATE_HIDDEN; 1176 1177 if (leftCount > 1) 1178 { //change order 1179 TBUTTON_INFO* btnPtr2; 1180 INT customID2,pos1,pos2; 1181 1182 pos1 = 0; 1183 while (infoPtr->buttons[pos1].nCustomID != customID) pos1++; 1184 if (leftPos < leftCount) 1185 { //insert before 1186 customID2 = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,leftPos+1,0); 1187 pos2 = 0; 1188 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1189 } else 1190 { //insert behind 1191 INT x; 1192 1193 customID2 = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,leftPos-1,0); 1194 pos2 = 0; 1195 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1196 //exchange to use first alogrithm 1197 x = pos1; 1198 pos1 = pos2; 1199 pos2 = x; 1200 } 1201 1202 if (pos1+1 != pos2) 915 1203 { 916 nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 917 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,(LPARAM)btnPtr); 918 leftCount++; 919 } else 920 { 921 nItem = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 922 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,nItem,(LPARAM)btnPtr); 923 rightCount++; 1204 TBUTTON_INFO temp; 1205 INT x; 1206 1207 memcpy(&temp,&infoPtr->buttons[pos1],sizeof(TBUTTON_INFO)); 1208 if (pos1 < pos2) 1209 { 1210 for (x = pos1;x < pos2;x++) 1211 memcpy(&infoPtr->buttons[x],&infoPtr->buttons[x+1],sizeof(TBUTTON_INFO)); 1212 memcpy(&infoPtr->buttons[pos2-1],&temp,sizeof(TBUTTON_INFO)); 1213 } else 1214 { 1215 for (x = pos1-1;x >= pos2;x--) 1216 memcpy(&infoPtr->buttons[x+1],&infoPtr->buttons[x],sizeof(TBUTTON_INFO)); 1217 memcpy(&infoPtr->buttons[pos2],&temp,sizeof(TBUTTON_INFO)); 1218 } 924 1219 } 925 1220 } 926 927 if (leftCount == 0 && rightCount == 0)928 {929 EndDialog(hwnd,FALSE);930 931 return TRUE;932 }933 1221 } 934 1222 935 return TRUE; 936 } 937 938 static BOOL TBCUSTOMIZE_Close(HWND hwnd,WPARAM wParam,LPARAM lParam) 939 { 940 EndDialog(hwnd,FALSE); 941 942 return TRUE; 943 } 944 945 static VOID TBCUSTOMIZE_Reset(HWND hwnd) 946 { 947 //CB: todo 948 //Send TBN_RESET 949 } 950 951 static VOID TBCUSTOMIZE_AddTool(HWND hwnd) 952 { 953 //CB: todo 954 } 955 956 static VOID TBCUSTOMIZE_RemoveTool(HWND hwnd) 957 { 958 //CB: todo 1223 if (pos == count-1) pos--; 1224 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos,0); 1225 TBCUSTOMIZE_VisSelChange(hwnd); 1226 1227 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1228 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 959 1229 } 960 1230 … … 974 1244 static VOID TBCUSTOMIZE_MoveToolUp(HWND hwnd) 975 1245 { 976 //CB: todo 1246 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1247 LRESULT pos; 1248 TBUTTON_INFO button; 1249 INT customID; 1250 TBUTTON_INFO* btnPtr1,* btnPtr2; 1251 1252 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1253 if (pos == (LRESULT)-1 || pos == 0) return; 1254 1255 //update listbox 1256 1257 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1258 btnPtr1 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1259 if (btnPtr1 == NULL) return; 1260 1261 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos-1,0); 1262 btnPtr2 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1263 if (btnPtr2 == NULL) return; 1264 1265 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos,btnPtr2->nCustomID); 1266 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos-1,btnPtr1->nCustomID); 1267 1268 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos-1,0); 1269 TBCUSTOMIZE_VisSelChange(hwnd); 1270 1271 //update buttons 1272 memcpy(&button,btnPtr1,sizeof(TBUTTON_INFO)); 1273 memcpy(btnPtr1,btnPtr2,sizeof(TBUTTON_INFO)); 1274 memcpy(btnPtr2,&button,sizeof(TBUTTON_INFO)); 1275 1276 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1277 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 977 1278 } 978 1279 979 1280 static VOID TBCUSTOMIZE_MoveToolDown(HWND hwnd) 980 1281 { 981 //CB: todo 1282 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1283 LRESULT pos,count; 1284 TBUTTON_INFO button; 1285 INT customID; 1286 TBUTTON_INFO* btnPtr1,* btnPtr2; 1287 1288 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1289 if (pos == (LRESULT)-1) return; 1290 1291 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1292 if (pos == count-1) return; 1293 1294 //update listbox 1295 1296 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1297 btnPtr1 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1298 if (btnPtr1 == NULL) return; 1299 1300 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos+1,0); 1301 btnPtr2 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1302 if (btnPtr2 == NULL) return; 1303 1304 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos,btnPtr2->nCustomID); 1305 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos+1,btnPtr1->nCustomID); 1306 1307 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos+1,0); 1308 TBCUSTOMIZE_VisSelChange(hwnd); 1309 1310 //update buttons 1311 memcpy(&button,btnPtr1,sizeof(TBUTTON_INFO)); 1312 memcpy(btnPtr1,btnPtr2,sizeof(TBUTTON_INFO)); 1313 memcpy(btnPtr2,&button,sizeof(TBUTTON_INFO)); 1314 1315 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1316 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 1317 } 1318 1319 static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd) 1320 { 1321 LRESULT pos; 1322 HWND hwndBtn; 1323 1324 pos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 1325 1326 hwndBtn = GetDlgItem(hwnd,IDOK); 1327 EnableWindow(hwndBtn,(pos == (LRESULT)-1) ? FALSE:TRUE); 1328 } 1329 1330 static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd) 1331 { 1332 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1333 LRESULT pos; 1334 1335 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1336 1337 if (pos == (LRESULT)-1) 1338 { 1339 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),FALSE); 1340 EnableWindow(GetDlgItem(hwnd,IDC_MOVEUP_BTN),FALSE); 1341 EnableWindow(GetDlgItem(hwnd,IDC_MOVEDN_BTN),FALSE); 1342 } else 1343 { 1344 INT customID; 1345 TBUTTON_INFO* btnPtr; 1346 LRESULT count; 1347 1348 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1349 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1350 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1351 1352 if (btnPtr) 1353 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),btnPtr->bDelete); 1354 else 1355 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),TRUE); 1356 EnableWindow(GetDlgItem(hwnd,IDC_MOVEUP_BTN),!(pos == 0)); 1357 EnableWindow(GetDlgItem(hwnd,IDC_MOVEDN_BTN),!(pos == count-1)); 1358 } 982 1359 } 983 1360 … … 1007 1384 TBCUSTOMIZE_MoveToolDown(hwnd); 1008 1385 break; 1386 case IDC_AVAILBTN_LBOX: 1387 switch(HIWORD(wParam)) 1388 { 1389 case LBN_SELCHANGE: 1390 TBCUSTOMIZE_AvailSelChange(hwnd); 1391 break; 1392 case LBN_DBLCLK: 1393 TBCUSTOMIZE_AddTool(hwnd); 1394 break; 1395 } 1396 break; 1397 case IDC_TOOLBARBTN_LBOX: 1398 switch(HIWORD(wParam)) 1399 { 1400 case LBN_SELCHANGE: 1401 TBCUSTOMIZE_VisSelChange(hwnd); 1402 break; 1403 case LBN_DBLCLK: 1404 TBCUSTOMIZE_RemoveTool(hwnd); 1405 break; 1406 } 1407 break; 1009 1408 } 1010 1409 … … 1017 1416 INT x; 1018 1417 1019 for (x = 0;x < infoPtr->nNumButtons;x++) 1020 { 1021 COMCTL32_Free(infoPtr->buttons[x].pszName); 1022 infoPtr->buttons[x].pszName = NULL; 1023 } 1024 1025 if (infoPtr->hDsa) DSA_Destroy(infoPtr->hDsa); 1418 for (x = 0;x < infoPtr->nNumOldButtons;x++) 1419 COMCTL32_Free(infoPtr->oldButtons[x].pszName); 1420 COMCTL32_Free(infoPtr->oldButtons); 1421 infoPtr->oldButtons = NULL; 1422 infoPtr->nNumOldButtons = 0; 1026 1423 1027 1424 return TRUE; … … 1040 1437 COLORREF oldText = 0; 1041 1438 COLORREF oldBk = 0; 1439 INT customID; 1042 1440 TBUTTON_INFO* btnPtr; 1043 1441 DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE); 1044 1442 1045 btnPtr = (TBUTTON_INFO*)SendDlgItemMessageA(hwnd,wParam,LB_GETITEMDATA,lpdis->itemID,0); 1046 1047 // FIXME(toolbar, "action: %x itemState: %x\n", 1048 // lpdis->itemAction, lpdis->itemState); 1049 1050 if (btnPtr != NULL && !btnPtr->bDelete) 1443 customID = SendDlgItemMessageA(hwnd,wParam,LB_GETITEMDATA,lpdis->itemID,0); 1444 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1445 1446 if (btnPtr != NULL && !btnPtr->bDelete) 1051 1447 { 1052 1448 if (lpdis->itemState & ODS_FOCUS) oldBk = SetBkColor(lpdis->hDC,GetSysColor(COLOR_HIGHLIGHT)); … … 1075 1471 if (lpdis->itemState & ODS_FOCUS) DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1076 1472 1077 /* draw button */ 1078 DrawEdge(lpdis->hDC,&rcButton,EDGE_RAISED,BF_RECT|BF_MIDDLE|BF_SOFT|BF_ADJUST); 1079 1080 if (btnPtr && !btnPtr->fsStyle & TBSTYLE_SEP) 1473 //draw tool 1474 if (btnPtr && !(btnPtr->fsStyle & TBSTYLE_SEP)) 1081 1475 { 1476 //draw button 1082 1477 if (dwStyle & TBSTYLE_FLAT) 1083 1478 { 1084 if(infoPtr->himlDef != NULL) 1085 ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC, 1086 rcButton.left+2,rcButton.top+2,ILD_NORMAL); 1087 else 1088 ImageList_Draw(infoPtr->himlStd,btnPtr->iBitmap,lpdis->hDC, 1089 rcButton.left+2,rcButton.top+2,ILD_NORMAL); 1479 ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC,rcButton.left+2,rcButton.top+2,ILD_NORMAL); 1090 1480 } else 1091 1481 { 1092 /* normal state */1093 ImageList_Draw(infoPtr->himlStd,btnPtr->iBitmap,lpdis->hDC, 1094 1482 DrawEdge (lpdis->hDC,&rcButton,EDGE_RAISED,BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 1483 1484 ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC,rcButton.left+1,rcButton.top+1,ILD_NORMAL); 1095 1485 } 1486 1096 1487 } else 1097 1488 { //draw separator 1098 1489 if (!(dwStyle & TBSTYLE_FLAT)) 1490 DrawEdge (lpdis->hDC,&rcButton,EDGE_RAISED,BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 1491 1492 TOOLBAR_DrawFlatSeparator(&rcButton,lpdis->hDC); 1099 1493 } 1100 1494 … … 1130 1524 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 1131 1525 1132 infoPtr = (TOOLBAR_INFO *)GetWindowLongA(hwnd,DWL_USER);1133 1134 1526 if (infoPtr) 1135 lpmis->itemHeight = infoPtr->nBitmapHeight+8; 1136 else 1137 lpmis->itemHeight = 16+8; /* default height */ 1527 { 1528 DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE); 1529 1530 if (dwStyle & TBSTYLE_FLAT) 1531 lpmis->itemHeight = infoPtr->nBitmapHeight+4; 1532 else 1533 lpmis->itemHeight = infoPtr->nBitmapHeight+8; 1534 } else lpmis->itemHeight = 16+8; 1138 1535 1139 1536 return TRUE; … … 1187 1584 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1188 1585 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam; 1189 INT nIndex = 0 ;1190 1191 if ( (!lpAddBmp) || ((INT)wParam <= 0))1586 INT nIndex = 0,nButtons; 1587 1588 if (!lpAddBmp) 1192 1589 return -1; 1193 1590 1194 // TRACE (toolbar, "adding %d bitmaps!\n", wParam); 1195 1196 if (!(infoPtr->himlStd)) { 1197 /* create new standard image list */ 1198 1199 // TRACE (toolbar, "creating standard image list!\n"); 1200 1591 if (lpAddBmp->hInst == HINST_COMMCTRL) 1592 { 1593 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR) 1594 nButtons = 15; 1595 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR) 1596 nButtons = 13; 1597 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR) 1598 nButtons = 5; 1599 else 1600 return -1; 1601 1602 // TRACE ("adding %d internal bitmaps!\n", nButtons); 1201 1603 1202 1604 /* Windows resize all the buttons to the size of a newly added STandard Image*/ 1203 /* TODO: The resizing should be done each time a standard image is added*/ 1204 if (lpAddBmp->hInst == HINST_COMMCTRL) 1605 if (lpAddBmp->nID & 1) 1205 1606 { 1206 1207 if (lpAddBmp->nID & 1) 1208 { 1209 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1210 MAKELPARAM((WORD)26, (WORD)26)); 1211 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1212 MAKELPARAM((WORD)33, (WORD)33)); 1213 } 1214 else 1215 { 1216 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1217 MAKELPARAM((WORD)16, (WORD)16)); 1218 1219 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1220 MAKELPARAM((WORD)22, (WORD)22)); 1221 } 1222 1223 TOOLBAR_CalcToolbar (hwnd); 1607 /* large icons */ 1608 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1609 MAKELPARAM((WORD)26, (WORD)26)); 1610 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1611 MAKELPARAM((WORD)33, (WORD)33)); 1224 1612 } 1225 1226 infoPtr->himlStd = 1613 else 1614 { 1615 /* small icons */ 1616 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1617 MAKELPARAM((WORD)16, (WORD)16)); 1618 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1619 MAKELPARAM((WORD)22, (WORD)22)); 1620 } 1621 1622 TOOLBAR_CalcToolbar (hwnd); 1623 } 1624 else 1625 { 1626 nButtons = (INT)wParam; 1627 if (nButtons <= 0) 1628 return -1; 1629 1630 // TRACE ("adding %d bitmaps!\n", nButtons); 1631 } 1632 1633 if (!(infoPtr->himlDef)) { 1634 /* create new default image list */ 1635 // TRACE ("creating default image list!\n"); 1636 1637 infoPtr->himlDef = 1227 1638 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, 1228 ILC_COLOR | ILC_MASK, (INT)wParam, 2); 1229 } 1230 1231 /* Add bitmaps to the standard image list */ 1232 if (lpAddBmp->hInst == (HINSTANCE)0) { 1639 ILC_COLOR | ILC_MASK, nButtons, 2); 1640 infoPtr->himlInt = infoPtr->himlDef; 1641 } 1642 1643 /* Add bitmaps to the default image list */ 1644 if (lpAddBmp->hInst == (HINSTANCE)0) 1645 { 1233 1646 nIndex = 1234 ImageList_AddMasked (infoPtr->himl Std, (HBITMAP)lpAddBmp->nID,1647 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID, 1235 1648 CLR_DEFAULT); 1236 1649 } 1237 else if (lpAddBmp->hInst == HINST_COMMCTRL) { 1650 else if (lpAddBmp->hInst == HINST_COMMCTRL) 1651 { 1238 1652 /* add internal bitmaps */ 1239 1240 // FIXME (toolbar, "internal bitmaps not supported!\n"); 1241 /* TODO: Resize all the buttons when a new standard image is added */ 1653 // FIXME ("internal bitmaps not supported!\n"); 1242 1654 1243 1655 /* Hack to "add" some reserved images within the image list 1244 1656 to get the right image indices */ 1245 nIndex = ImageList_GetImageCount (infoPtr->himl Std);1246 ImageList_SetImageCount (infoPtr->himl Std, nIndex + (INT)wParam);1247 1248 }1249 else{1657 nIndex = ImageList_GetImageCount (infoPtr->himlDef); 1658 ImageList_SetImageCount (infoPtr->himlDef, nIndex + nButtons); 1659 } 1660 else 1661 { 1250 1662 HBITMAP hBmp = 1251 1663 LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1252 nIndex = ImageList_AddMasked (infoPtr->himl Std, hBmp, CLR_DEFAULT);1664 nIndex = ImageList_AddMasked (infoPtr->himlDef, hBmp, CLR_DEFAULT); 1253 1665 1254 1666 DeleteObject (hBmp); 1255 1667 } 1256 1668 1257 infoPtr->nNumBitmaps += (INT)wParam;1669 infoPtr->nNumBitmaps += nButtons; 1258 1670 1259 1671 return nIndex; … … 1632 2044 HRSRC hRes; 1633 2045 NMHDR nmhdr; 2046 2047 if (infoPtr->nNumButtons == 0) return 0; 1634 2048 1635 2049 /* send TBN_BEGINADJUST notification */ … … 1966 2380 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1967 2381 1968 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 1969 return (LRESULT)infoPtr->himlDis; 1970 else 1971 return 0; 2382 return (LRESULT)infoPtr->himlDis; 1972 2383 } 1973 2384 … … 1987 2398 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1988 2399 1989 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 1990 return (LRESULT)infoPtr->himlHot; 1991 else 1992 return 0; 2400 return (LRESULT)infoPtr->himlHot; 1993 2401 } 1994 2402 … … 2002 2410 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2003 2411 2004 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 2005 return (LRESULT)infoPtr->himlDef; 2006 else 2007 return 0; 2412 return (LRESULT)infoPtr->himlDef; 2008 2413 } 2009 2414 … … 2654 3059 HIMAGELIST himlTemp; 2655 3060 2656 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))2657 return 0;2658 2659 3061 himlTemp = infoPtr->himlDis; 2660 3062 infoPtr->himlDis = (HIMAGELIST)lParam; … … 2699 3101 HIMAGELIST himlTemp; 2700 3102 2701 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))2702 return 0;2703 2704 3103 himlTemp = infoPtr->himlHot; 2705 3104 infoPtr->himlHot = (HIMAGELIST)lParam; … … 2719 3118 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2720 3119 HIMAGELIST himlTemp; 2721 2722 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))2723 return 0;2724 3120 2725 3121 himlTemp = infoPtr->himlDef; … … 2933 3329 infoPtr->dwDTFlags = DT_CENTER; 2934 3330 2935 infoPtr->hDsa = NULL;2936 3331 infoPtr->hwndToolbar = hwnd; 3332 infoPtr->oldButtons = NULL; 3333 infoPtr->nNumOldButtons = 0; 2937 3334 2938 3335 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); … … 2994 3391 } 2995 3392 2996 /* destroy default image list */ 2997 if (infoPtr->himlDef) 2998 ImageList_Destroy (infoPtr->himlDef); 2999 3000 /* destroy disabled image list */ 3001 if (infoPtr->himlDis) 3002 ImageList_Destroy (infoPtr->himlDis); 3003 3004 /* destroy hot image list */ 3005 if (infoPtr->himlHot) 3006 ImageList_Destroy (infoPtr->himlHot); 3393 /* destroy internal image list */ 3394 if (infoPtr->himlInt) 3395 ImageList_Destroy (infoPtr->himlInt); 3007 3396 3008 3397 /* delete default font */ … … 3192 3581 { 3193 3582 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 3194 if (oldBtnPtr->bHot) 3583 if (oldBtnPtr->bHot) //CB: dynamic buttons 3195 3584 { 3196 3585 oldBtnPtr->bHot = FALSE; -
trunk/src/comctl32/tooltips.c
r285 r295 1 /* $Id: tooltips.c,v 1.1 1 1999-07-07 17:08:43cbratschi Exp $ */1 /* $Id: tooltips.c,v 1.12 1999-07-12 15:58:49 cbratschi Exp $ */ 2 2 /* 3 3 * Tool tip control … … 1133 1133 if (nTool == -1) return 0; 1134 1134 1135 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); 1135 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); //CB: get text 1136 1136 1137 1137 lstrcpyWtoA(lpToolInfo->lpszText,infoPtr->szTipText); … … 1156 1156 if (nTool == -1) return 0; 1157 1157 1158 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); 1158 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); //CB: get text 1159 1159 1160 1160 lstrcpyW(lpToolInfo->lpszText,infoPtr->szTipText); … … 1979 1979 } 1980 1980 1981 static LRESULT 1982 TOOLTIPS_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 1983 { 1984 // FIXME ("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam); 1985 1986 return 0; 1987 } 1981 1988 1982 1989 static LRESULT … … 2020 2027 * returns the length, in characters, of the tip text 2021 2028 ******************************************************************/ 2029 2022 2030 static LRESULT 2023 2031 TOOLTIPS_OnWMGetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam) … … 2321 2329 return TOOLTIPS_NCHitTest (hwnd, wParam, lParam); 2322 2330 2323 /* case WM_NOTIFYFORMAT: */ 2324 /* return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); */ 2331 case WM_NOTIFYFORMAT: 2332 return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); 2325 2333 2326 2334 case WM_PAINT: -
trunk/src/comctl32/treeview.c
r252 r295 1 /* $Id: treeview.c,v 1. 7 1999-06-30 15:52:19 cbratschi Exp $ */1 /* $Id: treeview.c,v 1.8 1999-07-12 15:58:49 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 42 42 */ 43 43 44 /* CB: todo 45 - fix ffs(); 46 */ 44 47 45 48 #include <string.h> … … 1268 1271 * This method does the chaining of the insertion of a treeview item 1269 1272 * before an item. 1273 * If parent is NULL, we're inserting at the root of the list. 1270 1274 */ 1271 1275 static void TREEVIEW_InsertBefore( … … 1305 1309 upSibling->sibling = newItem->hItem; 1306 1310 else 1311 if (parent) 1307 1312 /* this item is the first child of this parent, adjust parent pointers */ 1308 1313 parent->firstChild = newItem->hItem; 1314 else infoPtr->TopRootItem = newItem->hItem; 1309 1315 } 1310 1316 else /* Insert as first child of this parent */ 1317 if (parent) 1311 1318 parent->firstChild = newItem->hItem; 1312 1319 } … … 1314 1321 /*************************************************************************** 1315 1322 * This method does the chaining of the insertion of a treeview item 1323 * If parent is NULL, we're inserting at the root of the list. 1316 1324 * after an item. 1317 1325 */ … … 1357 1365 } 1358 1366 else /* Insert as first child of this parent */ 1367 if (parent) 1359 1368 parent->firstChild = newItem->hItem; 1360 1369 } … … 1390 1399 /* Obtain the TVSORTBC struct */ 1391 1400 infoPtr->pCallBackSort = (LPTVSORTCB)lParam; 1401 1402 /* Check for a valid handle to the parent item */ 1403 if (!TREEVIEW_ValidItem(infoPtr, infoPtr->pCallBackSort->hParent)) 1404 { 1405 // ERR ("invalid item hParent=%d\n", (INT)infoPtr->pCallBackSort->hParent); 1406 return FALSE; 1407 } 1392 1408 1393 1409 /* Obtain the parent node to sort */ … … 1627 1643 else 1628 1644 { 1629 TREEVIEW_ITEM *aChild = 1630 &infoPtr->items[(INT)parentItem->firstChild]; 1645 TREEVIEW_ITEM *aChild; 1631 1646 1632 1647 TREEVIEW_ITEM *previousChild = NULL; 1633 1648 BOOL bItemInserted = FALSE; 1649 1650 if (parentItem) 1651 aChild = &infoPtr->items[(INT)parentItem->firstChild]; 1652 else 1653 aChild = &infoPtr->items[(INT)infoPtr->TopRootItem]; 1634 1654 1635 1655 /* Iterate the parent children to see where we fit in */ -
trunk/src/comctl32/updown.c
r180 r295 1 /* $Id: updown.c,v 1. 5 1999-06-24 16:37:46cbratschi Exp $ */1 /* $Id: updown.c,v 1.6 1999-07-12 15:58:51 cbratschi Exp $ */ 2 2 /* 3 3 * Updown control … … 195 195 196 196 /*if the buddy is a list window, we must set curr index */ 197 if (!lstrcmp A(infoPtr->szBuddyClass,"ListBox"))197 if (!lstrcmpiA(infoPtr->szBuddyClass,"ListBox")) 198 198 { 199 199 newVal = SendMessageA(infoPtr->Buddy,LB_GETCARETINDEX,0,0); … … 245 245 246 246 /*if the buddy is a list window, we must set curr index */ 247 if(!lstrcmp A(infoPtr->szBuddyClass, "ListBox"))247 if(!lstrcmpiA(infoPtr->szBuddyClass, "ListBox")) 248 248 { 249 249 SendMessageA(infoPtr->Buddy,LB_SETCURSEL,infoPtr->CurVal,0); … … 365 365 return FALSE; 366 366 367 /* Store buddy wundow handle */ 368 infoPtr->Buddy = hwndBud; 369 367 370 /* Store buddy window clas name */ 368 371 GetClassNameA (hwndBud, infoPtr->szBuddyClass, 40); … … 529 532 530 533 /* If the buddy is an edit, will set focus to it */ 531 if (!lstrcmp A(infoPtr->szBuddyClass,"Edit")) SetFocus(infoPtr->Buddy);534 if (!lstrcmpiA(infoPtr->szBuddyClass,"Edit")) SetFocus(infoPtr->Buddy); 532 535 533 536 /* Now see which one is the 'active' arrow */ … … 702 705 /*If we released the mouse and our buddy is an edit */ 703 706 /* we must select all text in it. */ 704 if (!lstrcmp A(infoPtr->szBuddyClass,"Edit"))707 if (!lstrcmpiA(infoPtr->szBuddyClass,"Edit")) 705 708 SendMessageA(infoPtr->Buddy,EM_SETSEL,0,MAKELONG(0,-1)); 706 709
Note:
See TracChangeset
for help on using the changeset viewer.