Changeset 295 for trunk/src


Ignore:
Timestamp:
Jul 12, 1999, 5:58:51 PM (26 years ago)
Author:
cbratschi
Message:

wine-990704 updates, TBCUSTOMIZE implemented

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 achimha Exp $ */
     1/* $Id: comctl32undoc.c,v 1.8 1999-07-12 15:58:46 cbratschi Exp $ */
    22/*
    33 * Undocumented functions from COMCTL32.DLL
     
    1111 *
    1212 */
     13
     14/* CB: todo
     15  - porting/implementing string functions
     16  - DPA_LoadStream
     17  - DPA_SaveStream
     18*/
    1319
    1420#include "comctl32.h"
     
    2834 *     dwFlags  [I] flags
    2935 *     pfnSort  [I] pointer to sort function
    30  *     dwParam5 [I]
     36 *     pfnMerge [I] pointer to merge function
    3137 *     lParam   [I] application specific value
    3238 *
     
    3743BOOL WINAPI
    3844DPA_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;
    4351
    4452//    TRACE (commctrl, "(%p %p %08lx %p %p %08lx): stub!\n",
    45 //         hdpa1, hdpa2, dwFlags, pfnCompare, pfnParam5, lParam);
     53//         hdpa1, hdpa2, dwFlags, pfnCompare, pfnParam5, lParam);
    4654
    4755    if (IsBadWritePtr (hdpa1, sizeof(DPA)))
    48         return FALSE;
     56        return FALSE;
    4957
    5058    if (IsBadWritePtr (hdpa2, sizeof(DPA)))
    51         return FALSE;
     59        return FALSE;
    5260
    5361    if (IsBadCodePtr ((FARPROC)pfnCompare))
    54         return FALSE;
    55 
    56     if (IsBadCodePtr ((FARPROC)pfnParam5))
    57         return FALSE;
     62        return FALSE;
     63
     64    if (IsBadCodePtr ((FARPROC)pfnMerge))
     65        return FALSE;
    5866
    5967    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
    7488#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);
    92144#endif
    93 
    94145
    95146    return TRUE;
     
    145196
    146197    if (lpSrc)
    147         lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
     198        lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
    148199    else
    149         lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
     200        lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
    150201
    151202    return lpDest;
     
    210261} MRUINFO, *LPMRUINFO;
    211262
    212  
     263
    213264typedef struct tagMRU
    214265{
     
    223274LPVOID WINAPI
    224275CreateMRUListLazyA (LPMRUINFO lpmi, DWORD dwParam2,
    225                     DWORD dwParam3, DWORD dwParam4);
     276                    DWORD dwParam3, DWORD dwParam4);
    226277
    227278
     
    249300#if 0
    250301    if (!(hmru->dwParam1 & 1001)) {
    251         RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
    252                           hmru->lpszMRUString,
    253                           lstrlenA (hmru->lpszMRUString));
     302        RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
     303                          hmru->lpszMRUString,
     304                          lstrlenA (hmru->lpszMRUString));
    254305    }
    255306
     
    269320
    270321//    FIXME (commctrl, "(%lx %lx %lx) empty stub!\n",
    271 //         dwParam1, dwParam2, dwParam3);
     322//         dwParam1, dwParam2, dwParam3);
    272323
    273324    return 0;
     
    280331
    281332//    FIXME (commctrl, "(%lx %lx %lx %lx) empty stub!\n",
    282 //         dwParam1, dwParam2, dwParam3, dwParam4);
     333//         dwParam1, dwParam2, dwParam3, dwParam4);
    283334
    284335    return TRUE;
     
    304355
    305356    if (lpmi) {
    306 //      FIXME (commctrl, "(%lx %lx %lx %lx \"%s\" %lx)\n",
    307 //             lpmi->dwParam1, lpmi->dwParam2, lpmi->dwParam3,
    308 //             (DWORD)lpmi->hkeyMain, lpmi->lpszSubKey, lpmi->dwParam6);
     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);
    309360    }
    310361
     
    338389
    339390    if (!lpDest && lpSrc)
    340         return lstrlenA (lpSrc);
     391        return lstrlenA (lpSrc);
    341392
    342393    if (nMaxLen == 0)
    343         return 0;
     394        return 0;
    344395
    345396    if (lpSrc == NULL) {
    346         lpDest[0] = '\0';
    347         return 0;
     397        lpDest[0] = '\0';
     398        return 0;
    348399    }
    349400
    350401    len = lstrlenA (lpSrc);
    351402    if (len >= nMaxLen)
    352         len = nMaxLen - 1;
     403        len = nMaxLen - 1;
    353404
    354405    RtlMoveMemory (lpDest, lpSrc, len);
     
    373424{
    374425//    TRACE (commctrl, "(%p %p)\n", lppDest, lpSrc);
    375  
     426
    376427    if (lpSrc) {
    377         LPSTR ptr = COMCTL32_ReAlloc (*lppDest, lstrlenA (lpSrc) + 1);
    378         if (!ptr)
    379             return FALSE;
    380         lstrcpyA (ptr, lpSrc);
    381         *lppDest = ptr;
     428        LPSTR ptr = COMCTL32_ReAlloc (*lppDest, lstrlenA (lpSrc) + 1);
     429        if (!ptr)
     430            return FALSE;
     431        lstrcpyA (ptr, lpSrc);
     432        *lppDest = ptr;
    382433    }
    383434    else {
    384         if (*lppDest) {
    385             COMCTL32_Free (*lppDest);
    386             *lppDest = NULL;
    387         }
     435        if (*lppDest) {
     436            COMCTL32_Free (*lppDest);
     437            *lppDest = NULL;
     438        }
    388439    }
    389440
     
    411462
    412463    if (!lpDest && lpSrc)
    413         return lstrlenW (lpSrc);
     464        return lstrlenW (lpSrc);
    414465
    415466    if (nMaxLen == 0)
    416         return 0;
     467        return 0;
    417468
    418469    if (lpSrc == NULL) {
    419         lpDest[0] = L'\0';
    420         return 0;
     470        lpDest[0] = L'\0';
     471        return 0;
    421472    }
    422473
    423474    len = lstrlenW (lpSrc);
    424475    if (len >= nMaxLen)
    425         len = nMaxLen - 1;
     476        len = nMaxLen - 1;
    426477
    427478    RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
     
    446497{
    447498//    TRACE (commctrl, "(%p %p)\n", lppDest, lpSrc);
    448  
     499
    449500    if (lpSrc) {
    450         INT len = lstrlenW (lpSrc) + 1;
    451         LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
    452         if (!ptr)
    453             return FALSE;
    454         lstrcpyW (ptr, lpSrc);
    455         *lppDest = ptr;
     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;
    456507    }
    457508    else {
    458         if (*lppDest) {
    459             COMCTL32_Free (*lppDest);
    460             *lppDest = NULL;
    461         }
     509        if (*lppDest) {
     510            COMCTL32_Free (*lppDest);
     511            *lppDest = NULL;
     512        }
    462513    }
    463514
     
    494545    if (hdsa)
    495546    {
    496         hdsa->nItemCount = 0;
     547        hdsa->nItemCount = 0;
    497548        hdsa->pData = NULL;
    498         hdsa->nMaxCount = 0;
    499         hdsa->nItemSize = nSize;
    500         hdsa->nGrow = MAX(1, nGrow);
     549        hdsa->nMaxCount = 0;
     550        hdsa->nItemSize = nSize;
     551        hdsa->nGrow = MAX(1, nGrow);
    501552    }
    502553
     
    522573
    523574    if (!hdsa)
    524         return FALSE;
     575        return FALSE;
    525576
    526577    if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
    527         return FALSE;
     578        return FALSE;
    528579
    529580    return COMCTL32_Free (hdsa);
     
    532583
    533584/**************************************************************************
    534  * DSA_GetItem [COMCTL32.322] 
     585 * DSA_GetItem [COMCTL32.322]
    535586 *
    536587 * PARAMS
     
    550601
    551602//    TRACE (commctrl, "(%p %d %p)\n", hdsa, nIndex, pDest);
    552    
     603
    553604    if (!hdsa)
    554         return FALSE;
     605        return FALSE;
    555606    if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
    556         return FALSE;
     607        return FALSE;
    557608
    558609    pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
     
    564615
    565616/**************************************************************************
    566  * DSA_GetItemPtr [COMCTL32.323] 
     617 * DSA_GetItemPtr [COMCTL32.323]
    567618 *
    568619 * Retrieves a pointer to the specified item.
     
    585636
    586637    if (!hdsa)
    587         return NULL;
     638        return NULL;
    588639    if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
    589         return NULL;
     640        return NULL;
    590641
    591642    pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    592    
     643
    593644//    TRACE (commctrl, "-- ret=%p\n", pSrc);
    594645
     
    598649
    599650/**************************************************************************
    600  * DSA_SetItem [COMCTL32.325] 
     651 * DSA_SetItem [COMCTL32.325]
    601652 *
    602653 * Sets the contents of an item in the array.
     
    617668    INT  nSize, nNewItems;
    618669    LPVOID pDest, lpTemp;
    619    
     670
    620671//    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
    621672
    622673    if ((!hdsa) || nIndex < 0)
    623         return FALSE;
    624      
     674        return FALSE;
     675
    625676    if (hdsa->nItemCount <= nIndex) {
    626         /* within the old array */
    627         if (hdsa->nMaxCount > nIndex) {
    628             /* within the allocated space, set a new boundary */
    629             hdsa->nItemCount = nIndex + 1;
    630         }
    631         else {
    632             /* resize the block of memory */
    633             nNewItems =
    634                 hdsa->nGrow * ((INT)((nIndex - 1) / hdsa->nGrow) + 1);
    635             nSize = hdsa->nItemSize * nNewItems;
    636 
    637             lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
    638             if (!lpTemp)
    639                 return FALSE;
    640 
    641             hdsa->nMaxCount = nNewItems;
    642             hdsa->nItemCount = nIndex + 1;
    643             hdsa->pData = lpTemp;
    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        }
    645696    }
    646697
     
    648699    pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    649700//    TRACE("-- move dest=%p src=%p size=%d\n",
    650 //         pDest, pSrc, hdsa->nItemSize);
     701//         pDest, pSrc, hdsa->nItemSize);
    651702    memmove (pDest, pSrc, hdsa->nItemSize);
    652703
     
    656707
    657708/**************************************************************************
    658  * DSA_InsertItem [COMCTL32.325] 
     709 * DSA_InsertItem [COMCTL32.325]
    659710 *
    660711 * PARAMS
     
    674725    LPVOID  lpTemp, lpDest;
    675726    LPDWORD p;
    676    
     727
    677728//    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
    678729
    679730    if ((!hdsa) || nIndex < 0)
    680         return -1;
     731        return -1;
    681732
    682733    for (i = 0; i < hdsa->nItemSize; i += 4) {
    683         p = *(DWORD**)((char *) pSrc + i);
    684 //      if (IsBadStringPtrA ((char*)p, 256))
    685 //          TRACE("-- %d=%p\n", i, (DWORD*)p);
    686 //      else
    687 //          TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
    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
    690741    /* when nIndex > nItemCount then append */
    691742    if (nIndex >= hdsa->nItemCount)
    692         nIndex = hdsa->nItemCount;
     743        nIndex = hdsa->nItemCount;
    693744
    694745    /* do we need to resize ? */
    695746    if (hdsa->nItemCount >= hdsa->nMaxCount) {
    696         nNewItems = hdsa->nMaxCount + hdsa->nGrow;
    697         nSize = hdsa->nItemSize * nNewItems;
    698 
    699         lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
    700         if (!lpTemp)
    701             return -1;
    702 
    703         hdsa->nMaxCount = nNewItems;
    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;
    705756    }
    706757
    707758    /* do we need to move elements ? */
    708759    if (nIndex < hdsa->nItemCount) {
    709         lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    710         lpDest = (char *) lpTemp + hdsa->nItemSize;
    711         nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
    712 //      TRACE("-- move dest=%p src=%p size=%d\n",
    713 //             lpDest, lpTemp, nSize);
    714         memmove (lpDest, lpTemp, nSize);
     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);
    715766    }
    716767
     
    719770    lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    720771//    TRACE("-- move dest=%p src=%p size=%d\n",
    721 //         lpDest, pSrc, hdsa->nItemSize);
     772//         lpDest, pSrc, hdsa->nItemSize);
    722773    memmove (lpDest, pSrc, hdsa->nItemSize);
    723774
     
    727778
    728779/**************************************************************************
    729  * DSA_DeleteItem [COMCTL32.326] 
     780 * DSA_DeleteItem [COMCTL32.326]
    730781 *
    731782 * PARAMS
     
    743794    LPVOID lpDest,lpSrc;
    744795    INT  nSize;
    745    
     796
    746797//    TRACE (commctrl, "(%p %d)\n", hdsa, nIndex);
    747798
    748799    if (!hdsa)
    749         return -1;
     800        return -1;
    750801    if (nIndex < 0 || nIndex >= hdsa->nItemCount)
    751         return -1;
     802        return -1;
    752803
    753804    /* do we need to move ? */
    754805    if (nIndex < hdsa->nItemCount - 1) {
    755         lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    756         lpSrc = (char *) lpDest + hdsa->nItemSize;
    757         nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
    758 //      TRACE (commctrl, "-- move dest=%p src=%p size=%d\n",
    759 //             lpDest, lpSrc, nSize);
    760         memmove (lpDest, lpSrc, nSize);
    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
    763814    hdsa->nItemCount--;
    764    
     815
    765816    /* free memory ? */
    766817    if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
    767         nSize = hdsa->nItemSize * hdsa->nItemCount;
    768 
    769         lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
    770         if (!lpDest)
    771             return -1;
    772 
    773         hdsa->nMaxCount = hdsa->nItemCount;
    774         hdsa->pData = lpDest;
     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;
    775826    }
    776827
     
    797848//    TRACE (commctrl, "(%p)\n", hdsa);
    798849
    799     if (!hdsa) 
    800         return FALSE;
     850    if (!hdsa)
     851        return FALSE;
    801852    if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
    802         return FALSE;
     853        return FALSE;
    803854
    804855    hdsa->nItemCount = 0;
     
    835886    hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
    836887    if (hdpa) {
    837         hdpa->nGrow = MAX(8, nGrow);
    838         hdpa->hHeap = COMCTL32_hHeap;
    839         hdpa->nMaxCount = hdpa->nGrow * 2;
    840         hdpa->ptrs =
    841             (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
     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));
    842893    }
    843894
     
    865916
    866917    if (!hdpa)
    867         return FALSE;
     918        return FALSE;
    868919
    869920    if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
    870         return FALSE;
     921        return FALSE;
    871922
    872923    return HeapFree (hdpa->hHeap, 0, hdpa);
     
    894945
    895946    if (!hdpa)
    896         return FALSE;
     947        return FALSE;
    897948
    898949    hdpa->nGrow = MAX(8, nGrow);
     
    929980
    930981    if (!hdpa)
    931         return NULL;
     982        return NULL;
    932983
    933984//    TRACE (commctrl, "(%p %p)\n", hdpa, hdpaNew);
    934985
    935986    if (!hdpaNew) {
    936         /* create a new DPA */
    937         hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    938                                     sizeof(DPA));
    939         hdpaTemp->hHeap = hdpa->hHeap;
    940         hdpaTemp->nGrow = hdpa->nGrow;
     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;
    941992    }
    942993    else
    943         hdpaTemp = hdpaNew;
     994        hdpaTemp = hdpaNew;
    944995
    945996    if (hdpaTemp->ptrs) {
    946         /* remove old pointer array */
    947         HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
    948         hdpaTemp->ptrs = NULL;
    949         hdpaTemp->nItemCount = 0;
    950         hdpaTemp->nMaxCount = 0;
     997        /* remove old pointer array */
     998        HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
     999        hdpaTemp->ptrs = NULL;
     1000        hdpaTemp->nItemCount = 0;
     1001        hdpaTemp->nMaxCount = 0;
    9511002    }
    9521003
    9531004    /* create a new pointer array */
    9541005    nNewItems = hdpaTemp->nGrow *
    955                 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
     1006                ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
    9561007    nSize = nNewItems * sizeof(LPVOID);
    9571008    hdpaTemp->ptrs =
    958         (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
     1009        (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
    9591010    hdpaTemp->nMaxCount = nNewItems;
    9601011
     
    9621013    hdpaTemp->nItemCount = hdpa->nItemCount;
    9631014    memmove (hdpaTemp->ptrs, hdpa->ptrs,
    964              hdpaTemp->nItemCount * sizeof(LPVOID));
     1015             hdpaTemp->nItemCount * sizeof(LPVOID));
    9651016
    9661017    return hdpaTemp;
     
    9881039
    9891040    if (!hdpa)
    990         return NULL;
     1041        return NULL;
    9911042    if (!hdpa->ptrs)
    992         return NULL;
     1043        return NULL;
    9931044    if ((i < 0) || (i >= hdpa->nItemCount))
    994         return NULL;
     1045        return NULL;
    9951046
    9961047//    TRACE (commctrl, "-- %p\n", hdpa->ptrs[i]);
     
    10201071
    10211072    if (!hdpa->ptrs)
    1022         return -1;
     1073        return -1;
    10231074
    10241075    for (i = 0; i < hdpa->nItemCount; i++) {
    1025         if (hdpa->ptrs[i] == p)
    1026             return i;
     1076        if (hdpa->ptrs[i] == p)
     1077            return i;
    10271078    }
    10281079
     
    10551106
    10561107    if ((!hdpa) || (i < 0))
    1057         return -1;
     1108        return -1;
    10581109
    10591110    if (!hdpa->ptrs) {
    1060         hdpa->ptrs =
    1061             (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1062                                 2 * hdpa->nGrow * sizeof(LPVOID));
    1063         if (!hdpa->ptrs)
    1064             return -1;
    1065         hdpa->nMaxCount = hdpa->nGrow * 2;
     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;
    10661117        nIndex = 0;
    10671118    }
    10681119    else {
    1069         if (hdpa->nItemCount >= hdpa->nMaxCount) {
    1070 //          TRACE (commctrl, "-- resizing\n");
    1071             nNewItems = hdpa->nMaxCount + hdpa->nGrow;
    1072             nSize = nNewItems * sizeof(LPVOID);
    1073 
    1074             lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1075                                            hdpa->ptrs, nSize);
    1076             if (!lpTemp)
    1077                 return -1;
    1078             hdpa->nMaxCount = nNewItems;
    1079             hdpa->ptrs = lpTemp;
    1080         }
    1081 
    1082         if (i >= hdpa->nItemCount) {
    1083             nIndex = hdpa->nItemCount;
    1084 //          TRACE (commctrl, "-- appending at %d\n", nIndex);
    1085         }
    1086         else {
    1087 //          TRACE (commctrl, "-- inserting at %d\n", i);
    1088             lpTemp = hdpa->ptrs + i;
    1089             lpDest = lpTemp + 1;
    1090             nSize  = (hdpa->nItemCount - i) * sizeof(LPVOID);
    1091 //          TRACE (commctrl, "-- move dest=%p src=%p size=%x\n",
    1092 //                 lpDest, lpTemp, nSize);
    1093             memmove (lpDest, lpTemp, nSize);
    1094             nIndex = i;
    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        }
    10961147    }
    10971148
     
    11231174{
    11241175    LPVOID *lpTemp;
    1125    
     1176
    11261177//    TRACE (commctrl, "(%p %d %p)\n", hdpa, i, p);
    11271178
    11281179    if ((!hdpa) || i < 0)
    1129         return FALSE;
    1130      
     1180        return FALSE;
     1181
    11311182    if (hdpa->nItemCount <= i) {
    1132         /* within the old array */
    1133         if (hdpa->nMaxCount > i) {
    1134             /* within the allocated space, set a new boundary */
    1135             hdpa->nItemCount = i;
    1136         }
    1137         else {
    1138             /* resize the block of memory */
    1139             INT nNewItems =
    1140                 hdpa->nGrow * ((INT)((i - 1) / hdpa->nGrow) + 1);
    1141             INT nSize = nNewItems * sizeof(LPVOID);
    1142 
    1143             lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1144                                            hdpa->ptrs, nSize);
    1145             if (!lpTemp)
    1146                 return FALSE;
    1147 
    1148             hdpa->nItemCount = nNewItems;
    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        }
    11511202    }
    11521203
     
    11771228    LPVOID *lpDest, *lpSrc, lpTemp = NULL;
    11781229    INT  nSize;
    1179    
     1230
    11801231//    TRACE (commctrl, "(%p %d)\n", hdpa, i);
    11811232
    11821233    if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
    1183         return NULL;
     1234        return NULL;
    11841235
    11851236    lpTemp = hdpa->ptrs[i];
     
    11871238    /* do we need to move ?*/
    11881239    if (i < hdpa->nItemCount - 1) {
    1189         lpDest = hdpa->ptrs + i;
    1190         lpSrc = lpDest + 1;
    1191         nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
    1192 //      TRACE (commctrl,"-- move dest=%p src=%p size=%x\n",
    1193 //             lpDest, lpSrc, nSize);
    1194         memmove (lpDest, lpSrc, nSize);
    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
    11971248    hdpa->nItemCount --;
    1198    
     1249
    11991250    /* free memory ?*/
    12001251    if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
    1201         INT nNewItems = MIN(hdpa->nGrow * 2, hdpa->nItemCount);
    1202         nSize = nNewItems * sizeof(LPVOID);
    1203         lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1204                                       hdpa->ptrs, nSize);
    1205         if (!lpDest)
    1206             return NULL;
    1207 
    1208         hdpa->nMaxCount = nNewItems;
    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;
    12101261    }
    12111262
     
    12321283//    TRACE (commctrl, "(%p)\n", hdpa);
    12331284
    1234     if (!hdpa) 
    1235         return FALSE;
     1285    if (!hdpa)
     1286        return FALSE;
    12361287
    12371288    if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
    1238         return FALSE;
     1289        return FALSE;
    12391290
    12401291    hdpa->nItemCount = 0;
    12411292    hdpa->nMaxCount = hdpa->nGrow * 2;
    12421293    hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1243                                      hdpa->nMaxCount * sizeof(LPVOID));
     1294                                     hdpa->nMaxCount * sizeof(LPVOID));
    12441295
    12451296    return TRUE;
     
    12651316static VOID
    12661317DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
    1267                PFNDPACOMPARE pfnCompare, LPARAM lParam)
     1318               PFNDPACOMPARE pfnCompare, LPARAM lParam)
    12681319{
    12691320    LPVOID t, v;
     
    12711322
    12721323//    TRACE (commctrl, "l=%i r=%i\n", l, r);
    1273  
     1324
    12741325    i = l;
    12751326    j = r;
    12761327    v = lpPtrs[(int)(l+r)/2];
    12771328    do {
    1278         while ((pfnCompare)(lpPtrs[i], v, lParam) > 0) i++;
    1279         while ((pfnCompare)(lpPtrs[j], v, lParam) < 0) j--;
    1280         if (i <= j)
    1281         {
    1282             t = lpPtrs[i];
    1283             lpPtrs[i++] = lpPtrs[j];
    1284             lpPtrs[j--] = t;
    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        }
    12861337    } while (i <= j);
    12871338    if (l < j) DPA_QuickSort (lpPtrs, l, j, pfnCompare, lParam);
     
    13091360{
    13101361    if (!hdpa || !pfnCompare)
    1311         return FALSE;
     1362        return FALSE;
    13121363
    13131364//    TRACE (commctrl, "(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam);
    13141365
    13151366    if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
    1316         DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
    1317                        pfnCompare, lParam);
     1367        DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
     1368                       pfnCompare, lParam);
    13181369
    13191370    return TRUE;
     
    13461397INT WINAPI
    13471398DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
    1348             PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
     1399            PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
    13491400{
    13501401    if (!hdpa || !pfnCompare || !pFind)
    1351         return -1;
     1402        return -1;
    13521403
    13531404//    TRACE (commctrl, "(%p %p %d %p 0x%08lx 0x%08x)\n",
    1354 //         hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
     1405//         hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
    13551406
    13561407    if (uOptions & DPAS_SORTED) {
    1357         /* array is sorted --> use binary search */
    1358         INT l, r, x, n;
    1359         LPVOID *lpPtr;
    1360 
    1361 //      TRACE (commctrl, "binary search\n");
    1362 
    1363         l = (nStart == -1) ? 0 : nStart;
    1364         r = hdpa->nItemCount - 1;
    1365         lpPtr = hdpa->ptrs;
    1366         while (r >= l) {
    1367             x = (l + r) / 2;
    1368             n = (pfnCompare)(pFind, lpPtr[x], lParam);
    1369             if (n < 0)
    1370                 r = x - 1;
    1371             else
    1372                 l = x + 1;
    1373             if (n == 0) {
    1374 //              TRACE (commctrl, "-- ret=%d\n", n);
    1375                 return n;
    1376             }
    1377         }
    1378 
    1379         if (uOptions & DPAS_INSERTBEFORE) {
    1380 //          TRACE (commctrl, "-- ret=%d\n", r);
    1381             return r;
    1382         }
    1383 
    1384         if (uOptions & DPAS_INSERTAFTER) {
    1385 //          TRACE (commctrl, "-- ret=%d\n", l);
    1386             return l;
    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        }
    13881439    }
    13891440    else {
    1390         /* array is not sorted --> use linear search */
    1391         LPVOID *lpPtr;
    1392         INT  nIndex;
    1393 
    1394 //      TRACE (commctrl, "linear search\n");
    1395        
    1396         nIndex = (nStart == -1)? 0 : nStart;
    1397         lpPtr = hdpa->ptrs;
    1398         for (; nIndex < hdpa->nItemCount; nIndex++) {
    1399             if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
    1400 //              TRACE (commctrl, "-- ret=%d\n", nIndex);
    1401                 return nIndex;
    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        }
    14041455    }
    14051456
     
    14311482
    14321483    if (hHeap)
    1433         hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
     1484        hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
    14341485    else
    1435         hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
     1486        hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
    14361487
    14371488    if (hdpa) {
    1438         hdpa->nGrow = MIN(8, nGrow);
    1439         hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
    1440         hdpa->nMaxCount = hdpa->nGrow * 2;
    1441         hdpa->ptrs =
    1442             (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
    1443                                 hdpa->nMaxCount * sizeof(LPVOID));
     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));
    14441495    }
    14451496
     
    14761527
    14771528//    TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n",
    1478 //         lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
    1479 //         lpNotify->dwParam5);
     1529//         lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
     1530//         lpNotify->dwParam5);
    14801531
    14811532    if (!lpNotify->hwndTo)
    1482         return 0;
     1533        return 0;
    14831534
    14841535    if (lpNotify->hwndFrom == -1) {
    1485         lpNmh = lpHdr;
    1486         idFrom = lpHdr->idFrom;
     1536        lpNmh = lpHdr;
     1537        idFrom = lpHdr->idFrom;
    14871538    }
    14881539    else {
    1489         if (lpNotify->hwndFrom) {
    1490             HWND hwndParent = GetParent (lpNotify->hwndFrom);
    1491             if (hwndParent) {
    1492                 hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
    1493                 if (hwndParent)
    1494                     idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
    1495             }
    1496         }
    1497 
    1498         lpNmh = (lpHdr) ? lpHdr : &nmhdr;
    1499 
    1500         lpNmh->hwndFrom = lpNotify->hwndFrom;
    1501         lpNmh->idFrom = idFrom;
    1502         lpNmh->code = uCode;
     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;
    15031554    }
    15041555
     
    15231574LRESULT WINAPI
    15241575COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
    1525                      UINT uCode, LPNMHDR lpHdr)
     1576                     UINT uCode, LPNMHDR lpHdr)
    15261577{
    15271578    NOTIFYDATA notify;
    15281579
    15291580//    TRACE (commctrl, "(0x%04x 0x%04x %d %p)\n",
    1530 //         hwndFrom, hwndTo, uCode, lpHdr);
     1581//         hwndFrom, hwndTo, uCode, lpHdr);
    15311582
    15321583    notify.hwndFrom = hwndFrom;
     
    15561607LRESULT WINAPI
    15571608COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
    1558                        LPNMHDR lpHdr, DWORD dwParam5)
     1609                       LPNMHDR lpHdr, DWORD dwParam5)
    15591610{
    15601611    NOTIFYDATA notify;
     
    15621613
    15631614//    TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n",
    1564 //         hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
     1615//         hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
    15651616
    15661617    hwndNotify = hwndTo;
    15671618    if (!hwndTo) {
    1568         if (IsWindow (hwndFrom)) {
    1569             hwndNotify = GetParent (hwndFrom);
    1570             if (!hwndNotify)
    1571                 return 0;
    1572         }
     1619        if (IsWindow (hwndFrom)) {
     1620            hwndNotify = GetParent (hwndFrom);
     1621            if (!hwndNotify)
     1622                return 0;
     1623        }
    15731624    }
    15741625
     
    16051656
    16061657    if (*lpStr2 == 0)
    1607         return ((LPSTR)lpStr1);
     1658        return ((LPSTR)lpStr1);
    16081659    len1 = 0;
    16091660    while (lpStr1[len1] != 0) ++len1;
     
    16111662    while (lpStr2[len2] != 0) ++len2;
    16121663    if (len2 == 0)
    1613         return ((LPSTR)(lpStr1 + len1));
     1664        return ((LPSTR)(lpStr1 + len1));
    16141665    first = tolower (*lpStr2);
    16151666    while (len1 >= len2) {
    1616         if (tolower(*lpStr1) == first) {
    1617             for (i = 1; i < len2; ++i)
    1618                 if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
    1619                     break;
    1620             if (i >= len2)
    1621                 return ((LPSTR)lpStr1);
    1622         }
    1623         ++lpStr1; --len1;
     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;
    16241675    }
    16251676    return (NULL);
     
    16411692 *
    16421693 * Enumerates all items in a dynamic pointer array.
    1643  *
    1644  * PARAMS
    1645  *     hdpa     [I] handle to the dynamic pointer array
    1646  *     enumProc [I]
    1647  *     lParam   [I]
    1648  *
    1649  * RETURNS
    1650  *     none
    1651  */
    1652 
    1653 VOID WINAPI
    1654 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.
    16781694 *
    16791695 * PARAMS
     
    16831699 *
    16841700 * RETURNS
     1701 *     none
     1702 */
     1703
     1704
     1705VOID WINAPI
     1706DPA_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
    16851737 *     Success: TRUE
    16861738 *     Failure: FALSE
     
    17201772
    17211773    if (!hdsa)
    1722         return;
     1774        return;
    17231775    if (hdsa->nItemCount <= 0)
    1724         return;
     1776        return;
    17251777
    17261778    for (i = 0; i < hdsa->nItemCount; i++) {
    1727         LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
    1728         if ((enumProc)(lpItem, lParam) == 0)
    1729             return;
     1779        LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
     1780        if ((enumProc)(lpItem, lParam) == 0)
     1781            return;
    17301782    }
    17311783
     
    17961848 */
    17971849LPSTR WINAPI COMCTL32_StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch) {
    1798 //  return lstrrchr(lpStart, lpEnd, wMatch); 
     1850//  return lstrrchr(lpStart, lpEnd, wMatch);
    17991851}
    18001852
     
    18041856 */
    18051857LPWSTR WINAPI COMCTL32_StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch) {
    1806 //  return lstrrchrw(lpStart, lpEnd, wMatch); 
     1858//  return lstrrchrw(lpStart, lpEnd, wMatch);
    18071859}
    18081860
     
    18381890//    if( CRTDLL_wcschr(lpSet, *(WORD*)lpLoop))
    18391891//      return (INT)(lpLoop-lpStr);
    1840  
     1892
    18411893//  return (INT)(lpLoop-lpStr);
    18421894}
  • trunk/src/comctl32/imagelist.c

    r164 r295  
    1 /* $Id: imagelist.c,v 1.4 1999-06-23 19:45:00 achimha Exp $ */
     1/* $Id: imagelist.c,v 1.5 1999-07-12 15:58:47 cbratschi Exp $ */
    22/*
    33 *  ImageList implementation
     
    2121 *    - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use
    2222 *      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
    2424 *      limited in functionality too.
    2525 */
     26
     27/* CB: todo
     28  - ImageList_Read
     29  - ImageList_Write
     30*/
    2631
    2732/* This must be defined because the HIMAGELIST type is just a pointer
     
    3237#define __WINE_IMAGELIST_C
    3338
    34 #include "imagelist.h" 
     39#include "imagelist.h"
    3540#include "commctrl.h"
    3641#include "comctl32.h"
     
    5762
    5863/*************************************************************************
    59  * IMAGELIST_InternalExpandBitmaps [Internal] 
     64 * IMAGELIST_InternalExpandBitmaps [Internal]
    6065 *
    6166 * Expands the bitmaps of an image list by the given number of images.
     
    101106
    102107    if (himl->hbmMask) {
    103         hbmNewBitmap = 
     108        hbmNewBitmap =
    104109            CreateBitmap (nNewWidth, himl->cy, 1, 1, NULL);
    105110
     
    138143
    139144INT WINAPI
    140 ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
     145ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
    141146{
    142147    HDC    hdcSrc, hdcDst;
     
    146151
    147152    if (!himl || !hbmImage)
    148         return -1;
     153        return -1;
    149154
    150155    GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp);
     
    164169    BitBlt (hdcDst, himl->cCurImage * himl->cx, 0,
    165170              bmp.bmWidth, himl->cy, hdcSrc, 0, 0, SRCCOPY);
    166          
     171
    167172    if (himl->hbmMask) {
    168173        if (hbmMask) {
    169             /* copy mask bitmap */
     174            /* copy mask bitmap */
    170175            SelectObject (hdcDst, himl->hbmMask);
    171176            SelectObject (hdcSrc, hbmMask);
    172177            BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy,
    173                       hdcSrc, 0, 0, SRCCOPY);
     178                      hdcSrc, 0, 0, SRCCOPY);
    174179        }
    175180        else {
    176             /* copy monochrome image to the mask bitmap */
     181            /* copy monochrome image to the mask bitmap */
    177182            SelectObject (hdcDst, himl->hbmMask);
    178183            SelectObject (hdcSrc, hbmImage);
    179             SetBkColor (hdcSrc, GetNearestColor (hdcSrc,
    180                           GetPixel (hdcSrc, 0, 0)));
    181             BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy,
    182                       hdcSrc, nStartX, 0, SRCCOPY);
     184            SetBkColor (hdcSrc, GetNearestColor (hdcSrc,
     185                          GetPixel (hdcSrc, 0, 0)));
     186            BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy,
     187                      hdcSrc, nStartX, 0, SRCCOPY);
    183188        }
    184189    }
     
    216221
    217222/*************************************************************************
    218  * ImageList_AddMasked [COMCTL32.41] 
     223 * ImageList_AddMasked [COMCTL32.41]
    219224 *
    220225 * Adds an image or images to an image list and creates a mask from the
     
    239244
    240245    if (himl == NULL)
    241         return -1;
     246        return -1;
    242247
    243248    if (!GetObjectA (hBitmap, sizeof(BITMAP), &bmp))
    244         return -1;
     249        return -1;
    245250
    246251    nImageCount = bmp.bmWidth / himl->cx;
     
    261266
    262267    if (himl->hbmMask) {
    263         COLORREF bkColor = (clrMask != CLR_DEFAULT) ? clrMask :
    264             GetNearestColor (hdcBitmap, GetPixel (hdcBitmap, 0, 0));
    265 
    266         /* create mask from image */
     268        COLORREF bkColor = (clrMask != CLR_DEFAULT) ? clrMask :
     269            GetNearestColor (hdcBitmap, GetPixel (hdcBitmap, 0, 0));
     270
     271        /* create mask from image */
    267272        hdcMask = CreateCompatibleDC (0);
    268273        SelectObject (hdcMask, himl->hbmMask);
    269274
    270         /* create monochrome image to the mask bitmap */
    271         SetBkColor (hdcBitmap, bkColor);
    272         BitBlt (hdcMask, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy,
    273                   hdcBitmap, 0, 0, SRCCOPY);
     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);
    274279
    275280        DeleteDC (hdcMask);
     
    278283    DeleteDC (hdcImage);
    279284    DeleteDC (hdcBitmap);
    280  
     285
    281286    return nIndex;
    282287}
     
    284289
    285290/*************************************************************************
    286  * ImageList_BeginDrag [COMCTL32.42] 
     291 * ImageList_BeginDrag [COMCTL32.42]
    287292 *
    288293 * Creates a temporary image list that contains one image. It will be used
     
    302307BOOL WINAPI
    303308ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack,
    304                      INT dxHotspot, INT dyHotspot)
     309                     INT dxHotspot, INT dyHotspot)
    305310{
    306311    HDC hdcSrc, hdcDst;
     
    309314
    310315    if (himlTrack == NULL)
    311         return FALSE;
     316        return FALSE;
    312317
    313318    if (himlInternalDrag)
     
    315320
    316321    himlInternalDrag =
    317         ImageList_Create (himlTrack->cx, himlTrack->cy,
    318                           himlTrack->flags, 1, 1);
     322        ImageList_Create (himlTrack->cx, himlTrack->cy,
     323                          himlTrack->flags, 1, 1);
    319324    if (himlInternalDrag == NULL) {
    320325//        ERR(imagelist, "Error creating drag image list!\n");
     
    350355
    351356/*************************************************************************
    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
    355360 *  destination image list. Images can be copied or swapped.
    356361 *
     
    373378
    374379BOOL WINAPI
    375 ImageList_Copy (HIMAGELIST himlDst, INT iDst,   HIMAGELIST himlSrc,
    376                 INT iSrc, INT uFlags)
    377 {
    378     HDC hdcSrc, hdcDst;   
     380ImageList_Copy (HIMAGELIST himlDst, INT iDst,   HIMAGELIST himlSrc,
     381                INT iSrc, INT uFlags)
     382{
     383    HDC hdcSrc, hdcDst;
    379384
    380385//    TRACE(imagelist, "iDst=%d  iSrc=%d\n", iDst, iSrc);
    381386
    382387    if ((himlSrc == NULL) || (himlDst == NULL))
    383         return FALSE;
     388        return FALSE;
    384389    if ((iDst < 0) || (iDst >= himlDst->cCurImage))
    385         return FALSE;
     390        return FALSE;
    386391    if ((iSrc < 0) || (iSrc >= himlSrc->cCurImage))
    387         return FALSE;
     392        return FALSE;
    388393
    389394    hdcSrc = CreateCompatibleDC (0);
     
    401406                                       himlSrc->uBitsPixel, NULL);
    402407        hbmTempMask = CreateBitmap (himlSrc->cx, himlSrc->cy, 1,
    403                                       1, NULL);
     408                                      1, NULL);
    404409
    405410        /* copy (and stretch) destination to temporary bitmaps.(save) */
     
    494499HIMAGELIST WINAPI
    495500ImageList_Create (INT cx, INT cy, UINT flags,
    496                   INT cInitial, INT cGrow)
     501                  INT cInitial, INT cGrow)
    497502{
    498503    HIMAGELIST himl;
     
    500505    INT      nCount;
    501506    HBITMAP  hbmTemp;
    502     static WORD aBitBlend25[] = 
     507    static WORD aBitBlend25[] =
    503508        {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00};
    504509
     
    542547    if (himl->flags & ILC_MASK) {
    543548        himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
    544                                         1, 1, NULL);
     549                                        1, 1, NULL);
    545550        if (himl->hbmMask == 0) {
    546551//            ERR(imagelist, "Error creating mask bitmap!\n");
     
    567572
    568573/*************************************************************************
    569  * ImageList_Destroy [COMCTL32.45] 
     574 * ImageList_Destroy [COMCTL32.45]
    570575 *
    571576 * Destroys an image list.
     
    581586BOOL WINAPI
    582587ImageList_Destroy (HIMAGELIST himl)
    583 { 
     588{
    584589    if (!himl)
    585         return FALSE;
     590        return FALSE;
    586591
    587592    /* delete image bitmaps */
     
    596601    if (himl->hbrBlend50)
    597602        DeleteObject (himl->hbrBlend50);
    598        
     603
    599604    COMCTL32_Free (himl);
    600605
     
    604609
    605610/*************************************************************************
    606  * ImageList_DragEnter [COMCTL32.46] 
     611 * ImageList_DragEnter [COMCTL32.46]
    607612 *
    608613 * Locks window update and displays the drag image at the given position.
     
    626631{
    627632    if (himlInternalDrag == NULL)
    628         return FALSE;
     633        return FALSE;
    629634
    630635    if (hwndLock)
    631         hwndInternalDrag = hwndLock;
     636        hwndInternalDrag = hwndLock;
    632637    else
    633         hwndInternalDrag = GetDesktopWindow ();
     638        hwndInternalDrag = GetDesktopWindow ();
    634639
    635640    xInternalPos = x;
     
    638643    hdcBackBuffer = CreateCompatibleDC (0);
    639644    hbmBackBuffer = CreateCompatibleBitmap (hdcBackBuffer,
    640                 himlInternalDrag->cx, himlInternalDrag->cy);
     645                himlInternalDrag->cx, himlInternalDrag->cy);
    641646
    642647    ImageList_DragShowNolock (TRUE);
     
    647652
    648653/*************************************************************************
    649  * ImageList_DragLeave [COMCTL32.47] 
     654 * ImageList_DragLeave [COMCTL32.47]
    650655 *
    651656 * Unlocks window update and hides the drag image.
     
    663668{
    664669    if (hwndLock)
    665         hwndInternalDrag = hwndLock;
     670        hwndInternalDrag = hwndLock;
    666671    else
    667         hwndInternalDrag = GetDesktopWindow ();
     672        hwndInternalDrag = GetDesktopWindow ();
    668673
    669674    ImageList_DragShowNolock (FALSE);
     
    677682
    678683/*************************************************************************
    679  * ImageList_DragMove [COMCTL32.48] 
     684 * ImageList_DragMove [COMCTL32.48]
    680685 *
    681686 * Moves the drag image.
     
    709714
    710715/*************************************************************************
    711  * ImageList_DragShowNolock [COMCTL32.49] 
     716 * ImageList_DragShowNolock [COMCTL32.49]
    712717 *
    713718 * Shows or hides the drag image.
     
    733738
    734739    hdcDrag = GetDCEx (hwndInternalDrag, 0,
    735                         DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
     740                        DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
    736741
    737742    if (bShow) {
    738         /* show drag image */
    739 
    740         /* save background */
    741 
    742         /* draw drag image */
     743        /* show drag image */
     744
     745        /* save background */
     746
     747        /* draw drag image */
    743748
    744749    }
    745750    else {
    746         /* hide drag image */
    747 
    748         /* restore background */
     751        /* hide drag image */
     752
     753        /* restore background */
    749754
    750755    }
     
    780785BOOL WINAPI
    781786ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc,
    782                 INT x, INT y, UINT fStyle)
     787                INT x, INT y, UINT fStyle)
    783788{
    784789    IMAGELISTDRAWPARAMS imldp;
     
    833838BOOL WINAPI
    834839ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y,
    835                   INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg,
    836                   UINT fStyle)
     840                  INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg,
     841                  UINT fStyle)
    837842{
    838843    IMAGELISTDRAWPARAMS imldp;
     
    858863
    859864/*************************************************************************
    860  * ImageList_DrawIndirect [COMCTL32.52] 
     865 * ImageList_DrawIndirect [COMCTL32.52]
    861866 *
    862867 * Draws an image using ...
     
    888893
    889894    if (pimldp == NULL)
    890         return FALSE;
     895        return FALSE;
    891896    if (pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS))
    892         return FALSE;
     897        return FALSE;
    893898    if (pimldp->himl == NULL)
    894         return FALSE;
     899        return FALSE;
    895900    if ((pimldp->i < 0) || (pimldp->i > pimldp->himl->cCurImage))
    896         return FALSE;
     901        return FALSE;
    897902
    898903    himlLocal = pimldp->himl;
     
    914919        bMaskTrans = TRUE;
    915920    }
    916    
     921
    917922    /* ILD_IMAGE state (changes) */
    918923    if (pimldp->fStyle & ILD_IMAGE)
     
    922927        bImageTrans = FALSE;
    923928    }
    924    
     929
    925930    /* ILD_MASK state (changes) */
    926931    if ((pimldp->fStyle & ILD_MASK) && (himlLocal->hbmMask))
     
    947952    if (bMask)
    948953    {
    949         /* draw the mask */
    950         SelectObject (hdcImageList, himlLocal->hbmMask);
    951         SetBkColor (hdcImageList, RGB(255, 255, 255));
    952         SetTextColor (hdcImageList, RGB(0, 0, 0));
    953         BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    954                   hdcImageList, himlLocal->cx * pimldp->i, 0,
    955                   bMaskTrans ? SRCAND : SRCCOPY);
     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);
    956961    }
    957962
    958963    if (bImage)
    959964    {
    960         /* draw the image */
    961         SelectObject (hdcImageList, himlLocal->hbmImage);
     965        /* draw the image */
     966        SelectObject (hdcImageList, himlLocal->hbmImage);
    962967
    963968        if (!bImageTrans)
     
    993998            SelectObject (hdcImageList, himlLocal->hbmMask);
    994999            BitBlt (hdcTempImage, 0, 0, himlLocal->cx,
    995                       himlLocal->cy, hdcImageList, 
     1000                      himlLocal->cy, hdcImageList,
    9961001                      pimldp->i * himlLocal->cx, 0, SRCPAINT);
    9971002
    9981003            BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    999                       hdcTempImage, 0, 0, SRCAND);
     1004                      hdcTempImage, 0, 0, SRCAND);
    10001005
    10011006            /* fill */
     
    10111016            SelectObject (hdcImageList, himlLocal->hbmMask);
    10121017            BitBlt (hdcTempImage, 0, 0, himlLocal->cx,
    1013                       himlLocal->cy, hdcImageList, 
     1018                      himlLocal->cy, hdcImageList,
    10141019                      pimldp->i * himlLocal->cx, 0, SRCPAINT);
    10151020
     
    10201025            DeleteDC (hdcTempImage);
    10211026        }
    1022     }   
     1027    }
    10231028
    10241029    /* Draw overlay image */
    10251030    if (pimldp->fStyle & 0x0700) {
    1026         nOvlIdx = (pimldp->fStyle & 0x0700) >> 8;
    1027         if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) {
    1028             nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1];
    1029             if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage)) {
    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) {
    10311036                    SelectObject (hdcImageList, pimldp->himl->hbmMask);
    10321037                    BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    10331038                              hdcImageList, pimldp->himl->cx * nOvlIdx, 0,
    1034                               SRCAND);
    1035                 } 
     1039                              SRCAND);
     1040                }
    10361041                SelectObject (hdcImageList, pimldp->himl->hbmImage);
    10371042                BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y,
     
    10431048
    10441049    DeleteDC (hdcImageList);
    1045  
     1050
    10461051    return TRUE;
    10471052}
     
    11511156{
    11521157    if (himl == NULL)
    1153         return CLR_NONE;
     1158        return CLR_NONE;
    11541159
    11551160    return himl->clrBk;
     
    11871192
    11881193/*************************************************************************
    1189  * ImageList_GetIcon [COMCTL32.57] 
     1194 * ImageList_GetIcon [COMCTL32.57]
    11901195 *
    11911196 * Creates an icon from a masked image of an image list.
     
    12091214
    12101215    if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage))
    1211         return 0;
     1216        return 0;
    12121217
    12131218    hdcSrc = CreateCompatibleDC(0);
     
    12221227    SelectObject (hdcDst, ii.hbmMask);
    12231228    if (himl->hbmMask) {
    1224         SelectObject (hdcSrc, himl->hbmMask);
    1225         BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1226                   hdcSrc, i * himl->cx, 0, SRCCOPY);
     1229        SelectObject (hdcSrc, himl->hbmMask);
     1230        BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
     1231                  hdcSrc, i * himl->cx, 0, SRCCOPY);
    12271232    }
    12281233    else
    1229         PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
     1234        PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
    12301235
    12311236    /* draw image*/
     
    12331238    SelectObject (hdcSrc, himl->hbmImage);
    12341239    BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1235               hdcSrc, i * himl->cx, 0, SRCCOPY);
    1236 
    1237     hIcon = CreateIconIndirect (&ii);   
     1240              hdcSrc, i * himl->cx, 0, SRCCOPY);
     1241
     1242    hIcon = CreateIconIndirect (&ii);
    12381243
    12391244    DeleteDC (hdcSrc);
     
    12681273{
    12691274    if (himl == NULL)
    1270         return FALSE;
     1275        return FALSE;
    12711276    if ((himl->cx <= 0) || (himl->cy <= 0))
    1272         return FALSE;
     1277        return FALSE;
    12731278
    12741279    if (cx)
    1275         *cx = himl->cx;
     1280        *cx = himl->cx;
    12761281    if (cy)
    1277         *cy = himl->cy;
     1282        *cy = himl->cy;
    12781283
    12791284    return TRUE;
     
    12981303{
    12991304    if (himl == NULL)
    1300         return 0;
     1305        return 0;
    13011306
    13021307    return himl->cCurImage;
     
    13231328{
    13241329    if ((himl == NULL) || (pImageInfo == NULL))
    1325         return FALSE;
     1330        return FALSE;
    13261331    if ((i < 0) || (i >= himl->cCurImage))
    1327         return FALSE;
     1332        return FALSE;
    13281333
    13291334    pImageInfo->hbmImage = himl->hbmImage;
    13301335    pImageInfo->hbmMask  = himl->hbmMask;
    1331    
     1336
    13321337    pImageInfo->rcImage.top    = 0;
    13331338    pImageInfo->rcImage.bottom = himl->cy;
    13341339    pImageInfo->rcImage.left   = i * himl->cx;
    13351340    pImageInfo->rcImage.right  = (i+1) * himl->cx;
    1336    
     1341
    13371342    return TRUE;
    13381343}
     
    13401345
    13411346/*************************************************************************
    1342  * ImageList_GetImageRect [COMCTL32.61] 
     1347 * ImageList_GetImageRect [COMCTL32.61]
    13431348 *
    13441349 * Retrieves the rectangle of the specified image in an image list.
     
    13611366{
    13621367    if ((himl == NULL) || (lpRect == NULL))
    1363         return FALSE;
     1368        return FALSE;
    13641369    if ((i < 0) || (i >= himl->cCurImage))
    1365         return FALSE;
     1370        return FALSE;
    13661371
    13671372    lpRect->left   = i * himl->cx;
     
    13971402
    13981403HIMAGELIST WINAPI
    1399 ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx,       INT cGrow,
    1400                         COLORREF clrMask, UINT uType,   UINT uFlags)
     1404ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx,       INT cGrow,
     1405                        COLORREF clrMask, UINT uType,   UINT uFlags)
    14011406{
    14021407    HIMAGELIST himl = NULL;
     
    14131418        BITMAP bmp;
    14141419        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
    14151433        nImageCount = bmp.bmWidth / cx;
    14161434
     
    14251443        GetIconInfo (handle, &ii);
    14261444        GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp);
    1427         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
     1445        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
    14281446                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    14291447        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    14331451
    14341452    DeleteObject (handle);
    1435    
     1453
    14361454    return himl;
    14371455}
     
    14621480HIMAGELIST WINAPI
    14631481ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow,
    1464                         COLORREF clrMask, UINT uType,   UINT uFlags)
     1482                        COLORREF clrMask, UINT uType,   UINT uFlags)
    14651483{
    14661484    HIMAGELIST himl = NULL;
     
    14891507        GetIconInfo (handle, &ii);
    14901508        GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
    1491         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
     1509        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
    14921510                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    14931511        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    14971515
    14981516    DeleteObject (handle);
    1499    
     1517
    15001518    return himl;
    15011519}
     
    15031521
    15041522/*************************************************************************
    1505  * ImageList_Merge [COMCTL32.65] 
     1523 * ImageList_Merge [COMCTL32.65]
    15061524 *
    15071525 * Creates a new image list that contains a merged image from the specified
     
    15231541HIMAGELIST WINAPI
    15241542ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
    1525                 INT dx, INT dy)
     1543                INT dx, INT dy)
    15261544{
    15271545    HIMAGELIST himlDst = NULL;
     
    15321550
    15331551    if ((himl1 == NULL) || (himl2 == NULL))
    1534         return NULL;
     1552        return NULL;
    15351553
    15361554    /* check indices */
     
    15841602        nX1 = i1 * himl1->cx;
    15851603        nX2 = i2 * himl2->cx;
    1586        
     1604
    15871605        /* copy image */
    15881606        SelectObject (hdcSrcImage, himl1->hbmImage);
    15891607        SelectObject (hdcDstImage, himlDst->hbmImage);
    1590         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
     1608        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
    15911609                  hdcSrcImage, 0, 0, BLACKNESS);
    1592         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
     1610        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
    15931611                  hdcSrcImage, nX1, 0, SRCCOPY);
    15941612
    15951613        SelectObject (hdcSrcImage, himl2->hbmMask);
    1596         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1614        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    15971615                  hdcSrcImage, nX2, 0, SRCAND);
    15981616
    15991617        SelectObject (hdcSrcImage, himl2->hbmImage);
    1600         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1618        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    16011619                  hdcSrcImage, nX2, 0, SRCPAINT);
    16021620
     
    16041622        SelectObject (hdcSrcImage, himl1->hbmMask);
    16051623        SelectObject (hdcDstImage, himlDst->hbmMask);
    1606         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
     1624        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
    16071625                  hdcSrcImage, 0, 0, WHITENESS);
    1608         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
     1626        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
    16091627                  hdcSrcImage, nX1, 0, SRCCOPY);
    16101628
    16111629        SelectObject (hdcSrcImage, himl2->hbmMask);
    1612         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1630        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    16131631                  hdcSrcImage, nX2, 0, SRCAND);
    16141632
     
    16161634        DeleteDC (hdcDstImage);
    16171635    }
    1618    
     1636
    16191637    return himlDst;
    16201638}
     
    17111729//        TRACE(imagelist, " - Max. number of images: %d / %d (Old/New)\n",
    17121730//                 himl->cMaxImage, himl->cCurImage + himl->cGrow - 1);
    1713        
     1731
    17141732        hbmNewImage =
    17151733            CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL);
     
    17261744        if (i > 0) {
    17271745//            TRACE (imagelist, "Pre image copy: Copy %d images\n", i);
    1728        
     1746
    17291747            SelectObject (hdcSrc, himl->hbmImage);
    17301748            SelectObject (hdcDst, hbmNewImage);
     
    17771795
    17781796/*************************************************************************
    1779  * ImageList_Replace [COMCTL32.68] 
     1797 * ImageList_Replace [COMCTL32.68]
    17801798 *
    17811799 * Replaces an image in an image list with a new image.
     
    17941812BOOL WINAPI
    17951813ImageList_Replace (HIMAGELIST himl, INT i, HBITMAP hbmImage,
    1796                    HBITMAP hbmMask)
     1814                   HBITMAP hbmMask)
    17971815{
    17981816    HDC hdcImageList, hdcImage;
     
    18031821        return FALSE;
    18041822    }
    1805    
     1823
    18061824    if ((i >= himl->cCurImage) || (i < 0)) {
    18071825//        ERR (imagelist, "Invalid image index!\n");
     
    18641882
    18651883    if (himl == NULL)
    1866         return -1;
     1884        return -1;
    18671885    if ((i >= himl->cCurImage) || (i < -1))
    1868         return -1;
     1886        return -1;
    18691887
    18701888    GetIconInfo (hIcon, &ii);
    18711889//    if (ii.hbmMask == 0)
    1872 //      ERR (imagelist, "no mask!\n");
     1890//      ERR (imagelist, "no mask!\n");
    18731891//    if (ii.hbmColor == 0)
    1874 //      ERR (imagelist, "no color!\n");
     1892//      ERR (imagelist, "no color!\n");
    18751893    GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
    18761894
     
    18881906//    TRACE (imagelist, "hdcImageList=0x%x!\n", hdcImageList);
    18891907//    if (hdcImageList == 0)
    1890 //      ERR (imagelist, "invalid hdcImageList!\n");
     1908//      ERR (imagelist, "invalid hdcImageList!\n");
    18911909
    18921910    hdcImage = CreateCompatibleDC (0);
    18931911//    TRACE (imagelist, "hdcImage=0x%x!\n", hdcImage);
    18941912//    if (hdcImage == 0)
    1895 //      ERR (imagelist, "invalid hdcImage!\n");
     1913//      ERR (imagelist, "invalid hdcImage!\n");
    18961914
    18971915    hbmOldDst = SelectObject (hdcImageList, himl->hbmImage);
     
    19131931
    19141932    if (hdcImageList)
    1915         DeleteDC (hdcImageList);
     1933        DeleteDC (hdcImageList);
    19161934    if (hdcImage)
    1917         DeleteDC (hdcImage);
     1935        DeleteDC (hdcImage);
    19181936    if (ii.hbmColor)
    1919         DeleteObject (ii.hbmColor);
     1937        DeleteObject (ii.hbmColor);
    19201938    if (ii.hbmMask)
    1921         DeleteObject (ii.hbmMask);
     1939        DeleteObject (ii.hbmMask);
    19221940
    19231941    return nIndex;
     
    19261944
    19271945/*************************************************************************
    1928  * ImageList_SetBkColor [COMCTL32.70] 
     1946 * ImageList_SetBkColor [COMCTL32.70]
    19291947 *
    19301948 * Sets the background color of an image list.
     
    19451963
    19461964    if (himl == NULL)
    1947         return CLR_NONE;
     1965        return CLR_NONE;
    19481966
    19491967    clrOldBk = himl->clrBk;
     
    19741992BOOL WINAPI
    19751993ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag,
    1976                               INT dxHotspot, INT dyHotspot)
     1994                              INT dxHotspot, INT dyHotspot)
    19771995{
    19781996    HIMAGELIST himlTemp;
     
    19811999
    19822000    if (himlInternalDrag == NULL)
    1983         return FALSE;
     2001        return FALSE;
    19842002
    19852003//    TRACE (imagelist, " dxH=%d dyH=%d nX=%d nY=%d\n",
    1986 //         dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY);
     2004//         dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY);
    19872005
    19882006    himlTemp = ImageList_Merge (himlInternalDrag, 0, himlDrag, iDrag,
    1989                                 dxHotspot, dyHotspot);
     2007                                dxHotspot, dyHotspot);
    19902008
    19912009    ImageList_Destroy (himlInternalDrag);
     
    20002018
    20012019/*************************************************************************
    2002  * ImageList_SetFilter [COMCTL32.76] 
     2020 * ImageList_SetFilter [COMCTL32.76]
    20032021 *
    20042022 * Sets a filter (or does something completely different)!!???
     
    20222040{
    20232041//    FIXME (imagelist, "(%p 0x%x 0x%lx):empty stub!\n",
    2024 //         himl, i, dwFilter);
     2042//         himl, i, dwFilter);
    20252043
    20262044    return FALSE;
     
    20492067
    20502068    if (!himl)
    2051         return FALSE;
     2069        return FALSE;
    20522070
    20532071    /* remove all images*/
     
    20992117
    21002118    if (!himl)
    2101         return FALSE;
     2119        return FALSE;
    21022120    if (himl->cCurImage >= iImageCount)
    2103         return FALSE;
     2121        return FALSE;
    21042122    if (himl->cMaxImage > iImageCount)
    2105         return TRUE;
     2123        return TRUE;
    21062124
    21072125    nNewCount = iImageCount + himl->cGrow;
     
    21182136        SelectObject (hdcBitmap, hbmNewBitmap);
    21192137
    2120         /* copy images */
     2138        /* copy images */
    21212139        BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy,
    21222140                  hdcImageList, 0, 0, SRCCOPY);
    21232141
    2124         /* delete 'empty' image space */
    2125         SetBkColor (hdcBitmap, RGB(255, 255, 255));
    2126         SetTextColor (hdcBitmap, RGB(0, 0, 0));
    2127         PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
    2128                   (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    2129 
    2130         DeleteObject (himl->hbmImage);
    2131         himl->hbmImage = hbmNewBitmap;
     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;
    21322150    }
    21332151//    else
    2134 //      ERR (imagelist, "Could not create new image bitmap !\n");
     2152//      ERR (imagelist, "Could not create new image bitmap !\n");
    21352153
    21362154    if (himl->hbmMask)
     
    21432161            SelectObject (hdcBitmap, hbmNewBitmap);
    21442162
    2145             /* copy images */
     2163            /* copy images */
    21462164            BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy,
    21472165                      hdcImageList, 0, 0, SRCCOPY);
    21482166
    2149             /* delete 'empty' image space */
    2150             SetBkColor (hdcBitmap, RGB(255, 255, 255));
    2151             SetTextColor (hdcBitmap, RGB(0, 0, 0));
    2152             PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0, 
    2153                       (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
     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);
    21542172
    21552173            DeleteObject (himl->hbmMask);
     
    21912209{
    21922210    if (!himl)
    2193         return FALSE;
     2211        return FALSE;
    21942212    if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE))
    2195         return FALSE;
     2213        return FALSE;
    21962214    if ((iImage < 0) || (iImage > himl->cCurImage))
    2197         return FALSE;
    2198    
     2215        return FALSE;
     2216
    21992217    himl->nOvlIdx[iOverlay - 1] = iImage;
    22002218    return TRUE;
     
    22272245//{
    22282246//    if (!himl)
    2229 //      return FALSE;
     2247//      return FALSE;
    22302248//
    22312249//    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 achimha Exp $ */
     1/* $Id: ipaddress.c,v 1.6 1999-07-12 15:58:47 cbratschi Exp $ */
    22/*
    33 * IP Address control
    44 *
     5 * Copyright 1999 Chris Morgan<cmorgan@wpi.edu> and
     6 *                James Abbatiello<abbeyj@wpi.edu>
    57 * Copyright 1998, 1999 Eric Kohl
    68 * Copyright 1998 Alex Priem <alexp@sci.kun.nl>
     
    810 *
    911 * NOTES
    10 
    1112 *
    1213 * TODO:
    1314 *    -Check ranges when changing field-focus.
    14  *        -Check all notifications/behavior.
     15 *        -Check all notifications/behavior.
    1516 *    -Optimization: include lpipsi in IPADDRESS_INFO.
    16  *        -CurrentFocus: field that has focus at moment of processing.
    17  *        -connect Rect32 rcClient.
    18  *        -handle right and left arrows correctly. Boring.
    19  *        -split GotoNextField in CheckField and GotoNextField.
    20  *        -check ipaddress.cpp for missing features.
     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.
    2122 *    -refresh: draw '.' instead of setpixel.
    22  *        -handle VK_ESCAPE.
     23 *        -handle VK_ESCAPE.
    2324 */
    2425
     
    3637
    3738
    38 static BOOL 
     39static BOOL
    3940IPADDRESS_SendNotify (HWND hwnd, UINT command);
    40 static BOOL 
     41static BOOL
    4142IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue);
    4243
     
    5556IPADDRESS_Refresh (HWND hwnd, HDC hdc)
    5657{
    57         RECT rcClient;
    58         HBRUSH hbr;
    59         COLORREF clr=GetSysColor (COLOR_3DDKSHADOW);
     58        RECT rcClient;
     59        HBRUSH hbr;
     60        COLORREF clr=GetSysColor (COLOR_3DDKSHADOW);
    6061    int i,x,fieldsize;
    6162
    6263    GetClientRect (hwnd, &rcClient);
    63         hbr =  CreateSolidBrush (RGB(255,255,255));
     64        hbr =  CreateSolidBrush (RGB(255,255,255));
    6465    DrawEdge (hdc, &rcClient, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
    65         FillRect (hdc, &rcClient, hbr);
     66        FillRect (hdc, &rcClient, hbr);
    6667    DeleteObject (hbr);
    6768
    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}
    8480
    8581
     
    8884{
    8985    IPADDRESS_INFO *infoPtr;
    90         RECT rcClient, edit;
    91         int i,fieldsize;
    92         LPIP_SUBCLASS_INFO lpipsi;
    93        
     86        RECT rcClient, edit;
     87        int i,fieldsize;
     88        LPIP_SUBCLASS_INFO lpipsi;
     89
    9490
    9591    infoPtr = (IPADDRESS_INFO *)COMCTL32_Alloc (sizeof(IPADDRESS_INFO));
     
    9894    GetClientRect (hwnd, &rcClient);
    9995
    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;
    135129
    136130    return 0;
     
    141135IPADDRESS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
    142136{
    143         int i;
     137        int i;
    144138    IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd);
    145         LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
     139        LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
    146140            GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP);
    147141
    148         for (i=0; i<=3; i++) {
    149                 SetWindowLongA ((HWND)lpipsi->hwndIP[i], GWL_WNDPROC,
     142        for (i=0; i<=3; i++) {
     143                SetWindowLongA ((HWND)lpipsi->hwndIP[i], GWL_WNDPROC,
    150144                  (LONG)lpipsi->wpOrigProc[i]);
    151         }
     145        }
    152146
    153147    COMCTL32_Free (infoPtr);
     
    161155    HDC hdc;
    162156
    163 //      TRACE (ipaddress,"\n");
     157//      TRACE (ipaddress,"\n");
    164158    hdc = GetDC (hwnd);
    165159    IPADDRESS_Refresh (hwnd, hdc);
     
    167161
    168162    IPADDRESS_SendIPAddressNotify (hwnd, 0, 0);  /* FIXME: should use -1 */
    169     IPADDRESS_SendNotify (hwnd, EN_KILLFOCUS);       
     163    IPADDRESS_SendNotify (hwnd, EN_KILLFOCUS);
    170164    InvalidateRect (hwnd, NULL, TRUE);
    171165
     
    183177    IPADDRESS_Refresh (hwnd, hdc);
    184178    if(!wParam)
    185         EndPaint (hwnd, &ps);
     179        EndPaint (hwnd, &ps);
    186180    return 0;
    187181}
     
    193187    HDC hdc;
    194188
    195 //      TRACE (ipaddress,"\n");
     189//      TRACE (ipaddress,"\n");
    196190
    197191    hdc = GetDC (hwnd);
     
    207201{
    208202    /* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */
    209 //      TRACE (ipaddress,"\n");
     203//      TRACE (ipaddress,"\n");
    210204    return 0;
    211205}
     
    225219IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue)
    226220{
    227         NMIPADDRESS nmip;
     221        NMIPADDRESS nmip;
    228222
    229223//    TRACE (ipaddress, "%x %x\n",field,newValue);
     
    232226    nmip.hdr.code     = IPN_FIELDCHANGED;
    233227
    234         nmip.iField=field;
    235         nmip.iValue=newValue;
     228        nmip.iField=field;
     229        nmip.iValue=newValue;
    236230
    237231    return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
     
    245239IPADDRESS_ClearAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
    246240{
    247         int i;
    248         HDC hdc;
    249         char buf[1];
    250         LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
     241        int i;
     242        HDC hdc;
     243        char buf[1];
     244        LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
    251245            GetPropA ((HWND)hwnd,IP_SUBCLASS_PROP);
    252246
    253 //      TRACE (ipaddress,"\n");
    254 
    255         buf[0]=0;
    256         for (i=0; i<=3; i++)
    257                 SetWindowTextA (lpipsi->hwndIP[i],buf);
    258        
     247//      TRACE (ipaddress,"\n");
     248
     249        buf[0]=0;
     250        for (i=0; i<=3; i++)
     251                SetWindowTextA (lpipsi->hwndIP[i],buf);
     252
    259253    hdc = GetDC (hwnd);
    260254    IPADDRESS_Refresh (hwnd, hdc);
    261255    ReleaseDC (hwnd, hdc);
    262        
    263         return 0;
     256
     257        return 0;
    264258}
    265259
     
    275269
    276270 for (i=0; i<=3; i++) {
    277                 GetWindowTextA (lpipsi->hwndIP[i],buf,5);
    278         if (buf[0])
    279             return 0;
    280         }
     271                GetWindowTextA (lpipsi->hwndIP[i],buf,5);
     272        if (buf[0])
     273            return 0;
     274        }
    281275
    282276 return 1;
     
    298292 ip_addr=0;
    299293 for (i=0; i<=3; i++) {
    300                 GetWindowTextA (lpipsi->hwndIP[i],field,4);
    301                 ip_addr*=256;
    302                 if (field[0]) {
    303                         field[3]=0;
    304                         fieldvalue=atoi(field);
    305                         if (fieldvalue<infoPtr->LowerLimit[i])
    306                                 fieldvalue=infoPtr->LowerLimit[i];
    307                         if (fieldvalue>infoPtr->UpperLimit[i])
    308                                 fieldvalue=infoPtr->UpperLimit[i];
    309                         ip_addr+=fieldvalue;
    310                         valid++;
    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                }
    312306 }
    313307
     
    322316{
    323317    IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd);
    324         INT index;
    325        
    326 //      TRACE (ipaddress,"\n");
    327 
    328         index=(INT) wParam;
    329         if ((index<0) || (index>3)) return 0;
    330 
    331         infoPtr->LowerLimit[index]=lParam & 0xff;
    332         infoPtr->UpperLimit[index]=(lParam >>8)  & 0xff;
    333         return 1;
     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;
    334328}
    335329
     
    338332{
    339333    IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd);
    340         HDC hdc;
    341         LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
     334        HDC hdc;
     335        LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
    342336            GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP);
    343         int i,ip_address,value;
     337        int i,ip_address,value;
    344338    char buf[20];
    345339
    346 //      TRACE (ipaddress,"\n");
    347         ip_address=(DWORD) lParam;
    348 
    349         for (i=3; i>=0; i--) {
    350                 value=ip_address & 0xff;
    351                 if ((value>=infoPtr->LowerLimit[i]) && (value<=infoPtr->UpperLimit[i]))
    352                         {
    353                         sprintf (buf,"%d",value);
    354                         SetWindowTextA (lpipsi->hwndIP[i],buf);
    355                         IPADDRESS_SendNotify (hwnd, EN_CHANGE);
    356                 }
    357                 ip_address/=256;
    358         }
    359 
    360     hdc = GetDC (hwnd);         /* & send notifications */
     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 */
    361355    IPADDRESS_Refresh (hwnd, hdc);
    362356    ReleaseDC (hwnd, hdc);
     
    372366{
    373367    /* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */
    374         LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
    375             GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP);
    376         INT index;
    377 
    378         index=(INT) wParam;
    379 //      TRACE (ipaddress," %d\n", index);
    380         if ((index<0) || (index>3)) return 0;
    381        
    382         SetFocus (lpipsi->hwndIP[index]);
    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
    384378    return 1;
    385379}
     
    391385//    TRACE (ipaddress, "\n");
    392386
    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
     394static INT
     395IPADDRESS_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
     429static INT
    412430IPADDRESS_GotoNextField (LPIP_SUBCLASS_INFO lpipsi, int currentfield)
    413431{
    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
    439479
    440480
     
    442482IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    443483{
    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);
    498597}
    499598
     
    503602    switch (uMsg)
    504603    {
    505         case IPM_CLEARADDRESS:
    506                 return IPADDRESS_ClearAddress (hwnd, wParam, lParam);
    507 
    508         case IPM_SETADDRESS:
    509             return IPADDRESS_SetAddress (hwnd, wParam, lParam);
    510 
    511         case IPM_GETADDRESS:
    512             return IPADDRESS_GetAddress (hwnd, wParam, lParam);
    513 
    514         case IPM_SETRANGE:
    515             return IPADDRESS_SetRange (hwnd, wParam, lParam);
    516 
    517         case IPM_SETFOCUS:
    518             return IPADDRESS_SetFocusToField (hwnd, wParam, lParam);
    519 
    520         case IPM_ISBLANK:
    521                 return IPADDRESS_IsBlank (hwnd, wParam, lParam);
    522 
    523         case WM_CREATE:
    524             return IPADDRESS_Create (hwnd, wParam, lParam);
    525 
    526         case WM_DESTROY:
    527             return IPADDRESS_Destroy (hwnd, wParam, lParam);
    528 
    529         case WM_GETDLGCODE:
    530             return DLGC_WANTARROWS | DLGC_WANTCHARS;
    531 
    532         case WM_KILLFOCUS:
    533             return IPADDRESS_KillFocus (hwnd, wParam, lParam);
    534 
    535         case WM_LBUTTONDOWN:
     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:
    536635        return IPADDRESS_LButtonDown (hwnd, wParam, lParam);
    537636
    538         case WM_PAINT:
    539             return IPADDRESS_Paint (hwnd, wParam);
    540 
    541         case WM_SETFOCUS:
    542             return IPADDRESS_SetFocus (hwnd, wParam, lParam);
    543 
    544         case WM_SIZE:
    545             return IPADDRESS_Size (hwnd, wParam, lParam);
    546 
    547         default:
    548 //          if (uMsg >= WM_USER)
    549 //              ERR (ipaddress, "unknown msg %04x wp=%08x lp=%08lx\n",
    550 //                   uMsg, wParam, lParam);
    551             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     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);
    552651    }
    553652    return 0;
     
    570669    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    571670    wndClass.lpszClassName = WC_IPADDRESSA;
    572  
     671
    573672    RegisterClassA (&wndClass);
    574673}
  • trunk/src/comctl32/listview.c

    r252 r295  
    33923392              if (dispInfo.item.mask & LVIF_DI_SETITEM)
    33933393              {
    3394                 Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText);
     3394                if (lpSubItem)
     3395                   Str_SetPtrA(&lpSubItem->pszText, dispInfo.item.pszText);
    33953396              }
    33963397              lpLVItem->pszText = dispInfo.item.pszText;
     
    33983399            else if (lpLVItem->mask & LVIF_TEXT)
    33993400            {
    3400               lpLVItem->pszText = lpItem->pszText;
     3401              lpLVItem->pszText = lpSubItem->pszText;
    34013402            }
    34023403          }
     
    39893990        lvFindInfo.vkDirection = VK_UP;
    39903991        ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt);
    3991         while ((nItem = LISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
     3992        while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
    39923993        {
    39933994          if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask)
     
    40124013        lvFindInfo.vkDirection = VK_DOWN;
    40134014        ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt);
    4014         while ((nItem = LISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
     4015        while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
    40154016        {
    40164017          if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask)
     
    40364037        lvFindInfo.vkDirection = VK_LEFT;
    40374038        ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt);
    4038         while ((nItem = LISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
     4039        while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
    40394040        {
    40404041          if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask)
     
    40604061        lvFindInfo.vkDirection = VK_RIGHT;
    40614062        ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt);
    4062         while ((nItem = LISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
     4063        while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
    40634064        {
    40644065          if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask)
     
    46674668  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    46684669  BOOL bResult = FALSE;
    4669   HDITEMA hdi;
     4670  HDITEMA hdi, hdiget;
    46704671
    46714672  if ((lpColumn != NULL) && (nColumn >= 0) &&
     
    46794680      /* format member is valid */
    46804681      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;
    46814688
    46824689      /* set text alignment (leftmost column must be left-aligned) */
     
    52445251
    52455252  /* create header */
    5246 
    52475253  infoPtr->hwndHeader = CreateWindowA(WC_HEADERA, (LPCSTR)NULL,
    52485254                                      WS_CHILD | HDS_HORZ | HDS_BUTTONS,
     
    56235629
    56245630  case VK_LEFT:
    5625     nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TOLEFT);
     5631    nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TOLEFT);
    56265632    break;
    56275633
    56285634  case VK_UP:
    5629     nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_ABOVE);
     5635    nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_ABOVE);
    56305636    break;
    56315637
    56325638  case VK_RIGHT:
    5633     nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TORIGHT);
     5639    nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TORIGHT);
    56345640    break;
    56355641
    56365642  case VK_DOWN:
    5637     nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_BELOW);
     5643    nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_BELOW);
    56385644    break;
    56395645
  • trunk/src/comctl32/propsheet.c

    r267 r295  
    1 /* $Id: propsheet.c,v 1.5 1999-07-04 21:05:59 cbratschi Exp $ */
     1/* $Id: propsheet.c,v 1.6 1999-07-12 15:58:48 cbratschi Exp $ */
    22/*
    33 * Property Sheets
     
    791791  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
    792792                                                    PropSheetInfoStr);
    793 
     793  if (!psInfo) return;
    794794  /*
    795795   * 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:17 cbratschi Exp $ */
     1/* $Id: rebar.c,v 1.7 1999-07-12 15:58:48 cbratschi Exp $ */
    22/*
    33 * Rebar control
     
    431431#if 0
    432432            else if (!lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
     433                INT nEditHeight, yPos;
     434                RECT rc;
     435                HWND hwndEdit;
     436
    433437                /* special placement code for extended combo box */
    434438
     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);
    435451
    436452            }
  • trunk/src/comctl32/status.c

    r267 r295  
    1 /* $Id: status.c,v 1.8 1999-07-04 21:05:59 cbratschi Exp $ */
     1/* $Id: status.c,v 1.9 1999-07-12 15:58:48 cbratschi Exp $ */
    22/*
    33 * Interface code to StatusWindow widget/control
     
    665665    if (style & SBT_OWNERDRAW)
    666666    {
     667      if (!(part->style & SBT_OWNERDRAW) && part->text) COMCTL32_Free(part->text);
    667668      part->text = (LPWSTR)text;
    668669    } else
     
    720721    if (style & SBT_OWNERDRAW)
    721722    {
     723      if (!(part->style & SBT_OWNERDRAW) && part->text) COMCTL32_Free(part->text);
    722724      part->text = text;
    723725    } else
    724726    {
     727      //compare
    725728      if (lstrcmpW(part->text,text) == 0)
    726729      {
  • trunk/src/comctl32/tab.c

    r267 r295  
    1 /* $Id: tab.c,v 1.8 1999-07-04 21:05:59 cbratschi Exp $ */
     1/* $Id: tab.c,v 1.9 1999-07-12 15:58:48 cbratschi Exp $ */
    22/*
    33 * Tab control
     
    398398  pt.y = (INT)HIWORD(lParam);
    399399
    400   newItem=TAB_InternalHitTest (hwnd, infoPtr,pt,(unsigned int*)&dummy);
     400  newItem=TAB_InternalHitTest (hwnd, infoPtr,pt,&dummy);
    401401
    402402//  TRACE(tab, "On Tab, item %d\n", newItem);
  • trunk/src/comctl32/toolbar.c

    r285 r295  
    1 /* $Id: toolbar.c,v 1.10 1999-07-07 17:08:42 cbratschi Exp $ */
     1/* $Id: toolbar.c,v 1.11 1999-07-12 15:58:49 cbratschi Exp $ */
    22/*
    33 * Toolbar control
     
    1616 *   - Internal COMMCTL32 bitmaps.
    1717 *   - Fix TOOLBAR_SetButtonInfo32A.
    18  *   - Customize dialog (CB: under construction).
    1918 *   - Drag & drop of buttons
    2019 *
     
    3029
    3130/* 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
    3333*/
    3434
     
    132132    HDC hdcImageList = CreateCompatibleDC (0);
    133133    HDC hdcMask = CreateCompatibleDC (0);
    134     HIMAGELIST himl = infoPtr->himlStd;
     134    HIMAGELIST himl = infoPtr->himlDef;
    135135    HBITMAP hbmMask;
    136136
     
    182182    {
    183183      if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0))
    184           TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
     184          TOOLBAR_DrawFlatSeparator (&rc, hdc);
    185185      return;
    186186    }
     
    189189    if (!(btnPtr->fsState & TBSTATE_ENABLED))
    190190    {
    191       DrawEdge (hdc, &rc, EDGE_RAISED,
     191      if (!(dwStyle & TBSTYLE_FLAT))
     192        DrawEdge (hdc, &rc, EDGE_RAISED,
    192193                  BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    193194
    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
    202199        TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
    203200
     
    210207    {
    211208      DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    212       ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     209      ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    213210                      rc.left+2, rc.top+2, ILD_NORMAL);
    214211      TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
     
    227224
    228225        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
    240230        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
    241231        return;
     
    254244    }
    255245
     246    /* normal state */
    256247    if (dwStyle & TBSTYLE_FLAT)
    257248    {
     
    260251                     BF_RECT | BF_MIDDLE | BF_SOFT);
    261252
    262       if(infoPtr->himlDef != NULL)
    263           ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     253      if(btnPtr->bHot && infoPtr->himlHot)
     254          ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
    264255                          rc.left +2, rc.top +2, ILD_NORMAL);
    265256      else
    266           ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     257          ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    267258                          rc.left +2, rc.top +2, ILD_NORMAL);
    268259    } else
    269260    {
    270       /* normal state */
    271261      DrawEdge (hdc, &rc, EDGE_RAISED,
    272262                BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    273263
    274       ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     264      ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    275265                      rc.left+1, rc.top+1, ILD_NORMAL);
    276266    }
     
    831821}
    832822
     823static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd);
     824static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd);
     825
     826static 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
    833924static BOOL TBCUSTOMIZE_InitDialog(HWND hwnd,WPARAM wParam,LPARAM lParam)
    834925{
     
    836927
    837928  infoPtr = (TOOLBAR_INFO*)lParam;
    838   SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
     929  SetWindowLongA(hwnd,DWL_USER,(DWORD)infoPtr);
    839930
    840931  if (infoPtr)
    841932  {
    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++)
    856937    {
    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
     954static BOOL TBCUSTOMIZE_Close(HWND hwnd,WPARAM wParam,LPARAM lParam)
     955{
     956  EndDialog(hwnd,FALSE);
     957
     958  return TRUE;
     959}
     960
     961static 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
     991static 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
     1004static 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)
    8601092      {
    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));
    8861096      } else
    8871097      {
    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));
    9121101      }
    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
     1113static 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)
    9151203      {
    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        }
    9241219      }
    9251220    }
    926 
    927     if (leftCount == 0 && rightCount == 0)
    928     {
    929       EndDialog(hwnd,FALSE);
    930 
    931       return TRUE;
    932     }
    9331221  }
    9341222
    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);
    9591229}
    9601230
     
    9741244static VOID TBCUSTOMIZE_MoveToolUp(HWND hwnd)
    9751245{
    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);
    9771278}
    9781279
    9791280static VOID TBCUSTOMIZE_MoveToolDown(HWND hwnd)
    9801281{
    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
     1319static 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
     1330static 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  }
    9821359}
    9831360
     
    10071384      TBCUSTOMIZE_MoveToolDown(hwnd);
    10081385      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;
    10091408  }
    10101409
     
    10171416  INT x;
    10181417
    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;
    10261423
    10271424  return TRUE;
     
    10401437    COLORREF oldText = 0;
    10411438    COLORREF oldBk = 0;
     1439    INT customID;
    10421440    TBUTTON_INFO* btnPtr;
    10431441    DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE);
    10441442
    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)
    10511447    {
    10521448      if (lpdis->itemState & ODS_FOCUS) oldBk = SetBkColor(lpdis->hDC,GetSysColor(COLOR_HIGHLIGHT));
     
    10751471    if (lpdis->itemState & ODS_FOCUS) DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
    10761472
    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))
    10811475    {
     1476      //draw button
    10821477      if (dwStyle & TBSTYLE_FLAT)
    10831478      {
    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);
    10901480      } else
    10911481      {
    1092         /* normal state */
    1093         ImageList_Draw(infoPtr->himlStd,btnPtr->iBitmap,lpdis->hDC,
    1094                        rcButton.left+1,rcButton.top+1,ILD_NORMAL);
     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);
    10951485      }
     1486
    10961487    } else
    10971488    { //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);
    10991493    }
    11001494
     
    11301524    MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
    11311525
    1132     infoPtr = (TOOLBAR_INFO *)GetWindowLongA(hwnd,DWL_USER);
    1133 
    11341526    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;
    11381535
    11391536    return TRUE;
     
    11871584    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    11881585    LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
    1189     INT nIndex = 0;
    1190 
    1191     if ((!lpAddBmp) || ((INT)wParam <= 0))
     1586    INT nIndex = 0,nButtons;
     1587
     1588    if (!lpAddBmp)
    11921589        return -1;
    11931590
    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);
    12011603
    12021604        /* 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)
    12051606        {
    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));
    12241612        }
    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 =
    12271638            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    {
    12331646        nIndex =
    1234             ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID,
     1647            ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
    12351648                                 CLR_DEFAULT);
    12361649    }
    1237     else if (lpAddBmp->hInst == HINST_COMMCTRL) {
     1650    else if (lpAddBmp->hInst == HINST_COMMCTRL)
     1651    {
    12381652        /* 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");
    12421654
    12431655        /* Hack to "add" some reserved images within the image list
    12441656           to get the right image indices */
    1245         nIndex = ImageList_GetImageCount (infoPtr->himlStd);
    1246         ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam);
    1247 
    1248     }
    1249     else {
     1657        nIndex = ImageList_GetImageCount (infoPtr->himlDef);
     1658        ImageList_SetImageCount (infoPtr->himlDef, nIndex + nButtons);
     1659    }
     1660    else
     1661    {
    12501662        HBITMAP hBmp =
    12511663            LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
    1252         nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT);
     1664        nIndex = ImageList_AddMasked (infoPtr->himlDef, hBmp, CLR_DEFAULT);
    12531665
    12541666        DeleteObject (hBmp);
    12551667    }
    12561668
    1257     infoPtr->nNumBitmaps += (INT)wParam;
     1669    infoPtr->nNumBitmaps += nButtons;
    12581670
    12591671    return nIndex;
     
    16322044    HRSRC hRes;
    16332045    NMHDR nmhdr;
     2046
     2047    if (infoPtr->nNumButtons == 0) return 0;
    16342048
    16352049    /* send TBN_BEGINADJUST notification */
     
    19662380    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    19672381
    1968     if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
    1969         return (LRESULT)infoPtr->himlDis;
    1970     else
    1971         return 0;
     2382    return (LRESULT)infoPtr->himlDis;
    19722383}
    19732384
     
    19872398    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    19882399
    1989     if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
    1990         return (LRESULT)infoPtr->himlHot;
    1991     else
    1992         return 0;
     2400    return (LRESULT)infoPtr->himlHot;
    19932401}
    19942402
     
    20022410    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    20032411
    2004     if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
    2005         return (LRESULT)infoPtr->himlDef;
    2006     else
    2007         return 0;
     2412    return (LRESULT)infoPtr->himlDef;
    20082413}
    20092414
     
    26543059    HIMAGELIST himlTemp;
    26553060
    2656     if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2657         return 0;
    2658 
    26593061    himlTemp = infoPtr->himlDis;
    26603062    infoPtr->himlDis = (HIMAGELIST)lParam;
     
    26993101    HIMAGELIST himlTemp;
    27003102
    2701     if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2702         return 0;
    2703 
    27043103    himlTemp = infoPtr->himlHot;
    27053104    infoPtr->himlHot = (HIMAGELIST)lParam;
     
    27193118    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    27203119    HIMAGELIST himlTemp;
    2721 
    2722     if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2723         return 0;
    27243120
    27253121    himlTemp = infoPtr->himlDef;
     
    29333329    infoPtr->dwDTFlags = DT_CENTER;
    29343330
    2935     infoPtr->hDsa        = NULL;
    29363331    infoPtr->hwndToolbar = hwnd;
     3332    infoPtr->oldButtons = NULL;
     3333    infoPtr->nNumOldButtons = 0;
    29373334
    29383335    SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
     
    29943391    }
    29953392
    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);
    30073396
    30083397    /* delete default font */
     
    31923581      {
    31933582        oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
    3194         if (oldBtnPtr->bHot)
     3583        if (oldBtnPtr->bHot) //CB: dynamic buttons
    31953584        {
    31963585          oldBtnPtr->bHot = FALSE;
  • trunk/src/comctl32/tooltips.c

    r285 r295  
    1 /* $Id: tooltips.c,v 1.11 1999-07-07 17:08:43 cbratschi Exp $ */
     1/* $Id: tooltips.c,v 1.12 1999-07-12 15:58:49 cbratschi Exp $ */
    22/*
    33 * Tool tip control
     
    11331133    if (nTool == -1) return 0;
    11341134
    1135     TOOLTIPS_GetTipText(hwnd,infoPtr,nTool);
     1135    TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); //CB: get text
    11361136
    11371137    lstrcpyWtoA(lpToolInfo->lpszText,infoPtr->szTipText);
     
    11561156    if (nTool == -1) return 0;
    11571157
    1158     TOOLTIPS_GetTipText(hwnd,infoPtr,nTool);
     1158    TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); //CB: get text
    11591159
    11601160    lstrcpyW(lpToolInfo->lpszText,infoPtr->szTipText);
     
    19791979}
    19801980
     1981static LRESULT
     1982TOOLTIPS_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}
    19811988
    19821989static LRESULT
     
    20202027 * returns the length, in characters, of the tip text
    20212028 ******************************************************************/
     2029
    20222030static LRESULT
    20232031TOOLTIPS_OnWMGetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    23212329            return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
    23222330
    2323 /*      case WM_NOTIFYFORMAT: */
    2324 /*          return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); */
     2331        case WM_NOTIFYFORMAT:
     2332            return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam);
    23252333
    23262334        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 $ */
    22/* Treeview control
    33 *
     
    4242 */
    4343
     44/* CB: todo
     45 - fix ffs();
     46*/
    4447
    4548#include <string.h>
     
    12681271 * This method does the chaining of the insertion of a treeview item
    12691272 * before an item.
     1273 * If parent is NULL, we're inserting at the root of the list.
    12701274 */
    12711275static void TREEVIEW_InsertBefore(
     
    13051309      upSibling->sibling = newItem->hItem;
    13061310    else
     1311    if (parent)
    13071312      /* this item is the first child of this parent, adjust parent pointers */
    13081313      parent->firstChild = newItem->hItem;
     1314    else infoPtr->TopRootItem = newItem->hItem;
    13091315  }
    13101316  else /* Insert as first child of this parent */
     1317  if (parent)
    13111318    parent->firstChild = newItem->hItem;
    13121319}
     
    13141321/***************************************************************************
    13151322 * 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.
    13161324 * after an item.
    13171325 */
     
    13571365  }
    13581366  else /* Insert as first child of this parent */
     1367  if (parent)
    13591368    parent->firstChild = newItem->hItem;
    13601369}
     
    13901399  /* Obtain the TVSORTBC struct */
    13911400  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  }
    13921408
    13931409  /* Obtain the parent node to sort */
     
    16271643      else
    16281644      {
    1629         TREEVIEW_ITEM *aChild        =
    1630           &infoPtr->items[(INT)parentItem->firstChild];
     1645        TREEVIEW_ITEM *aChild;
    16311646
    16321647        TREEVIEW_ITEM *previousChild = NULL;
    16331648        BOOL bItemInserted           = FALSE;
     1649
     1650        if (parentItem)
     1651          aChild = &infoPtr->items[(INT)parentItem->firstChild];
     1652        else
     1653          aChild = &infoPtr->items[(INT)infoPtr->TopRootItem];
    16341654
    16351655        /* 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:46 cbratschi Exp $ */
     1/* $Id: updown.c,v 1.6 1999-07-12 15:58:51 cbratschi Exp $ */
    22/*
    33 * Updown control
     
    195195
    196196  /*if the buddy is a list window, we must set curr index */
    197   if (!lstrcmpA(infoPtr->szBuddyClass,"ListBox"))
     197  if (!lstrcmpiA(infoPtr->szBuddyClass,"ListBox"))
    198198  {
    199199    newVal = SendMessageA(infoPtr->Buddy,LB_GETCARETINDEX,0,0);
     
    245245
    246246  /*if the buddy is a list window, we must set curr index */
    247   if(!lstrcmpA(infoPtr->szBuddyClass, "ListBox"))
     247  if(!lstrcmpiA(infoPtr->szBuddyClass, "ListBox"))
    248248  {
    249249    SendMessageA(infoPtr->Buddy,LB_SETCURSEL,infoPtr->CurVal,0);
     
    365365    return FALSE;
    366366
     367  /* Store buddy wundow handle */
     368  infoPtr->Buddy = hwndBud;
     369
    367370  /* Store buddy window clas name */
    368371  GetClassNameA (hwndBud, infoPtr->szBuddyClass, 40);
     
    529532
    530533      /* If the buddy is an edit, will set focus to it */
    531       if (!lstrcmpA(infoPtr->szBuddyClass,"Edit")) SetFocus(infoPtr->Buddy);
     534      if (!lstrcmpiA(infoPtr->szBuddyClass,"Edit")) SetFocus(infoPtr->Buddy);
    532535
    533536      /* Now see which one is the 'active' arrow */
     
    702705   /*If we released the mouse and our buddy is an edit */
    703706   /* we must select all text in it.                   */
    704    if (!lstrcmpA(infoPtr->szBuddyClass,"Edit"))
     707   if (!lstrcmpiA(infoPtr->szBuddyClass,"Edit"))
    705708       SendMessageA(infoPtr->Buddy,EM_SETSEL,0,MAKELONG(0,-1));
    706709
Note: See TracChangeset for help on using the changeset viewer.