Changeset 10530


Ignore:
Timestamp:
Mar 16, 2004, 6:17:31 PM (21 years ago)
Author:
sandervl
Message:

Wine merge

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/include/win/commctrl.h

    r10447 r10530  
    11301130#define TB_UNKWN45E              (WM_USER+94)
    11311131#define TB_UNKWN460              (WM_USER+96)
     1132#define TB_UNKWN462              (WM_USER+98)
    11321133#define TB_UNKWN463              (WM_USER+99)
    11331134#define TB_UNKWN464              (WM_USER+100)
  • TabularUnified trunk/src/comctl32/comctl32.h

    r10097 r10530  
    346346
    347347
     348/* undocumented functions */
     349
     350LPVOID WINAPI COMCTL32_Alloc (DWORD);
     351#define Alloc(a) COMCTL32_Alloc(a)
     352
     353LPVOID WINAPI COMCTL32_ReAlloc (LPVOID, DWORD);
     354BOOL   WINAPI COMCTL32_Free (LPVOID);
     355#define Free(a) COMCTL32_Free(a)
     356DWORD  WINAPI COMCTL32_GetSize (LPVOID);
     357
    348358#ifdef __cplusplus
    349359}
  • TabularUnified trunk/src/comctl32/listview.c

    r10448 r10530  
    2626 * This code was audited for completeness against the documented features
    2727 * of Comctl32.dll version 6.0 on Oct. 21, 2002, by Dimitrie O. Paun.
    28  *
    29  * Unless otherwise noted, we belive this code to be complete, as per
     28 * 
     29 * Unless otherwise noted, we believe this code to be complete, as per
    3030 * the specification mentioned above.
    3131 * If you discover missing features, or bugs, please note them below.
    32  *
     32 * 
    3333 * TODO:
    3434 *
     
    4242 *   -- Expand large item in ICON mode when the cursor is flying over the icon or text.
    4343 *   -- Support CustonDraw options for _WIN32_IE >= 0x560 (see NMLVCUSTOMDRAW docs.
    44  *   -- in LISTVIEW_AddGroupSelection, se whould send LVN_ODSTATECHANGED
     44 *   -- in LISTVIEW_AddGroupSelection, se whould send LVN_ODSTATECHANGED 
    4545 *   -- LVA_SNAPTOGRID not implemented
    4646 *   -- LISTVIEW_ApproximateViewRect partially implemented
     
    7979 * Extended Styles
    8080 *   -- LVS_EX_BORDERSELECT
    81  *   -- LVS_EX_CHECKBOXES
    8281 *   -- LVS_EX_FLATSB
    8382 *   -- LVS_EX_GRIDLINES
     
    8988 *   -- LVS_EX_REGIONAL
    9089 *   -- LVS_EX_SIMPLESELECT
    91  *   -- LVS_EX_SUBITEMIMAGES
    9290 *   -- LVS_EX_TRACKSELECT
    9391 *   -- LVS_EX_TWOCLICKACTIVATE
    9492 *   -- LVS_EX_UNDERLINECOLD
    9593 *   -- LVS_EX_UNDERLINEHOT
    96  *
     94 *   
    9795 * Notifications:
    98  *   -- LVN_BEGINRDRAG
    9996 *   -- LVN_BEGINSCROLL, LVN_ENDSCROLL
    10097 *   -- LVN_GETINFOTIP
     
    108105 * Messages:
    109106 *   -- LVM_CANCELEDITLABEL
    110  *   -- LVM_CREATEDRAGIMAGE
    111107 *   -- LVM_ENABLEGROUPVIEW
    112108 *   -- LVM_GETBKIMAGE, LVM_SETBKIMAGE
     
    153149#include <string.h>
    154150#include <stdlib.h>
     151#include <stdarg.h>
    155152#include <stdio.h>
    156153
     154#include "windef.h"
    157155#include "winbase.h"
    158156#include "winnt.h"
     157#include "wingdi.h"
     158#include "winuser.h"
     159#include "winnls.h"
    159160#include "commctrl.h"
    160161#include "comctl32.h"
     
    234235  INT nHotItem;
    235236  SHORT notifyFormat;
     237  HWND hwndNotify;
    236238  RECT rcList;                 /* This rectangle is really the window
    237                                 * client rectangle possibly reduced by the
    238                                 * horizontal scroll bar and/or header - see
     239                                * client rectangle possibly reduced by the 
     240                                * horizontal scroll bar and/or header - see 
    239241                                * LISTVIEW_UpdateSize. This rectangle offset
    240242                                * by the LISTVIEW_GetOrigin value is in
     
    251253  INT ntmAveCharWidth;          /* by the listview to draw items */
    252254  BOOL bRedraw;                 /* Turns on/off repaints & invalidations */
    253   BOOL bFirstPaint;             /* Flags if the control has never painted before */
    254255  BOOL bAutoarrange;            /* Autoarrange flag when NOT in LVS_AUTOARRANGE */
    255256  BOOL bFocus;
     
    273274  HWND hwndToolTip;
    274275
    275   /* __WIN32OS2__: this might be sligtly fishy as the merge with wine is only partially done ... */
    276276  DWORD cditemmode;             /* Keep the custom draw flags for an item/row */
    277277
     
    349349#define LV_ML_DT_FLAGS  (DT_TOP | DT_NOPREFIX | DT_EDITCONTROL | DT_CENTER | DT_WORDBREAK | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS)
    350350#define LV_FL_DT_FLAGS  (DT_TOP | DT_NOPREFIX | DT_EDITCONTROL | DT_CENTER | DT_WORDBREAK | DT_NOCLIP)
    351 #define LV_SL_DT_FLAGS  (DT_TOP | DT_EDITCONTROL | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS)
     351#define LV_SL_DT_FLAGS  (DT_VCENTER | DT_EDITCONTROL | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS)
    352352
    353353/* The time in milliseconds to reset the search in the list */
     
    396396static BOOL LISTVIEW_EnsureVisible(LISTVIEW_INFO *, INT, BOOL);
    397397static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, INT, INT, INT, INT, BOOL);
     398static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *, INT, HIMAGELIST);
    398399
    399400/******** Text handling functions *************************************/
     
    460461{
    461462    BOOL bResult = TRUE;
    462 
     463   
    463464    if (src == LPSTR_TEXTCALLBACKW)
    464465    {
    465         if (is_textW(*dest)) COMCTL32_Free(*dest);
     466        if (is_textW(*dest)) Free(*dest);
    466467        *dest = LPSTR_TEXTCALLBACKW;
    467468    }
     
    491492        textfreeT(bw, isW);
    492493        return r;
    493     }   
    494        
     494    }      
     495           
    495496    return 1;
    496497}
    497 
     498   
    498499static inline int lstrncmpiW(LPCWSTR s1, LPCWSTR s2, int n)
    499500{
     
    506507
    507508/******** Debugging functions *****************************************/
    508 
    509509#if defined(__WIN32OS2__) && !defined(DEBUG)
    510510//can be removed when switching to GCC
     
    522522#define debugscrollcode(nScrollCode) 0
    523523#else
     524
    524525static inline LPCSTR debugtext_t(LPCWSTR text, BOOL isW)
    525526{
     
    546547}
    547548
    548 static inline char* debugrange(const RANGE *lprng)
    549 {
    550     if (lprng)
     549static inline const char* debugrange(const RANGE *lprng)
     550{
     551    if (lprng) 
    551552    {
    552553        char* buf = debug_getbuf();
     
    556557}
    557558
    558 static inline char* debugpoint(const POINT *lppt)
    559 {
    560     if (lppt)
     559static inline const char* debugpoint(const POINT *lppt)
     560{
     561    if (lppt) 
    561562    {
    562563        char* buf = debug_getbuf();
     
    566567}
    567568
    568 static inline char* debugrect(const RECT *rect)
    569 {
    570     if (rect)
     569static inline const char* debugrect(const RECT *rect)
     570{
     571    if (rect) 
    571572    {
    572573        char* buf = debug_getbuf();
     
    577578}
    578579
    579 static char * debugscrollinfo(const SCROLLINFO *pScrollInfo)
     580static const char * debugscrollinfo(const SCROLLINFO *pScrollInfo)
    580581{
    581582    char* buf = debug_getbuf(), *text = buf;
    582583    int len, size = DEBUG_BUFFER_SIZE;
    583 
     584   
    584585    if (pScrollInfo == NULL) return "(null)";
    585586    len = snprintf(buf, size, "{cbSize=%d, ", pScrollInfo->cbSize);
     
    607608    if (buf - text > 2) { buf[-2] = '}'; buf[-1] = 0; }
    608609    return text;
    609 }
    610 
    611 static char* debugnmlistview(const NMLISTVIEW *plvnm)
     610} 
     611
     612static const char* debugnmlistview(const NMLISTVIEW *plvnm)
    612613{
    613614    if (plvnm)
     
    622623}
    623624
    624 static char* debuglvitem_t(const LVITEMW *lpLVItem, BOOL isW)
     625static const char* debuglvitem_t(const LVITEMW *lpLVItem, BOOL isW)
    625626{
    626627    char* buf = debug_getbuf(), *text = buf;
    627628    int len, size = DEBUG_BUFFER_SIZE;
    628 
     629   
    629630    if (lpLVItem == NULL) return "(null)";
    630631    len = snprintf(buf, size, "{iItem=%d, iSubItem=%d, ", lpLVItem->iItem, lpLVItem->iSubItem);
     
    658659}
    659660
    660 static char* debuglvcolumn_t(const LVCOLUMNW *lpColumn, BOOL isW)
     661static const char* debuglvcolumn_t(const LVCOLUMNW *lpColumn, BOOL isW)
    661662{
    662663    char* buf = debug_getbuf(), *text = buf;
    663664    int len, size = DEBUG_BUFFER_SIZE;
    664 
     665   
    665666    if (lpColumn == NULL) return "(null)";
    666667    len = snprintf(buf, size, "{");
     
    698699}
    699700
    700 static char* debuglvhittestinfo(const LVHITTESTINFO *lpht)
    701 {
    702     if (lpht)
     701static const char* debuglvhittestinfo(const LVHITTESTINFO *lpht)
     702{
     703    if (lpht) 
    703704    {
    704705        char* buf = debug_getbuf();
     
    725726  }
    726727}
    727 #endif
     728#endif /* __WIN32OS2__ */
     729
    728730
    729731/******** Notification functions i************************************/
     
    732734{
    733735    LRESULT result;
    734 
     736   
    735737    TRACE("(code=%d)\n", code);
    736738
     
    738740    pnmh->idFrom = GetWindowLongW(infoPtr->hwndSelf, GWL_ID);
    739741    pnmh->code = code;
    740     result = SendMessageW(GetParent(infoPtr->hwndSelf), WM_NOTIFY,
     742    result = SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
    741743                          (WPARAM)pnmh->idFrom, (LPARAM)pnmh);
    742744
     
    752754}
    753755
    754 static inline void notify_itemactivate(LISTVIEW_INFO *infoPtr)
    755 {
    756     notify(infoPtr, LVN_ITEMACTIVATE);
     756static inline void notify_itemactivate(LISTVIEW_INFO *infoPtr, LVHITTESTINFO *htInfo)
     757{
     758    NMITEMACTIVATE nmia;
     759    LVITEMW item;
     760
     761    if (htInfo) {
     762      nmia.uNewState = 0;
     763      nmia.uOldState = 0;
     764      nmia.uChanged  = 0;
     765      nmia.uKeyFlags = 0;
     766     
     767      item.mask = LVIF_PARAM|LVIF_STATE;
     768      item.iItem = htInfo->iItem;
     769      item.iSubItem = 0;
     770      if (LISTVIEW_GetItemT(infoPtr, &item, TRUE)) {
     771          nmia.lParam = item.lParam;
     772          nmia.uOldState = item.state;
     773          nmia.uNewState = item.state | LVIS_ACTIVATING;
     774          nmia.uChanged  = LVIF_STATE;
     775      }
     776     
     777      nmia.iItem = htInfo->iItem;
     778      nmia.iSubItem = htInfo->iSubItem;
     779      nmia.ptAction = htInfo->pt;     
     780     
     781      if (GetKeyState(VK_SHIFT) & 0x8000) nmia.uKeyFlags |= LVKF_SHIFT;
     782      if (GetKeyState(VK_CONTROL) & 0x8000) nmia.uKeyFlags |= LVKF_CONTROL;
     783      if (GetKeyState(VK_MENU) & 0x8000) nmia.uKeyFlags |= LVKF_ALT;
     784    }
     785    notify_hdr(infoPtr, LVN_ITEMACTIVATE, (LPNMHDR)&nmia);
    757786}
    758787
     
    767796    NMLISTVIEW nmlv;
    768797    LVITEMW item;
    769 
    770     TRACE("code=%d, lvht=%s\n", code, debuglvhittestinfo(lvht));
     798   
     799    TRACE("code=%d, lvht=%s\n", code, debuglvhittestinfo(lvht)); 
    771800    ZeroMemory(&nmlv, sizeof(nmlv));
    772801    nmlv.iItem = lvht->iItem;
     
    784813    NMLISTVIEW nmlv;
    785814    LVITEMW item;
    786 
     815   
    787816    ZeroMemory(&nmlv, sizeof (NMLISTVIEW));
    788817    nmlv.iItem = nItem;
     
    873902}
    874903
    875 static void customdraw_fill(NMLVCUSTOMDRAW *lpnmlvcd, LISTVIEW_INFO *infoPtr, HDC hdc,
     904static void customdraw_fill(NMLVCUSTOMDRAW *lpnmlvcd, LISTVIEW_INFO *infoPtr, HDC hdc, 
    876905                            const RECT *rcBounds, const LVITEMW *lplvItem)
    877906{
     
    896925
    897926    lpnmlvcd->nmcd.dwDrawStage = dwDrawStage;
    898     if (isForItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_ITEM;
     927    if (isForItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_ITEM; 
    899928    if (lpnmlvcd->iSubItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_SUBITEM;
    900929    if (isForItem) lpnmlvcd->nmcd.dwItemSpec--;
     
    904933}
    905934
    906 static DWORD notify_prepaint (LISTVIEW_INFO *infoPtr, HDC hdc, NMLVCUSTOMDRAW *lpnmlvcd)
    907 {
    908     BOOL isSelected = lpnmlvcd->nmcd.uItemState & CDIS_SELECTED;
    909     DWORD cditemmode = notify_customdraw(infoPtr, CDDS_PREPAINT, lpnmlvcd);
    910 
    911     if (cditemmode & CDRF_SKIPDEFAULT) return cditemmode;
    912 
     935static void prepaint_setup (LISTVIEW_INFO *infoPtr, HDC hdc, NMLVCUSTOMDRAW *lpnmlvcd)
     936{
    913937    /* apprently, for selected items, we have to override the returned values */
    914     if (isSelected)
     938    if (lpnmlvcd->nmcd.uItemState & CDIS_SELECTED)
    915939    {
    916940        if (infoPtr->bFocus)
     
    938962        SetBkMode(hdc, TRANSPARENT);
    939963    SetTextColor(hdc, lpnmlvcd->clrText);
    940 
    941     return cditemmode;
    942964}
    943965
     
    9881010 * after it's done with it, as the creation of the iterator may
    9891011 * allocate memory, which thus needs to be freed.
    990  *
     1012 * 
    9911013 * You can iterate both forwards, and backwards through the list,
    9921014 * by using iterator_next or iterator_prev respectively.
    993  *
     1015 * 
    9941016 * Lower numbered items are draw on top of higher number items in
    9951017 * LVS_ICON, and LVS_SMALLICON (which are the only modes where
     
    10151037 * LVS_ICON, and LVS_SMALLICON mode to handle the focused item,
    10161038 * which needs to be first, as it may overlap other items.
    1017  *
     1039 *           
    10181040 * The code is a bit messy because we have:
    10191041 *   - a special item to deal with
     
    10511073    if (i->ranges)
    10521074    {
    1053         if (i->index < i->ranges->hdpa->nItemCount)
     1075        if (i->index < DPA_GetPtrCount(i->ranges->hdpa))
    10541076            i->range = *(RANGE*)DPA_GetPtr(i->ranges->hdpa, i->index++);
    10551077        else goto end;
     
    10771099    {
    10781100        start = TRUE;
    1079         if (i->ranges) i->index = i->ranges->hdpa->nItemCount;
     1101        if (i->ranges) i->index = DPA_GetPtrCount(i->ranges->hdpa);
    10801102        goto pickarange;
    10811103    }
     
    11131135
    11141136    range.lower = (*(RANGE*)DPA_GetPtr(i->ranges->hdpa, 0)).lower;
    1115     range.upper = (*(RANGE*)DPA_GetPtr(i->ranges->hdpa, i->ranges->hdpa->nItemCount - 1)).upper;
     1137    range.upper = (*(RANGE*)DPA_GetPtr(i->ranges->hdpa, DPA_GetPtrCount(i->ranges->hdpa) - 1)).upper;
    11161138    return range;
    11171139}
     
    11651187    RECT frame = *lprc, rcItem, rcTemp;
    11661188    POINT Origin;
    1167 
     1189   
    11681190    /* in case we fail, we want to return an empty iterator */
    11691191    if (!iterator_empty(i)) return FALSE;
     
    12501272    RECT rcItem, rcClip;
    12511273    INT rgntype;
    1252 
     1274   
    12531275    rgntype = GetClipBox(hdc, &rcClip);
    12541276    if (rgntype == NULLREGION) return iterator_empty(i);
     
    12621284        if (!RectVisible(hdc, &rcItem)) i->nSpecial = -1;
    12631285    }
    1264 
     1286   
    12651287    /* if we can't deal with the region, we'll just go with the simple range */
    12661288    LISTVIEW_GetOrigin(infoPtr, &Origin);
     
    12901312    /* the iterator should restart on the next iterator_next */
    12911313    TRACE("done\n");
    1292 
     1314   
    12931315    return TRUE;
    12941316}
     
    13061328{
    13071329    UINT uView = infoPtr->dwStyle & LVS_TYPEMASK;
    1308 
     1330   
    13091331    return ((infoPtr->dwStyle & LVS_AUTOARRANGE) || infoPtr->bAutoarrange) &&
    13101332           (uView == LVS_ICON || uView == LVS_SMALLICON);
     
    13171339    static COLUMN_INFO mainItem;
    13181340
    1319     if (nSubItem == 0 && infoPtr->hdpaColumns->nItemCount == 0) return &mainItem;
    1320     assert (nSubItem >= 0 && nSubItem < infoPtr->hdpaColumns->nItemCount);
     1341    if (nSubItem == 0 && DPA_GetPtrCount(infoPtr->hdpaColumns) == 0) return &mainItem;
     1342    assert (nSubItem >= 0 && nSubItem < DPA_GetPtrCount(infoPtr->hdpaColumns));
    13211343    return (COLUMN_INFO *)DPA_GetPtr(infoPtr->hdpaColumns, nSubItem);
    13221344}
     
    13361358static inline BOOL is_redrawing(LISTVIEW_INFO *infoPtr)
    13371359{
    1338     return infoPtr->bRedraw && !infoPtr->bFirstPaint;
     1360    return infoPtr->bRedraw;
    13391361}
    13401362
    13411363static inline void LISTVIEW_InvalidateRect(LISTVIEW_INFO *infoPtr, const RECT* rect)
    13421364{
    1343     if(!is_redrawing(infoPtr)) return;
     1365    if(!is_redrawing(infoPtr)) return; 
    13441366    TRACE(" invalidating rect=%s\n", debugrect(rect));
    13451367    InvalidateRect(infoPtr->hwndSelf, rect, TRUE);
     
    13501372    RECT rcBox;
    13511373
    1352     if(!is_redrawing(infoPtr)) return;
     1374    if(!is_redrawing(infoPtr)) return; 
    13531375    LISTVIEW_GetItemBox(infoPtr, nItem, &rcBox);
    13541376    LISTVIEW_InvalidateRect(infoPtr, &rcBox);
     
    13591381    POINT Origin, Position;
    13601382    RECT rcBox;
    1361 
    1362     if(!is_redrawing(infoPtr)) return;
     1383   
     1384    if(!is_redrawing(infoPtr)) return; 
    13631385    assert ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_REPORT);
    13641386    LISTVIEW_GetOrigin(infoPtr, &Origin);
     
    13791401{
    13801402    RECT rcCol;
    1381 
    1382     if(!is_redrawing(infoPtr)) return;
     1403   
     1404    if(!is_redrawing(infoPtr)) return; 
    13831405    LISTVIEW_GetHeaderRect(infoPtr, nColumn, &rcCol);
    13841406    rcCol.top = infoPtr->rcList.top;
     
    16311653        if (LISTVIEW_GetViewRect(infoPtr, &rcView)) horzInfo.nMax = rcView.right - rcView.left;
    16321654    }
    1633 
     1655 
    16341656    horzInfo.fMask = SIF_RANGE | SIF_PAGE;
    16351657    horzInfo.nMax = max(horzInfo.nMax - 1, 0);
     
    16801702/***
    16811703 * DESCRIPTION:
    1682  * Shows/hides the focus rectangle.
     1704 * Shows/hides the focus rectangle. 
    16831705 *
    16841706 * PARAMETER(S):
     
    17031725        RECT rcBox;
    17041726
    1705         LISTVIEW_GetItemBox(infoPtr, infoPtr->nFocusedItem, &rcBox);
     1727        LISTVIEW_GetItemBox(infoPtr, infoPtr->nFocusedItem, &rcBox); 
    17061728        if ((rcBox.bottom - rcBox.top) > infoPtr->nItemHeight)
    17071729        {
     
    17231745        item.mask = LVIF_PARAM;
    17241746        if (!LISTVIEW_GetItemW(infoPtr, &item)) goto done;
    1725        
    1726         ZeroMemory(&dis, sizeof(dis));
     1747           
     1748        ZeroMemory(&dis, sizeof(dis)); 
    17271749        dis.CtlType = ODT_LISTVIEW;
    17281750        dis.CtlID = GetWindowLongW(infoPtr->hwndSelf, GWL_ID);
     
    17351757        dis.itemData = item.lParam;
    17361758
    1737         SendMessageW(GetParent(infoPtr->hwndSelf), WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
     1759        SendMessageW(infoPtr->hwndNotify, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
    17381760    }
    17391761    else
     
    17501772static void LISTVIEW_InvalidateSelectedItems(LISTVIEW_INFO *infoPtr)
    17511773{
    1752     ITERATOR i;
    1753 
    1754     iterator_frameditems(&i, infoPtr, &infoPtr->rcList);
     1774    ITERATOR i; 
     1775   
     1776    iterator_frameditems(&i, infoPtr, &infoPtr->rcList); 
    17551777    while(iterator_next(&i))
    17561778    {
     
    17611783}
    17621784
    1763        
     1785           
    17641786/***
    17651787 * DESCRIPTION:            [INTERNAL]
     
    17701792 * one ca factor the computation of the Origin before the loop,
    17711793 * and offset the value retured by this function, on every iteration.
    1772  *
     1794 * 
    17731795 * PARAMETER(S):
    17741796 * [I] infoPtr : valid pointer to the listview structure
     
    18021824    }
    18031825}
    1804 
     1826   
    18051827/***
    18061828 * DESCRIPTION:            [INTERNAL]
     
    18451867 */
    18461868static void LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem,
    1847                                     LPRECT lprcBox, LPRECT lprcState,
     1869                                    LPRECT lprcBox, LPRECT lprcState, 
    18481870                                    LPRECT lprcIcon, LPRECT lprcLabel)
    18491871{
     
    18651887    if (doLabel || lprcIcon) doIcon = TRUE;
    18661888    if (doIcon || lprcState) doState = TRUE;
    1867 
     1889   
    18681890    /************************************************************/
    18691891    /* compute the box rectangle (it should be cheap to do)     */
     
    18721894        lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, lpLVItem->iSubItem);
    18731895
    1874     if (lpLVItem->iSubItem)
     1896    if (lpLVItem->iSubItem)   
    18751897    {
    18761898        Box = lpColumnInfo->rcHeader;
     
    18921914        {
    18931915            State.left = Box.left - infoPtr->iconStateSize.cx - 2;
    1894             if (infoPtr->himlNormal)
     1916            if (infoPtr->himlNormal) 
    18951917                State.left += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2;
    18961918            State.top  = Box.top + infoPtr->iconSize.cy - infoPtr->iconStateSize.cy + 4;
     
    19001922            /* we need the ident in report mode, if we don't have it, we fail */
    19011923            State.left = Box.left;
    1902             if (uView == LVS_REPORT)
     1924            if (uView == LVS_REPORT) 
    19031925            {
    19041926                if (lpLVItem->iSubItem == 0)
     
    19301952        {
    19311953            Icon.left   = Box.left;
    1932             if (infoPtr->himlNormal)
     1954            if (infoPtr->himlNormal) 
    19331955                Icon.left += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2;
    19341956            Icon.top    = Box.top + ICON_TOP_PADDING;
     
    19461968            Icon.top    = Box.top;
    19471969            Icon.right  = Icon.left;
    1948             if (infoPtr->himlSmall && (!lpColumnInfo || lpLVItem->iSubItem == 0 || (lpColumnInfo->fmt & LVCFMT_IMAGE)))
     1970            if (infoPtr->himlSmall &&
     1971                (!lpColumnInfo || lpLVItem->iSubItem == 0 || (lpColumnInfo->fmt & LVCFMT_IMAGE) ||
     1972                 ((infoPtr->dwLvExStyle & LVS_EX_SUBITEMIMAGES) && lpLVItem->iImage != I_IMAGECALLBACK)))
    19491973                Icon.right += infoPtr->iconSize.cx;
    19501974            Icon.bottom = Icon.top + infoPtr->nItemHeight;
     
    19892013            rcText.right = infoPtr->nItemWidth - TRAILING_LABEL_PADDING;
    19902014            rcText.bottom = infoPtr->nItemHeight;
    1991             if (uView == LVS_ICON)
     2015            if (uView == LVS_ICON) 
    19922016                rcText.bottom -= ICON_TOP_PADDING + infoPtr->iconSize.cy + ICON_BOTTOM_PADDING;
    19932017
     
    19972021            else
    19982022                uFormat = LV_SL_DT_FLAGS;
    1999        
     2023           
    20002024            DrawTextW (hdc, lpLVItem->pszText, -1, &rcText, uFormat | DT_CALCRECT);
    20012025
     
    20312055            Label.bottom = Label.top + infoPtr->nItemHeight;
    20322056        }
    2033 
     2057 
    20342058        if (lprcLabel) *lprcLabel = Label;
    20352059        TRACE("    - label=%s\n", debugrect(&Label));
     
    21022126{
    21032127    INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;
    2104 
     2128   
    21052129    *lpPos = infoPtr->currIconPos;
    2106 
     2130   
    21072131    infoPtr->currIconPos.x += infoPtr->nItemWidth;
    21082132    if (infoPtr->currIconPos.x + infoPtr->nItemWidth <= nListWidth) return;
     
    21122136}
    21132137
    2114 
     2138   
    21152139/***
    21162140 * DESCRIPTION:
     
    21282152{
    21292153    INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;
    2130 
     2154   
    21312155    *lpPos = infoPtr->currIconPos;
    2132 
     2156   
    21332157    infoPtr->currIconPos.y += infoPtr->nItemHeight;
    21342158    if (infoPtr->currIconPos.y + infoPtr->nItemHeight <= nListHeight) return;
     
    21382162}
    21392163
    2140 
     2164   
    21412165/***
    21422166 * DESCRIPTION:
     
    21572181{
    21582182    POINT old;
    2159 
     2183   
    21602184    if (!isNew)
    2161     {
     2185    { 
    21622186        old.x = (LONG)DPA_GetPtr(infoPtr->hdpaPosX, nItem);
    21632187        old.y = (LONG)DPA_GetPtr(infoPtr->hdpaPosY, nItem);
    2164 
     2188   
    21652189        if (lppt->x == old.x && lppt->y == old.y) return TRUE;
    21662190        LISTVIEW_InvalidateItem(infoPtr, nItem);
     
    21972221
    21982222    if (uView != LVS_ICON && uView != LVS_SMALLICON) return FALSE;
    2199 
     2223 
    22002224    TRACE("nAlignCode=%d\n", nAlignCode);
    22012225
     
    22052229        else nAlignCode = LVA_ALIGNTOP;
    22062230    }
    2207 
     2231   
    22082232    switch (nAlignCode)
    22092233    {
     
    22132237    default: return FALSE;
    22142238    }
    2215 
     2239   
    22162240    infoPtr->bAutoarrange = TRUE;
    22172241    infoPtr->currIconPos.x = infoPtr->currIconPos.y = 0;
     
    22242248    return TRUE;
    22252249}
    2226 
     2250 
    22272251/***
    22282252 * DESCRIPTION:
     
    22692293        break;
    22702294       
    2271     case LVS_REPORT:   
     2295    case LVS_REPORT:       
    22722296        lprcView->right = infoPtr->nItemWidth;
    22732297        lprcView->bottom = infoPtr->nItemCount * infoPtr->nItemHeight;
     
    22952319
    22962320    if (!lprcView) return FALSE;
    2297 
     2321 
    22982322    LISTVIEW_GetOrigin(infoPtr, &ptOrigin);
    2299     LISTVIEW_GetAreaRect(infoPtr, lprcView);
    2300     OffsetRect(lprcView, ptOrigin.x, ptOrigin.y);
     2323    LISTVIEW_GetAreaRect(infoPtr, lprcView); 
     2324    OffsetRect(lprcView, ptOrigin.x, ptOrigin.y); 
    23012325
    23022326    TRACE("lprcView=%s\n", debugrect(lprcView));
     
    23232347
    23242348    /* we should binary search here if need be */
    2325     for (i = 1; i < hdpaSubItems->nItemCount; i++)
     2349    for (i = 1; i < DPA_GetPtrCount(hdpaSubItems); i++)
    23262350    {
    23272351        lpSubItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, i);
     
    23572381        RECT rcHeader;
    23582382
    2359         if (infoPtr->hdpaColumns->nItemCount > 0)
     2383        if (DPA_GetPtrCount(infoPtr->hdpaColumns) > 0)
    23602384        {
    2361             LISTVIEW_GetHeaderRect(infoPtr, infoPtr->hdpaColumns->nItemCount - 1, &rcHeader);
     2385            LISTVIEW_GetHeaderRect(infoPtr, DPA_GetPtrCount(infoPtr->hdpaColumns) - 1, &rcHeader);
    23622386            nItemWidth = rcHeader.right;
    23632387        }
     
    23702394            nItemWidth = max(LISTVIEW_GetLabelWidth(infoPtr, i), nItemWidth);
    23712395
    2372         if (infoPtr->himlSmall) nItemWidth += infoPtr->iconSize.cx;
     2396        if (infoPtr->himlSmall) nItemWidth += infoPtr->iconSize.cx; 
    23732397        if (infoPtr->himlState) nItemWidth += infoPtr->iconStateSize.cx;
    23742398
     
    24002424    else
    24012425    {
    2402         nItemHeight = infoPtr->ntmHeight;
     2426        nItemHeight = infoPtr->ntmHeight; 
    24032427        if (infoPtr->himlState)
    24042428            nItemHeight = max(nItemHeight, infoPtr->iconStateSize.cy);
     
    24242448       }
    24252449#endif
     2450
    24262451    }
    24272452
     
    24692494    SelectObject(hdc, hOldFont);
    24702495    ReleaseDC(infoPtr->hwndSelf, hdc);
    2471 
     2496   
    24722497    TRACE("tmHeight=%d\n", infoPtr->ntmHeight);
    24732498}
     
    24902515{
    24912516    INT cmp;
    2492 
    2493     if (((RANGE*)range1)->upper <= ((RANGE*)range2)->lower)
     2517   
     2518    if (((RANGE*)range1)->upper <= ((RANGE*)range2)->lower) 
    24942519        cmp = -1;
    2495     else if (((RANGE*)range2)->upper <= ((RANGE*)range1)->lower)
     2520    else if (((RANGE*)range2)->upper <= ((RANGE*)range1)->lower) 
    24962521        cmp = 1;
    2497     else
     2522    else 
    24982523        cmp = 0;
    2499 
     2524   
    25002525    TRACE("range1=%s, range2=%s, cmp=%d\n", debugrange((RANGE*)range1), debugrange((RANGE*)range2), cmp);
    25012526
     
    25132538    INT i;
    25142539    RANGE *prev, *curr;
    2515 
     2540   
    25162541    TRACE("*** Checking %s:%d:%s ***\n", func, line, desc);
    25172542    assert (ranges);
    2518     assert (ranges->hdpa->nItemCount >= 0);
     2543    assert (DPA_GetPtrCount(ranges->hdpa) >= 0);
    25192544    ranges_dump(ranges);
    25202545    prev = (RANGE *)DPA_GetPtr(ranges->hdpa, 0);
    2521     if (ranges->hdpa->nItemCount > 0)
     2546    if (DPA_GetPtrCount(ranges->hdpa) > 0)
    25222547        assert (prev->lower >= 0 && prev->lower < prev->upper);
    2523     for (i = 1; i < ranges->hdpa->nItemCount; i++)
     2548    for (i = 1; i < DPA_GetPtrCount(ranges->hdpa); i++)
    25242549    {
    25252550        curr = (RANGE *)DPA_GetPtr(ranges->hdpa, i);
     
    25332558static RANGES ranges_create(int count)
    25342559{
    2535     RANGES ranges = (RANGES)COMCTL32_Alloc(sizeof(struct tagRANGES));
     2560    RANGES ranges = (RANGES)Alloc(sizeof(struct tagRANGES));
    25362561    if (!ranges) return NULL;
    25372562    ranges->hdpa = DPA_Create(count);
    25382563    if (ranges->hdpa) return ranges;
    2539     COMCTL32_Free(ranges);
     2564    Free(ranges);
    25402565    return NULL;
    25412566}
     
    25452570    INT i;
    25462571       
    2547     for(i = 0; i < ranges->hdpa->nItemCount; i++)
    2548         COMCTL32_Free(DPA_GetPtr(ranges->hdpa, i));
     2572    for(i = 0; i < DPA_GetPtrCount(ranges->hdpa); i++)
     2573        Free(DPA_GetPtr(ranges->hdpa, i));
    25492574    DPA_DeleteAllPtrs(ranges->hdpa);
    25502575}
     
    25562581    ranges_clear(ranges);
    25572582    DPA_Destroy(ranges->hdpa);
    2558     COMCTL32_Free(ranges);
     2583    Free(ranges);
    25592584}
    25602585
     
    25632588    RANGES clone;
    25642589    INT i;
    2565        
    2566     if (!(clone = ranges_create(ranges->hdpa->nItemCount))) goto fail;
    2567 
    2568     for (i = 0; i < ranges->hdpa->nItemCount; i++)
    2569     {
    2570         RANGE *newrng = (RANGE *)COMCTL32_Alloc(sizeof(RANGE));
     2590           
     2591    if (!(clone = ranges_create(DPA_GetPtrCount(ranges->hdpa)))) goto fail;
     2592
     2593    for (i = 0; i < DPA_GetPtrCount(ranges->hdpa); i++)
     2594    {
     2595        RANGE *newrng = (RANGE *)Alloc(sizeof(RANGE));
    25712596        if (!newrng) goto fail;
    25722597        *newrng = *((RANGE*)DPA_GetPtr(ranges->hdpa, i));
     
    25742599    }
    25752600    return clone;
    2576 
     2601   
    25772602fail:
    25782603    TRACE ("clone failed\n");
     
    25852610    INT i;
    25862611
    2587     for (i = 0; i < sub->hdpa->nItemCount; i++)
     2612    for (i = 0; i < DPA_GetPtrCount(sub->hdpa); i++)
    25882613        ranges_del(ranges, *((RANGE *)DPA_GetPtr(sub->hdpa, i)));
    25892614
     
    25952620    INT i;
    25962621
    2597     for (i = 0; i < ranges->hdpa->nItemCount; i++)
     2622    for (i = 0; i < DPA_GetPtrCount(ranges->hdpa); i++)
    25982623        TRACE("   %s\n", debugrange(DPA_GetPtr(ranges->hdpa, i)));
    25992624}
     
    26112636{
    26122637    INT i, count = 0;
    2613 
    2614     for (i = 0; i < ranges->hdpa->nItemCount; i++)
     2638   
     2639    for (i = 0; i < DPA_GetPtrCount(ranges->hdpa); i++)
    26152640    {
    26162641        RANGE *sel = DPA_GetPtr(ranges->hdpa, i);
     
    26292654    if (index == -1) return TRUE;
    26302655
    2631     for (; index < ranges->hdpa->nItemCount; index++)
     2656    for (; index < DPA_GetPtrCount(ranges->hdpa); index++)
    26322657    {
    26332658        chkrng = DPA_GetPtr(ranges->hdpa, index);
     
    26522677    srchrgn.upper = range.upper + 1;
    26532678    index = DPA_Search(ranges->hdpa, &srchrgn, 0, ranges_cmp, 0, DPAS_SORTED);
    2654 
     2679   
    26552680    if (index == -1)
    26562681    {
     
    26602685
    26612686        /* create the brand new range to insert */     
    2662         newrgn = (RANGE *)COMCTL32_Alloc(sizeof(RANGE));
     2687        newrgn = (RANGE *)Alloc(sizeof(RANGE));
    26632688        if(!newrgn) goto fail;
    26642689        *newrgn = range;
     
    26722697        if (DPA_InsertPtr(ranges->hdpa, index, newrgn) == -1)
    26732698        {
    2674             COMCTL32_Free(newrgn);
     2699            Free(newrgn);
    26752700            goto fail;
    26762701        }
     
    26932718        srchrgn.lower = chkrgn->lower - 1;
    26942719        srchrgn.upper = chkrgn->upper + 1;
    2695        
     2720           
    26962721        do
    26972722        {
    26982723            mergeindex = DPA_Search(ranges->hdpa, &srchrgn, fromindex, ranges_cmp, 0, 0);
    26992724            if (mergeindex == -1) break;
    2700             if (mergeindex == index)
     2725            if (mergeindex == index) 
    27012726            {
    27022727                fromindex = index + 1;
    27032728                continue;
    27042729            }
    2705        
     2730         
    27062731            TRACE("Merge with index %i\n", mergeindex);
    2707        
     2732           
    27082733            mrgrgn = DPA_GetPtr(ranges->hdpa, mergeindex);
    27092734            chkrgn->lower = min(chkrgn->lower, mrgrgn->lower);
    27102735            chkrgn->upper = max(chkrgn->upper, mrgrgn->upper);
    2711             COMCTL32_Free(mrgrgn);
     2736            Free(mrgrgn);
    27122737            DPA_DeletePtr(ranges->hdpa, mergeindex);
    27132738            if (mergeindex < index) index --;
     
    27172742    ranges_check(ranges, "after add");
    27182743    return TRUE;
    2719 
     2744   
    27202745fail:
    27212746    ranges_check(ranges, "failed add");
     
    27302755    TRACE("(%s)\n", debugrange(&range));
    27312756    ranges_check(ranges, "before del");
    2732 
     2757   
    27332758    /* we don't use DPAS_SORTED here, since we need *
    27342759     * to find the first overlapping range          */
    27352760    index = DPA_Search(ranges->hdpa, &range, 0, ranges_cmp, 0, 0);
    2736     while(index != -1)
     2761    while(index != -1) 
    27372762    {
    27382763        chkrgn = DPA_GetPtr(ranges->hdpa, index);
    27392764       
    2740         TRACE("Matches range %s @%d\n", debugrange(chkrgn), index);
     2765        TRACE("Matches range %s @%d\n", debugrange(chkrgn), index); 
    27412766
    27422767        /* case 1: Same range */
     
    27492774        /* case 2: engulf */
    27502775        else if ( (chkrgn->upper <= range.upper) &&
    2751                   (chkrgn->lower >= range.lower) )
     2776                  (chkrgn->lower >= range.lower) ) 
    27522777        {
    27532778            DPA_DeletePtr(ranges->hdpa, index);
     
    27712796            RANGE tmprgn = *chkrgn, *newrgn;
    27722797
    2773             if (!(newrgn = (RANGE *)COMCTL32_Alloc(sizeof(RANGE)))) goto fail;
     2798            if (!(newrgn = (RANGE *)Alloc(sizeof(RANGE)))) goto fail;
    27742799            newrgn->lower = chkrgn->lower;
    27752800            newrgn->upper = range.lower;
     
    27772802            if (DPA_InsertPtr(ranges->hdpa, index, newrgn) == -1)
    27782803            {
    2779                 COMCTL32_Free(newrgn);
     2804                Free(newrgn);
    27802805                goto fail;
    27812806            }
     
    28172842    lvItem.state = 0;
    28182843    lvItem.stateMask = LVIS_SELECTED;
    2819 
     2844   
    28202845    /* need to clone the DPA because callbacks can change it */
    28212846    if (!(clone = ranges_clone(infoPtr->selectionRanges))) return FALSE;
     
    28322857{
    28332858    RANGES toSkip;
    2834 
     2859   
    28352860    if (!(toSkip = ranges_create(1))) return FALSE;
    28362861    if (nItem != -1) ranges_additem(toSkip, nItem);
     
    28932918
    28942919    if (nItem == infoPtr->nFocusedItem) return FALSE;
    2895 
     2920   
    28962921    lvItem.state =  nItem == -1 ? 0 : LVIS_FOCUSED;
    28972922    lvItem.stateMask = LVIS_FOCUSED;
     
    29452970    if (nNewFocus != infoPtr->nFocusedItem)
    29462971        LISTVIEW_SetItemFocus(infoPtr, nNewFocus);
    2947 
     2972   
    29482973    /* But we are not supposed to modify nHotItem! */
    29492974
     
    30063031    if (!(selection = ranges_create(100))) return;
    30073032
    3008     item.state = LVIS_SELECTED;
     3033    item.state = LVIS_SELECTED; 
    30093034    item.stateMask = LVIS_SELECTED;
    30103035
     
    30193044        {
    30203045            RANGE sel;
    3021        
     3046           
    30223047            sel.lower = min(infoPtr->nSelectionMark, nItem);
    30233048            sel.upper = max(infoPtr->nSelectionMark, nItem) + 1;
     
    30503075    /* this will also destroy the selection */
    30513076    iterator_destroy(&i);
    3052 
     3077   
    30533078    LISTVIEW_SetItemFocus(infoPtr, nItem);
    30543079}
     
    30703095
    30713096    TRACE("nItem=%d\n", nItem);
    3072 
     3097   
    30733098    LISTVIEW_DeselectAllSkipItem(infoPtr, nItem);
    30743099
     
    31923217    }
    31933218  }
     3219
    31943220  return 0;
    31953221}
     
    31973223
    31983224/***
    3199  * Tests wheather the item is assignable to a list with style lStyle
     3225 * Tests wheather the item is assignable to a list with style lStyle 
    32003226 */
    32013227static inline BOOL is_assignable_item(const LVITEMW *lpLVItem, LONG lStyle)
    32023228{
    3203     if ( (lpLVItem->mask & LVIF_TEXT) &&
     3229    if ( (lpLVItem->mask & LVIF_TEXT) && 
    32043230        (lpLVItem->pszText == LPSTR_TEXTCALLBACKW) &&
    32053231        (lStyle & (LVS_SORTASCENDING | LVS_SORTDESCENDING)) ) return FALSE;
    3206 
     3232   
    32073233    return TRUE;
    32083234}
     
    32353261
    32363262    assert(lpLVItem->iItem >= 0 && lpLVItem->iItem < infoPtr->nItemCount);
    3237 
    3238     if (lpLVItem->mask == 0) return TRUE;
     3263   
     3264    if (lpLVItem->mask == 0) return TRUE;   
    32393265
    32403266    if (infoPtr->dwStyle & LVS_OWNERDATA)
     
    32623288
    32633289    TRACE("oldState=%x, newState=%x\n", item.state, lpLVItem->state);
    3264     /* determine what fields will change */
     3290    /* determine what fields will change */   
    32653291    if ((lpLVItem->mask & LVIF_STATE) && ((item.state ^ lpLVItem->state) & lpLVItem->stateMask & ~infoPtr->uCallbackMask))
    32663292        uChanged |= LVIF_STATE;
     
    32773303    if ((lpLVItem->mask & LVIF_TEXT) && textcmpWT(lpItem->hdr.pszText, lpLVItem->pszText, isW))
    32783304        uChanged |= LVIF_TEXT;
    3279 
    3280     TRACE("uChanged=0x%x\n", uChanged);
     3305   
     3306    TRACE("uChanged=0x%x\n", uChanged); 
    32813307    if (!uChanged) return TRUE;
    32823308    *bChanged = TRUE;
    3283 
     3309   
    32843310    ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
    32853311    nmlv.iItem = lpLVItem->iItem;
     
    32883314    nmlv.uChanged = uChanged;
    32893315    nmlv.lParam = item.lParam;
    3290 
     3316   
    32913317    /* send LVN_ITEMCHANGING notification, if the item is not being inserted */
    32923318    /* and we are _NOT_ virtual (LVS_OWERNDATA), and change notifications */
     
    33403366    /* if we're inserting the item, we're done */
    33413367    if (isNew) return TRUE;
    3342 
     3368   
    33433369    /* send LVN_ITEMCHANGED notification */
    33443370    if (lpLVItem->mask & LVIF_PARAM) nmlv.lParam = lpLVItem->lParam;
     
    33693395    /* we do not support subitems for virtual listviews */
    33703396    if (infoPtr->dwStyle & LVS_OWNERDATA) return FALSE;
    3371 
     3397   
    33723398    /* set subitem only if column is present */
    3373     if (lpLVItem->iSubItem >= infoPtr->hdpaColumns->nItemCount) return FALSE;
    3374 
     3399    if (lpLVItem->iSubItem >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE;
     3400   
    33753401    /* First do some sanity checks */
    33763402    if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE)) return FALSE;
    33773403    if (!(lpLVItem->mask & (LVIF_TEXT | LVIF_IMAGE))) return TRUE;
    3378 
     3404   
    33793405    /* get the subitem structure, and create it if not there */
    33803406    hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem);
    33813407    assert (hdpaSubItems);
    3382 
     3408   
    33833409    lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, lpLVItem->iSubItem);
    33843410    if (!lpSubItem)
     
    33873413        INT i;
    33883414
    3389         lpSubItem = (SUBITEM_INFO *)COMCTL32_Alloc(sizeof(SUBITEM_INFO));
     3415        lpSubItem = (SUBITEM_INFO *)Alloc(sizeof(SUBITEM_INFO));
    33903416        if (!lpSubItem) return FALSE;
    33913417        /* we could binary search here, if need be...*/
    3392         for (i = 1; i < hdpaSubItems->nItemCount; i++)
     3418        for (i = 1; i < DPA_GetPtrCount(hdpaSubItems); i++)
    33933419        {
    33943420            tmpSubItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, i);
     
    33973423        if (DPA_InsertPtr(hdpaSubItems, i, lpSubItem) == -1)
    33983424        {
    3399             COMCTL32_Free(lpSubItem);
     3425            Free(lpSubItem);
    34003426            return FALSE;
    34013427        }
    34023428        lpSubItem->iSubItem = lpLVItem->iSubItem;
     3429        lpSubItem->hdr.iImage = I_IMAGECALLBACK;
    34033430        *bChanged = TRUE;
    34043431    }
    3405 
     3432   
    34063433    if (lpLVItem->mask & LVIF_IMAGE)
    34073434        if (lpSubItem->hdr.iImage != lpLVItem->iImage)
     
    34393466    LPWSTR pszText = NULL;
    34403467    BOOL bResult, bChanged = FALSE;
    3441 
     3468   
    34423469    TRACE("(lpLVItem=%s, isW=%d)\n", debuglvitem_t(lpLVItem, isW), isW);
    34433470
     
    34513478        ((LVITEMW *)lpLVItem)->pszText = textdupTtoW(lpLVItem->pszText, isW);
    34523479    }
    3453 
     3480   
    34543481    /* actually set the fields */
    34553482    if (!is_assignable_item(lpLVItem, infoPtr->dwStyle)) return FALSE;
    3456 
     3483   
    34573484    if (lpLVItem->iSubItem)
    34583485        bResult = set_sub_item(infoPtr, lpLVItem, TRUE, &bChanged);
     
    35093536        if ((lStyle & WS_VSCROLL) && GetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo))
    35103537            nItem = scrollInfo.nPos;
    3511     }
     3538    } 
    35123539    else
    35133540    {
     
    35173544
    35183545    TRACE("nItem=%d\n", nItem);
    3519 
     3546   
    35203547    return nItem;
    35213548}
     
    35653592    WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' };
    35663593    WCHAR szCallback[] = { '(', 'c', 'a', 'l', 'l', 'b', 'a', 'c', 'k', ')', 0 };
    3567     DWORD cditemmode = CDRF_DODEFAULT;
     3594    DWORD cdsubitemmode = CDRF_DODEFAULT;
    35683595    RECT* lprcFocus, rcSelect, rcBox, rcState, rcIcon, rcLabel;
    35693596    NMLVCUSTOMDRAW nmlvcd;
    35703597    HIMAGELIST himl;
    35713598    LVITEMW lvItem;
    3572 
    35733599#ifdef __WIN32OS2__
    35743600    DWORD dwBkColor;
     
    35933619    lvItem.pszText = szDispText;
    35943620    if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE;
    3595     if (nSubItem > 0 && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
     3621    if (nSubItem > 0 && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) 
    35963622        lvItem.state = LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED);
    35973623    if (lvItem.pszText == LPSTR_TEXTCALLBACKW) lvItem.pszText = szCallback;
     
    36003626    /* now check if we need to update the focus rectangle */
    36013627    lprcFocus = infoPtr->bFocus && (lvItem.state & LVIS_FOCUSED) ? &infoPtr->rcFocus : 0;
    3602 
     3628   
    36033629    if (!lprcFocus) lvItem.state &= ~LVIS_FOCUSED;
    36043630    LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, &rcState, &rcIcon, &rcLabel);
     
    36073633    OffsetRect(&rcIcon, pos.x, pos.y);
    36083634    OffsetRect(&rcLabel, pos.x, pos.y);
    3609     TRACE("    rcBox=%s, rcState=%s, rcIcon=%s. rcLabel=%s\n",
     3635    TRACE("    rcBox=%s, rcState=%s, rcIcon=%s. rcLabel=%s\n", 
    36103636        debugrect(&rcBox), debugrect(&rcState), debugrect(&rcIcon), debugrect(&rcLabel));
    36113637
     
    36133639    customdraw_fill(&nmlvcd, infoPtr, hdc, &rcBox, &lvItem);
    36143640
     3641    if (nSubItem > 0) cdmode = infoPtr->cditemmode;
    36153642    if (cdmode & CDRF_NOTIFYITEMDRAW)
    3616         cditemmode = notify_prepaint (infoPtr, hdc, &nmlvcd);
    3617     if (nSubItem == 0) infoPtr->cditemmode = cditemmode;
    3618     if (cditemmode & CDRF_SKIPDEFAULT) goto postpaint;
     3643        cdsubitemmode = notify_customdraw(infoPtr, CDDS_PREPAINT, &nmlvcd);
     3644    if (nSubItem == 0) infoPtr->cditemmode = cdsubitemmode;
     3645    if (cdsubitemmode & CDRF_SKIPDEFAULT) goto postpaint;
     3646    /* we have to send a CDDS_SUBITEM customdraw explicitly for subitem 0 */
     3647    if (nSubItem == 0 && cdsubitemmode == CDRF_NOTIFYITEMDRAW)
     3648    {
     3649        cdsubitemmode = notify_customdraw(infoPtr, CDDS_SUBITEM | CDDS_ITEMPREPAINT, &nmlvcd);
     3650        if (cdsubitemmode & CDRF_SKIPDEFAULT) goto postpaint;
     3651    }
     3652    if (nSubItem == 0 || (cdmode & CDRF_NOTIFYITEMDRAW))
     3653        prepaint_setup(infoPtr, hdc, &nmlvcd);
    36193654
    36203655    /* in full row select, subitems, will just use main item's colors */
    36213656    if (nSubItem && uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
    36223657        nmlvcd.clrTextBk = CLR_NONE;
    3623 
     3658   
    36243659    /* state icons */
    36253660    if (infoPtr->himlState && !IsRectEmpty(&rcState))
     
    36903725        if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
    36913726            rcSelect.right = rcBox.right;
    3692 
    3693         if (nmlvcd.clrTextBk != CLR_NONE)
     3727   
     3728        if (nmlvcd.clrTextBk != CLR_NONE) 
    36943729#ifdef __WIN32OS2__
    36953730            ExtTextOutW(hdc, rcSelect.left, rcSelect.top, textoutOptions, &rcSelect, 0, 0, 0);
     
    36993734        if(lprcFocus) *lprcFocus = rcSelect;
    37003735    }
    3701 
     3736   
    37023737    /* figure out the text drawing flags */
    37033738    uFormat = (uView == LVS_ICON ? (lprcFocus ? LV_FL_DT_FLAGS : LV_ML_DT_FLAGS) : LV_SL_DT_FLAGS);
     
    37223757
    37233758postpaint:
    3724     if (cditemmode & CDRF_NOTIFYPOSTPAINT)
     3759    if (cdsubitemmode & CDRF_NOTIFYPOSTPAINT)
    37253760        notify_postpaint(infoPtr, &nmlvcd);
     3761
    37263762
    37273763#ifdef __WIN32OS2__
     
    37353771  }
    37363772#endif
    3737 
    37383773    return TRUE;
    37393774}
     
    37533788{
    37543789    UINT uID = GetWindowLongW(infoPtr->hwndSelf, GWL_ID);
    3755     HWND hwndParent = GetParent(infoPtr->hwndSelf);
    37563790    DWORD cditemmode = CDRF_DODEFAULT;
    37573791    NMLVCUSTOMDRAW nmlvcd;
     
    37593793    DRAWITEMSTRUCT dis;
    37603794    LVITEMW item;
    3761 
     3795   
    37623796    TRACE("()\n");
    37633797
    37643798    ZeroMemory(&dis, sizeof(dis));
    3765 
     3799   
    37663800    /* Get scroll info once before loop */
    37673801    LISTVIEW_GetOrigin(infoPtr, &Origin);
    3768 
     3802   
    37693803    /* iterate through the invalidated rows */
    37703804    while(iterator_next(i))
     
    37753809        item.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
    37763810        if (!LISTVIEW_GetItemW(infoPtr, &item)) continue;
    3777        
     3811           
    37783812        dis.CtlType = ODT_LISTVIEW;
    37793813        dis.CtlID = uID;
     
    37943828        TRACE("item=%s, rcItem=%s\n", debuglvitem_t(&item, TRUE), debugrect(&dis.rcItem));
    37953829
     3830    /*
     3831     * Even if we do not send the CDRF_NOTIFYITEMDRAW we need to fill the nmlvcd
     3832     * structure for the rest. of the paint cycle
     3833     */
     3834        customdraw_fill(&nmlvcd, infoPtr, hdc, &dis.rcItem, &item);
    37963835        if (cdmode & CDRF_NOTIFYITEMDRAW)
     3836            cditemmode = notify_customdraw(infoPtr, CDDS_PREPAINT, &nmlvcd);
     3837   
     3838        if (!(cditemmode & CDRF_SKIPDEFAULT))
    37973839        {
    3798             customdraw_fill(&nmlvcd, infoPtr, hdc, &dis.rcItem, &item);
    3799             cditemmode = notify_prepaint (infoPtr, hdc, &nmlvcd);
     3840            prepaint_setup (infoPtr, hdc, &nmlvcd);
     3841            SendMessageW(infoPtr->hwndNotify, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
    38003842        }
    3801 
    3802         if (!(cditemmode & CDRF_SKIPDEFAULT))
    3803             SendMessageW(hwndParent, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
    38043843
    38053844        if (cditemmode & CDRF_NOTIFYPOSTPAINT)
     
    38333872    rgntype = GetClipBox(hdc, &rcClip);
    38343873    if (rgntype == NULLREGION) return;
    3835 
     3874   
    38363875    /* Get scroll info once before loop */
    38373876    LISTVIEW_GetOrigin(infoPtr, &Origin);
    3838 
     3877   
    38393878    /* narrow down the columns we need to paint */
    3840     for(colRange.lower = 0; colRange.lower < infoPtr->hdpaColumns->nItemCount; colRange.lower++)
     3879    for(colRange.lower = 0; colRange.lower < DPA_GetPtrCount(infoPtr->hdpaColumns); colRange.lower++)
    38413880    {
    38423881        LISTVIEW_GetHeaderRect(infoPtr, colRange.lower, &rcItem);
    38433882        if (rcItem.right + Origin.x >= rcClip.left) break;
    38443883    }
    3845     for(colRange.upper = infoPtr->hdpaColumns->nItemCount; colRange.upper > 0; colRange.upper--)
     3884    for(colRange.upper = DPA_GetPtrCount(infoPtr->hdpaColumns); colRange.upper > 0; colRange.upper--)
    38463885    {
    38473886        LISTVIEW_GetHeaderRect(infoPtr, colRange.upper - 1, &rcItem);
     
    38973936    /* Get scroll info once before loop */
    38983937    LISTVIEW_GetOrigin(infoPtr, &Origin);
    3899 
     3938   
    39003939    while(iterator_prev(i))
    39013940    {
     
    39323971
    39333972    LISTVIEW_DUMP(infoPtr);
    3934 
     3973 
    39353974    infoPtr->bIsDrawing = TRUE;
    39363975
     
    39433982    oldClrTextBk = infoPtr->clrTextBk;
    39443983    oldClrText   = infoPtr->clrText;
    3945 
     3984   
    39463985    infoPtr->cditemmode = CDRF_DODEFAULT;
    39473986
    39483987    GetClientRect(infoPtr->hwndSelf, &rcClient);
    39493988    customdraw_fill(&nmlvcd, infoPtr, hdc, &rcClient, 0);
    3950     cdmode = notify_prepaint(infoPtr, hdc, &nmlvcd);
     3989    cdmode = notify_customdraw(infoPtr, CDDS_PREPAINT, &nmlvcd);
    39513990    if (cdmode & CDRF_SKIPDEFAULT) goto enddraw;
     3991    prepaint_setup(infoPtr, hdc, &nmlvcd);
    39523992
    39533993    /* Use these colors to draw the items */
     
    39604000    /* figure out what we need to draw */
    39614001    iterator_visibleitems(&i, infoPtr, hdc);
    3962 
     4002   
    39634003    /* send cache hint notification */
    39644004    if (infoPtr->dwStyle & LVS_OWNERDATA)
     
    39874027    }
    39884028    iterator_destroy(&i);
    3989 
     4029   
    39904030enddraw:
    39914031    if (cdmode & CDRF_NOTIFYPOSTPAINT)
     
    40604100  }
    40614101  else if (uView == LVS_REPORT)
     4102  {
    40624103#ifdef __WIN32OS2__
    40634104  {
     
    40994140  }
    41004141#else
    4101     FIXME("uView == LVS_REPORT: not implemented\n");
     4142    RECT rcBox;
     4143
     4144    if (infoPtr->nItemCount > 0)
     4145    {
     4146      LISTVIEW_GetItemBox(infoPtr, 0, &rcBox);
     4147      wWidth = rcBox.right - rcBox.left;
     4148      wHeight = (rcBox.bottom - rcBox.top) * nItemCount;
     4149    }
     4150    else
     4151    {
     4152      /* use current height and width */
     4153      if (wHeight == 0xffff)
     4154          wHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;
     4155      if (wWidth == 0xffff)
     4156          wWidth = infoPtr->rcList.right - infoPtr->rcList.left;
     4157    }
     4158
     4159    dwViewRect = MAKELONG(wWidth, wHeight);
    41024160#endif
     4161  }
    41034162  else if (uView == LVS_SMALLICON)
    41044163    FIXME("uView == LVS_SMALLICON: not implemented\n");
     
    41544213    rcItem.bottom = size.cy;
    41554214    FillRect(hdc, &rcItem, infoPtr->hBkBrush);
    4156 
     4215   
    41574216    pos.x = pos.y = 0;
    41584217    if (LISTVIEW_DrawItem(infoPtr, hdc, iItem, 0, pos, infoPtr->cditemmode))
     
    42164275        {
    42174276            hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, i);
    4218             for (j = 0; j < hdpaSubItems->nItemCount; j++)
     4277            for (j = 0; j < DPA_GetPtrCount(hdpaSubItems); j++)
    42194278            {
    42204279                hdrItem = (ITEMHDR *)DPA_GetPtr(hdpaSubItems, j);
    4221                 if (is_textW(hdrItem->pszText)) COMCTL32_Free(hdrItem->pszText);
    4222                 COMCTL32_Free(hdrItem);
     4280                if (is_textW(hdrItem->pszText)) Free(hdrItem->pszText);
     4281                Free(hdrItem);
    42234282            }
    42244283            DPA_Destroy(hdpaSubItems);
     
    42294288        infoPtr->nItemCount --;
    42304289    }
    4231 
     4290   
    42324291    LISTVIEW_UpdateScroll(infoPtr);
    42334292
    42344293    LISTVIEW_InvalidateList(infoPtr);
    4235 
     4294   
    42364295    return TRUE;
    42374296}
     
    42544313    RECT rcOld, rcCol;
    42554314    INT nCol;
    4256 
    4257     lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, min(nColumn, infoPtr->hdpaColumns->nItemCount - 1));
     4315   
     4316    if (nColumn < 0 || DPA_GetPtrCount(infoPtr->hdpaColumns) < 1) return;
     4317    lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, min(nColumn, DPA_GetPtrCount(infoPtr->hdpaColumns) - 1));
    42584318    rcCol = lpColumnInfo->rcHeader;
    4259     if (nColumn >= infoPtr->hdpaColumns->nItemCount)
     4319    if (nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns))
    42604320        rcCol.left = rcCol.right;
    4261 
     4321   
    42624322    /* ajust the other columns */
    4263     for (nCol = nColumn; nCol < infoPtr->hdpaColumns->nItemCount; nCol++)
     4323    for (nCol = nColumn; nCol < DPA_GetPtrCount(infoPtr->hdpaColumns); nCol++)
    42644324    {
    42654325        lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, nCol);
     
    42704330    /* do not update screen if not in report mode */
    42714331    if (!is_redrawing(infoPtr) || (infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return;
    4272 
     4332   
    42734333    /* if we have a focus, must first erase the focus rect */
    42744334    if (infoPtr->bFocus) LISTVIEW_ShowFocusRect(infoPtr, FALSE);
    4275 
     4335   
    42764336    /* Need to reset the item width when inserting a new column */
    42774337    infoPtr->nItemWidth += dx;
     
    42834343    rcOld.left = rcCol.left;
    42844344    ScrollWindowEx(infoPtr->hwndSelf, dx, 0, &rcOld, &rcOld, 0, 0, SW_ERASE | SW_INVALIDATE);
    4285 
     4345   
    42864346    /* we can restore focus now */
    42874347    if (infoPtr->bFocus) LISTVIEW_ShowFocusRect(infoPtr, TRUE);
     
    43034363{
    43044364    RECT rcCol;
    4305 
     4365   
    43064366    TRACE("nColumn=%d\n", nColumn);
    43074367
    4308     if (nColumn < 0 || infoPtr->hdpaColumns->nItemCount == 0
    4309            || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;
     4368    if (nColumn < 0 || DPA_GetPtrCount(infoPtr->hdpaColumns) == 0
     4369           || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE;
    43104370
    43114371    /* While the MSDN specifically says that column zero should not be deleted,
    43124372       it does in fact work on WinNT, and at least one app depends on it. On
    43134373       WinNT, deleting column zero deletes the last column of items but the
    4314        first header. Since no app will ever depend on that bizarre behavior,
     4374       first header. Since no app will ever depend on that bizarre behavior, 
    43154375       we just delete the last column including the header.
    43164376     */
    43174377    if (nColumn == 0)
    4318         nColumn = infoPtr->hdpaColumns->nItemCount - 1;
     4378        nColumn = DPA_GetPtrCount(infoPtr->hdpaColumns) - 1;
    43194379
    43204380    LISTVIEW_GetHeaderRect(infoPtr, nColumn, &rcCol);
    4321 
     4381   
    43224382    if (!Header_DeleteItem(infoPtr->hwndHeader, nColumn))
    43234383        return FALSE;
    43244384
    4325     COMCTL32_Free(DPA_GetPtr(infoPtr->hdpaColumns, nColumn));
     4385    Free(DPA_GetPtr(infoPtr->hdpaColumns, nColumn));
    43264386    DPA_DeletePtr(infoPtr->hdpaColumns, nColumn);
    4327 
     4387 
    43284388    if (!(infoPtr->dwStyle & LVS_OWNERDATA))
    43294389    {
     
    43344394        if (nColumn == 0)
    43354395            return LISTVIEW_DeleteAllItems(infoPtr);
    4336        
     4396           
    43374397        for (nItem = 0; nItem < infoPtr->nItemCount; nItem++)
    43384398        {
     
    43404400            nSubItem = 0;
    43414401            lpDelItem = 0;
    4342             for (i = 1; i < hdpaSubItems->nItemCount; i++)
     4402            for (i = 1; i < DPA_GetPtrCount(hdpaSubItems); i++)
    43434403            {
    43444404                lpSubItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, i);
     
    43484408                    lpDelItem = lpSubItem;
    43494409                }
    4350                 else if (lpSubItem->iSubItem > nColumn)
     4410                else if (lpSubItem->iSubItem > nColumn) 
    43514411                {
    43524412                    lpSubItem->iSubItem--;
     
    43594419                /* free string */
    43604420                if (is_textW(lpDelItem->hdr.pszText))
    4361                     COMCTL32_Free(lpDelItem->hdr.pszText);
     4421                    Free(lpDelItem->hdr.pszText);
    43624422
    43634423                /* free item */
    4364                 COMCTL32_Free(lpDelItem);
     4424                Free(lpDelItem);
    43654425
    43664426                /* free dpa memory */
     
    43974457    /* if we don't refresh, what's the point of scrolling? */
    43984458    if (!is_redrawing(infoPtr)) return;
    4399 
     4459   
    44004460    assert (abs(dir) == 1);
    44014461
     
    44124472    LISTVIEW_UpdateScroll(infoPtr);
    44134473
    4414     /* figure out the item's position */
     4474    /* figure out the item's position */ 
    44154475    if (uView == LVS_REPORT)
    44164476        nPerCol = infoPtr->nItemCount + 1;
     
    44194479    else /* LVS_ICON, or LVS_SMALLICON */
    44204480        return;
    4421 
     4481   
    44224482    nItemCol = nItem / nPerCol;
    44234483    nItemRow = nItem % nPerCol;
     
    44344494    {
    44354495        TRACE("Scrolling rcScroll=%s, rcList=%s\n", debugrect(&rcScroll), debugrect(&infoPtr->rcList));
    4436         ScrollWindowEx(infoPtr->hwndSelf, 0, dir * infoPtr->nItemHeight,
     4496        ScrollWindowEx(infoPtr->hwndSelf, 0, dir * infoPtr->nItemHeight, 
    44374497                       &rcScroll, &rcScroll, 0, 0, SW_ERASE | SW_INVALIDATE);
    44384498    }
     
    44724532
    44734533    if (nItem < 0 || nItem >= infoPtr->nItemCount) return FALSE;
    4474 
     4534   
    44754535    /* remove selection, and focus */
    44764536    item.state = 0;
    44774537    item.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
    44784538    LISTVIEW_SetItemState(infoPtr, nItem, &item);
    4479        
     4539           
    44804540    /* send LVN_DELETEITEM notification. */
    44814541    notify_deleteitem(infoPtr, nItem);
    44824542
    4483     /* we need to do this here, because we'll be deleting stuff */
     4543    /* we need to do this here, because we'll be deleting stuff */ 
    44844544    if (uView == LVS_SMALLICON || uView == LVS_ICON)
    44854545        LISTVIEW_InvalidateItem(infoPtr, nItem);
    4486 
     4546   
    44874547    if (!(infoPtr->dwStyle & LVS_OWNERDATA))
    44884548    {
     
    44924552
    44934553        hdpaSubItems = (HDPA)DPA_DeletePtr(infoPtr->hdpaItems, nItem); 
    4494         for (i = 0; i < hdpaSubItems->nItemCount; i++)
     4554        for (i = 0; i < DPA_GetPtrCount(hdpaSubItems); i++)
    44954555        {
    44964556            hdrItem = (ITEMHDR *)DPA_GetPtr(hdpaSubItems, i);
    4497             if (is_textW(hdrItem->pszText)) COMCTL32_Free(hdrItem->pszText);
    4498             COMCTL32_Free(hdrItem);
     4557            if (is_textW(hdrItem->pszText)) Free(hdrItem->pszText);
     4558            Free(hdrItem);
    44994559        }
    45004560        DPA_Destroy(hdpaSubItems);
     
    45984658    rect.left = LVIR_LABEL;
    45994659    if (!LISTVIEW_GetItemRect(infoPtr, nItem, &rect)) return 0;
    4600 
     4660   
    46014661    ZeroMemory(&dispInfo, sizeof(dispInfo));
    46024662    dispInfo.item.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;
     
    46114671                    rect.left-2, rect.top-1, 0, rect.bottom - rect.top+2, isW);
    46124672    if (!infoPtr->hwndEdit) return 0;
    4613 
     4673   
    46144674    if (notify_dispinfoT(infoPtr, LVN_BEGINLABELEDITW, &dispInfo, isW))
    46154675    {
     
    46544714
    46554715    if (bPartial && IntersectRect(&rcTemp, &infoPtr->rcList, &rcItem)) return TRUE;
    4656 
     4716   
    46574717    if (rcItem.left < infoPtr->rcList.left || rcItem.right > infoPtr->rcList.right)
    46584718    {
     
    47394799
    47404800    if (!lpFindInfo || nItem < 0) return -1;
    4741 
     4801   
    47424802    lvItem.mask = 0;
    47434803    if (lpFindInfo->flags & (LVFI_STRING | LVFI_PARTIAL))
     
    47514811        bWrap = TRUE;
    47524812
    4753     if ((lpFindInfo->flags & LVFI_NEARESTXY) &&
     4813    if ((lpFindInfo->flags & LVFI_NEARESTXY) && 
    47544814        (uView == LVS_ICON || uView ==LVS_SMALLICON))
    47554815    {
     
    47714831        case VK_END:
    47724832            LISTVIEW_GetAreaRect(infoPtr, &rcArea);
    4773             Destination.x = rcArea.right;
    4774             Destination.y = rcArea.bottom;
     4833            Destination.x = rcArea.right; 
     4834            Destination.y = rcArea.bottom; 
    47754835            break;
    47764836        default: ERR("Unknown vkDirection=%d\n", lpFindInfo->vkDirection);
     
    49094969    HDITEMW hdi;
    49104970
    4911     if (!lpColumn || nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;
     4971    if (!lpColumn || nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE;
    49124972    lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, nColumn);
    49134973
     
    49865046        break;
    49875047    case LVS_REPORT:
    4988         if (nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return 0;
     5048        if (nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return 0;
    49895049        LISTVIEW_GetHeaderRect(infoPtr, nColumn, &rcHeader);
    49905050        nColumnWidth = rcHeader.right - rcHeader.left;
     
    50705130 *   that, so it's not a problem.
    50715131 *   For the two cases when the text must be copied (that is,
    5072  *   for LVM_GETITEM, and LVMGETITEMTEXT), use LISTVIEW_GetItemExtT.
     5132 *   for LVM_GETITEM, and LVM_GETITEMTEXT), use LISTVIEW_GetItemExtT.
    50735133 *
    50745134 * RETURN:
     
    50835143    ITEMHDR* pItemHdr;
    50845144    HDPA hdpaSubItems;
     5145    INT isubitem;
    50855146
    50865147    TRACE("(lpLVItem=%s, isW=%d)\n", debuglvitem_t(lpLVItem, isW), isW);
     
    50905151
    50915152    if (lpLVItem->mask == 0) return TRUE;
     5153
     5154    /* make a local copy */
     5155    isubitem = lpLVItem->iSubItem;
    50925156
    50935157    /* a quick optimization if all we're asked is the focus state
     
    51175181            dispInfo.item.mask = lpLVItem->mask & ~LVIF_PARAM;
    51185182            dispInfo.item.iItem = lpLVItem->iItem;
    5119             dispInfo.item.iSubItem = lpLVItem->iSubItem;
     5183            dispInfo.item.iSubItem = isubitem;
    51205184            if (lpLVItem->mask & LVIF_TEXT)
    51215185            {
     
    51495213       
    51505214        /* we store only a little state, so if we're not asked, we're done */
    5151         if (!(lpLVItem->mask & LVIF_STATE) || lpLVItem->iSubItem) return TRUE;
     5215        if (!(lpLVItem->mask & LVIF_STATE) || isubitem) return TRUE;
    51525216
    51535217        /* if focus is handled by us, report it */
    5154         if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED )
     5218        if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED ) 
    51555219        {
    51565220            lpLVItem->state &= ~LVIS_FOCUSED;
     
    51605224
    51615225        /* and do the same for selection, if we handle it */
    5162         if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED )
     5226        if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED ) 
    51635227        {
    51645228            lpLVItem->state &= ~LVIS_SELECTED;
     
    51755239    assert (lpItem);
    51765240
    5177     if (lpLVItem->iSubItem)
    5178     {
    5179         SUBITEM_INFO *lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, lpLVItem->iSubItem);
     5241    if (isubitem)
     5242    {
     5243        SUBITEM_INFO *lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, isubitem);
    51805244        pItemHdr = lpSubItem ? &lpSubItem->hdr : &callbackHdr;
     5245        if (!lpSubItem)
     5246        {
     5247            WARN(" iSubItem invalid (%08x), ignored.\n", isubitem);
     5248            isubitem = 0;
     5249        }
    51815250    }
    51825251    else
     
    51845253
    51855254    /* Do we need to query the state from the app? */
    5186     if ((lpLVItem->mask & LVIF_STATE) && infoPtr->uCallbackMask && lpLVItem->iSubItem == 0)
     5255    if ((lpLVItem->mask & LVIF_STATE) && infoPtr->uCallbackMask && isubitem == 0)
    51875256    {
    51885257        dispInfo.item.mask |= LVIF_STATE;
    51895258        dispInfo.item.stateMask = infoPtr->uCallbackMask;
    51905259    }
    5191 
     5260 
    51925261    /* Do we need to enquire about the image? */
    5193     if ((lpLVItem->mask & LVIF_IMAGE) && pItemHdr->iImage == I_IMAGECALLBACK)
     5262    if ((lpLVItem->mask & LVIF_IMAGE) && pItemHdr->iImage == I_IMAGECALLBACK &&
     5263        (isubitem == 0 || (infoPtr->dwLvExStyle & LVS_EX_SUBITEMIMAGES)))
     5264    {
    51945265        dispInfo.item.mask |= LVIF_IMAGE;
     5266        dispInfo.item.iImage = I_IMAGECALLBACK;
     5267    }
    51955268
    51965269    /* Apps depend on calling back for text if it is NULL or LPSTR_TEXTCALLBACKW */
     
    52085281    {
    52095282        dispInfo.item.iItem = lpLVItem->iItem;
    5210         dispInfo.item.iSubItem = lpLVItem->iSubItem;
     5283        dispInfo.item.iSubItem = lpLVItem->iSubItem; /* yes: the original subitem */
    52115284        dispInfo.item.lParam = lpItem->lParam;
    52125285        notify_dispinfoT(infoPtr, LVN_GETDISPINFOW, &dispInfo, isW);
     
    52155288
    52165289    /* we should not store values for subitems */
    5217     if (lpLVItem->iSubItem) dispInfo.item.mask &= ~LVIF_DI_SETITEM;
     5290    if (isubitem) dispInfo.item.mask &= ~LVIF_DI_SETITEM;
    52185291
    52195292    /* Now, handle the iImage field */
     
    52255298    }
    52265299    else if (lpLVItem->mask & LVIF_IMAGE)
    5227         lpLVItem->iImage = pItemHdr->iImage;
     5300    {
     5301        if(isubitem == 0 || (infoPtr->dwLvExStyle & LVS_EX_SUBITEMIMAGES))
     5302            lpLVItem->iImage = pItemHdr->iImage;
     5303        else
     5304            lpLVItem->iImage = 0;
     5305    }
    52285306
    52295307    /* The pszText field */
     
    52425320
    52435321    /* if this is a subitem, we're done */
    5244     if (lpLVItem->iSubItem) return TRUE;
    5245 
     5322    if (isubitem) return TRUE;
     5323 
    52465324    /* Next is the lParam field */
    52475325    if (dispInfo.item.mask & LVIF_PARAM)
     
    52555333
    52565334    /* ... the state field (this one is different due to uCallbackmask) */
    5257     if (lpLVItem->mask & LVIF_STATE)
     5335    if (lpLVItem->mask & LVIF_STATE) 
    52585336    {
    52595337        lpLVItem->state = lpItem->state;
     
    52635341            lpLVItem->state |= (dispInfo.item.state & dispInfo.item.stateMask);
    52645342        }
    5265         if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED )
     5343        if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED ) 
    52665344        {
    52675345            lpLVItem->state &= ~LVIS_FOCUSED;
     
    52695347                lpLVItem->state |= LVIS_FOCUSED;
    52705348        }
    5271         if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED )
     5349        if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED ) 
    52725350        {
    52735351            lpLVItem->state &= ~LVIS_SELECTED;
    52745352            if (ranges_contain(infoPtr->selectionRanges, lpLVItem->iItem))
    52755353                lpLVItem->state |= LVIS_SELECTED;
    5276         }       
     5354        }          
    52775355    }
    52785356
     
    53545432    lpptPosition->x += Origin.x;
    53555433    lpptPosition->y += Origin.y;
    5356 
     5434   
    53575435    TRACE ("  lpptPosition=%s\n", debugpoint(lpptPosition));
    53585436    return TRUE;
     
    55055583 *             on input, lprc->top = nSubItem
    55065584 *                       lprc->left = LVIR_ICON | LVIR_BOUNDS | LVIR_LABEL
    5507  *
     5585 * 
    55085586 * NOTE: for subItem = 0, we should return the bounds of the _entire_ item,
    55095587 *       not only those of the first column.
    55105588 *       Fortunately, LISTVIEW_GetItemMetrics does the right thing.
    5511  *
     5589 * 
    55125590 * RETURN:
    55135591 *     TRUE: success
     
    55185596    POINT Position;
    55195597    LVITEMW lvItem;
    5520 
    5521     if (!lprc || (infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return FALSE;
     5598   
     5599    if (!lprc) return FALSE;
    55225600
    55235601    TRACE("(nItem=%d, nSubItem=%ld)\n", nItem, lprc->top);
     
    55265604        return LISTVIEW_GetItemRect(infoPtr, nItem, lprc);
    55275605
     5606    if ((infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return FALSE;
     5607
    55285608    if (!LISTVIEW_GetItemPosition(infoPtr, nItem, &Position)) return FALSE;
    55295609
    5530     lvItem.mask = lprc->top == 0 ? LVIF_INDENT : 0;
     5610    lvItem.mask = 0;
    55315611    lvItem.iItem = nItem;
    55325612    lvItem.iSubItem = lprc->top;
    5533 
     5613   
    55345614    if (lvItem.mask && !LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE;
    55355615    switch(lprc->left)
     
    55785658    lvItem.cchTextMax = DISP_TEXT_SIZE;
    55795659    if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return 0;
    5580 
     5660 
    55815661    return LISTVIEW_GetStringWidthT(infoPtr, lvItem.pszText, TRUE);
    55825662}
     
    57025782      uMask |= LVIS_SELECTED;
    57035783
    5704     /* if we're asked for the focused item, that's only one,
     5784    /* if we're asked for the focused item, that's only one, 
    57055785     * so it's worth optimizing */
    57065786    if (uFlags & LVNI_FOCUSED)
     
    57095789        return (infoPtr->nFocusedItem == nItem) ? -1 : infoPtr->nFocusedItem;
    57105790    }
    5711 
     5791   
    57125792    if (uFlags & LVNI_ABOVE)
    57135793    {
     
    58865966    SCROLLINFO scrollInfo;
    58875967
    5888     scrollInfo.cbSize = sizeof(SCROLLINFO);
     5968    scrollInfo.cbSize = sizeof(SCROLLINFO);   
    58895969    scrollInfo.fMask = SIF_POS;
    5890 
     5970   
    58915971    if ((infoPtr->dwStyle & WS_HSCROLL) && GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo))
    58925972        nHorzPos = scrollInfo.nPos;
     
    59025982    else if (uView == LVS_REPORT)
    59035983        nVertPos *= infoPtr->nItemHeight;
    5904 
     5984   
    59055985    lpptOrigin->x -= nHorzPos;
    59065986    lpptOrigin->y -= nVertPos;
     
    59256005{
    59266006    SIZE stringSize;
    5927 
    5928     stringSize.cx = 0;
     6007   
     6008    stringSize.cx = 0;   
    59296009    if (is_textT(lpszText, isW))
    59306010    {
     
    59396019        SelectObject(hdc, hOldFont);
    59406020        ReleaseDC(infoPtr->hwndSelf, hdc);
     6021
    59416022#ifdef __WIN32OS2__
    59426023        if(infoPtr->dwStyle & LVS_OWNERDRAWFIXED) {
    5943         /* Get item width */
    5944 
    5945         MEASUREITEMSTRUCT mis;
    5946         UINT             id = GetWindowLongA(infoPtr->hwndSelf,GWL_ID);
    5947         mis.CtlType    = ODT_LISTVIEW;
    5948         mis.CtlID      = id;
    5949         mis.itemID     = 0;
    5950         mis.itemData   = 0;     //TODO:!!!!
    5951         mis.itemHeight = 0;
    5952         mis.itemWidth  = 0;
    5953         if (isW)
    5954          SendMessageW(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis );
    5955         else
    5956          SendMessageA(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis );
    5957         stringSize.cx  = (mis.itemWidth) ? mis.itemWidth : infoPtr->nItemWidth;
    5958     }
     6024            /* Get item width */
     6025
     6026            MEASUREITEMSTRUCT mis;
     6027            UINT             id = GetWindowLongA(infoPtr->hwndSelf,GWL_ID);
     6028            mis.CtlType    = ODT_LISTVIEW;
     6029            mis.CtlID      = id;
     6030            mis.itemID     = 0;
     6031            mis.itemData   = 0;     //TODO:!!!!
     6032            mis.itemHeight = 0;
     6033            mis.itemWidth  = 0;
     6034            if (isW)
     6035             SendMessageW(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis );
     6036            else
     6037             SendMessageA(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis );
     6038            stringSize.cx  = (mis.itemWidth) ? mis.itemWidth : infoPtr->nItemWidth;
     6039        }
    59596040#endif
    59606041    }
     
    59766057 * an app might pass only a structure with space up to iItem!
    59776058 * (MS Office 97 does that for instance in the file open dialog)
    5978  *
     6059 * 
    59796060 * RETURN:
    59806061 *   SUCCESS : item index
     
    59896070    LVITEMW lvItem;
    59906071    ITERATOR i;
    5991 
     6072    INT iItem;
     6073   
    59926074    TRACE("(pt=%s, subitem=%d, select=%d)\n", debugpoint(&lpht->pt), subitem, select);
    5993 
     6075   
    59946076    lpht->flags = 0;
    59956077    lpht->iItem = -1;
     
    60006082    else if (infoPtr->rcList.right < lpht->pt.x)
    60016083        lpht->flags |= LVHT_TORIGHT;
    6002 
     6084   
    60036085    if (infoPtr->rcList.top > lpht->pt.y)
    60046086        lpht->flags |= LVHT_ABOVE;
     
    60126094
    60136095    LISTVIEW_GetOrigin(infoPtr, &Origin);
    6014 
     6096   
    60156097    /* first deal with the large items */
    60166098    rcSearch.left = lpht->pt.x;
     
    60186100    rcSearch.right = rcSearch.left + 1;
    60196101    rcSearch.bottom = rcSearch.top + 1;
    6020 
     6102   
    60216103    iterator_frameditems(&i, infoPtr, &rcSearch);
    60226104    iterator_next(&i); /* go to first item in the sequence */
    6023     lpht->iItem = i.nItem;
     6105    iItem = i.nItem;
    60246106    iterator_destroy(&i);
    6025 
    6026     TRACE("lpht->iItem=%d\n", lpht->iItem);
    6027     if (lpht->iItem == -1) return -1;
     6107   
     6108    TRACE("lpht->iItem=%d\n", iItem);
     6109    if (iItem == -1) return -1;
    60286110
    60296111    lvItem.mask = LVIF_STATE | LVIF_TEXT;
     
    60316113    lvItem.stateMask = LVIS_STATEIMAGEMASK;
    60326114    if (uView == LVS_ICON) lvItem.stateMask |= LVIS_FOCUSED;
    6033     lvItem.iItem = lpht->iItem;
     6115    lvItem.iItem = iItem;
    60346116    lvItem.iSubItem = 0;
    60356117    lvItem.pszText = szDispText;
    60366118    lvItem.cchTextMax = DISP_TEXT_SIZE;
    60376119    if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return -1;
    6038     if (!infoPtr->bFocus) lvItem.state &= ~LVIS_FOCUSED;
    6039 
     6120    if (!infoPtr->bFocus) lvItem.state &= ~LVIS_FOCUSED; 
     6121   
    60406122    LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, &rcState, &rcIcon, &rcLabel);
    6041     LISTVIEW_GetItemOrigin(infoPtr, lpht->iItem, &Position);
     6123    LISTVIEW_GetItemOrigin(infoPtr, iItem, &Position);
    60426124    opt.x = lpht->pt.x - Position.x - Origin.x;
    60436125    opt.y = lpht->pt.y - Position.y - Origin.y;
    6044 
    6045     if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
     6126   
     6127    if (uView == LVS_REPORT)
    60466128        rcBounds = rcBox;
    60476129    else
     
    60586140    if (lpht->flags & LVHT_ONITEM)
    60596141        lpht->flags &= ~LVHT_NOWHERE;
    6060 
    6061     TRACE("lpht->flags=0x%x\n", lpht->flags);
    6062     if (uView == LVS_REPORT && lpht->iItem != -1 && subitem)
     6142   
     6143    TRACE("lpht->flags=0x%x\n", lpht->flags); 
     6144    if (uView == LVS_REPORT && subitem)
    60636145    {
    60646146        INT j;
    60656147
    60666148        rcBounds.right = rcBounds.left;
    6067         for (j = 0; j < infoPtr->hdpaColumns->nItemCount; j++)
     6149        for (j = 0; j < DPA_GetPtrCount(infoPtr->hdpaColumns); j++)
    60686150        {
    60696151            rcBounds.left = rcBounds.right;
     
    60776159    }
    60786160
    6079     if (!select || lpht->iItem == -1) return lpht->iItem;
    6080 
    6081     if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) return lpht->iItem;
    6082 
    6083     if (uView == LVS_REPORT) UnionRect(&rcBounds, &rcIcon, &rcLabel);
    6084     return PtInRect(&rcBounds, opt) ? lpht->iItem : -1;
     6161    if (select && !(uView == LVS_REPORT &&
     6162                    ((infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT) ||
     6163                     (infoPtr->dwStyle & LVS_OWNERDRAWFIXED))))
     6164    {
     6165        if (uView == LVS_REPORT)
     6166        {
     6167            UnionRect(&rcBounds, &rcIcon, &rcLabel);
     6168            UnionRect(&rcBounds, &rcBounds, &rcState);
     6169        }
     6170        if (!PtInRect(&rcBounds, opt)) iItem = -1;
     6171    }
     6172    return lpht->iItem = iItem;
    60856173}
    60866174
     
    61066194    ITEM_INFO* lv_first = (ITEM_INFO*) DPA_GetPtr( (HDPA)first, 0 );
    61076195    ITEM_INFO* lv_second = (ITEM_INFO*) DPA_GetPtr( (HDPA)second, 0 );
    6108     INT cmpv = textcmpWT(lv_first->hdr.pszText, lv_second->hdr.pszText, TRUE);
     6196    INT cmpv = textcmpWT(lv_first->hdr.pszText, lv_second->hdr.pszText, TRUE); 
    61096197
    61106198    /* if we're sorting descending, negate the return value */
     
    61446232    if (!is_assignable_item(lpLVItem, infoPtr->dwStyle)) return -1;
    61456233
    6146     if ( !(lpItem = (ITEM_INFO *)COMCTL32_Alloc(sizeof(ITEM_INFO))) )
     6234    if ( !(lpItem = (ITEM_INFO *)Alloc(sizeof(ITEM_INFO))) )
    61476235        return -1;
    6148 
     6236   
    61496237    /* insert item in listview control data structure */
    61506238    if ( !(hdpaSubItems = DPA_Create(8)) ) goto fail;
     
    61596247    if (nItem == -1) goto fail;
    61606248    infoPtr->nItemCount++;
     6249
     6250    /* shift indices first so they don't get tangled */
     6251    LISTVIEW_ShiftIndices(infoPtr, nItem, 1);
    61616252
    61626253    /* set the item attributes */
     
    61996290        }
    62006291    }
    6201 
    6202     /* Add the subitem list to the items array. Do this last in case we go to
    6203      * fail during the above.
    6204      */
    6205     LISTVIEW_ShiftIndices(infoPtr, nItem, 1);
    6206 
     6292   
    62076293    /* send LVN_INSERTITEM notification */
    62086294    ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
     
    62296315
    62306316undo:
     6317    LISTVIEW_ShiftIndices(infoPtr, nItem, -1);
    62316318    DPA_DeletePtr(infoPtr->hdpaItems, nItem);
    62326319    infoPtr->nItemCount--;
     
    62346321    DPA_DeletePtr(hdpaSubItems, 0);
    62356322    DPA_Destroy (hdpaSubItems);
    6236     COMCTL32_Free (lpItem);
     6323    Free (lpItem);
    62376324    return -1;
    62386325}
     
    62546341{
    62556342    INT i;
    6256 
    6257     if (nLast < nFirst || min(nFirst, nLast) < 0 ||
     6343 
     6344    if (nLast < nFirst || min(nFirst, nLast) < 0 || 
    62586345        max(nFirst, nLast) >= infoPtr->nItemCount)
    62596346        return FALSE;
    6260 
     6347   
    62616348    for (i = nFirst; i <= nLast; i++)
    62626349        LISTVIEW_InvalidateItem(infoPtr, i);
     
    63156402    if (dx != 0) LISTVIEW_HScroll(infoPtr, SB_INTERNAL, dx, 0);
    63166403    if (dy != 0) LISTVIEW_VScroll(infoPtr, SB_INTERNAL, dy, 0);
    6317 
     6404 
    63186405    return TRUE;
    63196406}
     
    64476534
    64486535    if (!lpColumn || nColumn < 0) return -1;
    6449     nColumn = min(nColumn, infoPtr->hdpaColumns->nItemCount);
    6450 
     6536    nColumn = min(nColumn, DPA_GetPtrCount(infoPtr->hdpaColumns));
     6537   
    64516538    ZeroMemory(&hdi, sizeof(HDITEMW));
    64526539    column_fill_hditem(infoPtr, &hdi, nColumn, lpColumn, isW);
    64536540
    64546541    /* insert item in header control */
    6455     nNewColumn = SendMessageW(infoPtr->hwndHeader,
     6542    nNewColumn = SendMessageW(infoPtr->hwndHeader, 
    64566543                              isW ? HDM_INSERTITEMW : HDM_INSERTITEMA,
    64576544                              (WPARAM)nColumn, (LPARAM)&hdi);
    64586545    if (nNewColumn == -1) return -1;
    64596546    if (nNewColumn != nColumn) ERR("nColumn=%d, nNewColumn=%d\n", nColumn, nNewColumn);
    6460 
    6461     /* create our own column info */
    6462     if (!(lpColumnInfo = COMCTL32_Alloc(sizeof(COLUMN_INFO)))) goto fail;
     6547   
     6548    /* create our own column info */ 
     6549    if (!(lpColumnInfo = Alloc(sizeof(COLUMN_INFO)))) goto fail;
    64636550    if (DPA_InsertPtr(infoPtr->hdpaColumns, nNewColumn, lpColumnInfo) == -1) goto fail;
    64646551
     
    64696556    if (!(infoPtr->dwStyle & LVS_OWNERDATA) && infoPtr->nItemCount > 0)
    64706557    {
    6471         SUBITEM_INFO *lpSubItem, *lpMainItem, **lpNewItems = 0;
     6558        SUBITEM_INFO *lpSubItem;
    64726559        HDPA hdpaSubItems;
    64736560        INT nItem, i;
    6474        
    6475         /* preallocate memory, so we can fail gracefully */
    6476         if (nNewColumn == 0)
    6477         {
    6478             lpNewItems = COMCTL32_Alloc(sizeof(SUBITEM_INFO *) * infoPtr->nItemCount);
    6479             if (!lpNewItems) goto fail;
    6480             for (i = 0; i < infoPtr->nItemCount; i++)
    6481                 if (!(lpNewItems[i] = COMCTL32_Alloc(sizeof(SUBITEM_INFO)))) break;
    6482             if (i != infoPtr->nItemCount)
    6483             {
    6484                 for(; i >=0; i--) COMCTL32_Free(lpNewItems[i]);
    6485                 COMCTL32_Free(lpNewItems);
    6486                 goto fail;
    6487             }
    6488         }
    64896561       
    64906562        for (nItem = 0; nItem < infoPtr->nItemCount; nItem++)
    64916563        {
    64926564            hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem);
    6493             for (i = 1; i < hdpaSubItems->nItemCount; i++)
     6565            for (i = 1; i < DPA_GetPtrCount(hdpaSubItems); i++)
    64946566            {
    64956567                lpSubItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, i);
     
    64976569                    lpSubItem->iSubItem++;
    64986570            }
    6499 
    6500             /* for inserting column 0, we have to special-case the main item */
    6501             if (nNewColumn == 0)
    6502             {
    6503                 lpMainItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, 0);
    6504                 lpSubItem = lpNewItems[nItem];
    6505                 lpSubItem->hdr = lpMainItem->hdr;
    6506                 lpSubItem->iSubItem = 1;
    6507                 ZeroMemory(&lpMainItem->hdr, sizeof(lpMainItem->hdr));
    6508                 lpMainItem->iSubItem = 0;
    6509                 DPA_InsertPtr(hdpaSubItems, 1, lpSubItem);
    6510             }
    65116571        }
    6512 
    6513         COMCTL32_Free(lpNewItems);
    65146572    }
    65156573
    65166574    /* make space for the new column */
    65176575    LISTVIEW_ScrollColumns(infoPtr, nNewColumn + 1, lpColumnInfo->rcHeader.right - lpColumnInfo->rcHeader.left);
    6518 
     6576   
    65196577    return nNewColumn;
    65206578
     
    65246582    {
    65256583        DPA_DeletePtr(infoPtr->hdpaColumns, nNewColumn);
    6526         COMCTL32_Free(lpColumnInfo);
     6584        Free(lpColumnInfo);
    65276585    }
    65286586    return -1;
     
    65506608
    65516609    TRACE("(nColumn=%d, lpColumn=%s, isW=%d)\n", nColumn, debuglvcolumn_t(lpColumn, isW), isW);
    6552 
    6553     if (!lpColumn || nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;
     6610   
     6611    if (!lpColumn || nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE;
    65546612
    65556613    ZeroMemory(&hdi, sizeof(HDITEMW));
     
    66376695
    66386696    /* resize all columns if in LVS_LIST mode */
    6639     if(uView == LVS_LIST)
     6697    if(uView == LVS_LIST) 
    66406698    {
    66416699        infoPtr->nItemWidth = cx;
     
    66446702    }
    66456703
    6646     if (nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;
    6647 
    6648     if (cx == LVSCW_AUTOSIZE || (cx == LVSCW_AUTOSIZE_USEHEADER && nColumn < infoPtr->hdpaColumns->nItemCount -1))
     6704    if (nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE;
     6705
     6706    if (cx == LVSCW_AUTOSIZE || (cx == LVSCW_AUTOSIZE_USEHEADER && nColumn < DPA_GetPtrCount(infoPtr->hdpaColumns) -1))
    66496707    {
    66506708        INT nLabelWidth;
     
    66736731    {
    66746732        /* if iCol is the last column make it fill the remainder of the controls width */
    6675         if(nColumn == infoPtr->hdpaColumns->nItemCount - 1)
     6733        if(nColumn == DPA_GetPtrCount(infoPtr->hdpaColumns) - 1)
    66766734        {
    66776735            RECT rcHeader;
     
    67226780
    67236781/***
     6782 * Creates the checkbox imagelist.  Helper for LISTVIEW_SetExtendedListViewStyle
     6783 *
     6784 */
     6785static HIMAGELIST LISTVIEW_CreateCheckBoxIL(LISTVIEW_INFO *infoPtr)
     6786{
     6787    HDC hdc_wnd, hdc;
     6788    HBITMAP hbm_im, hbm_mask, hbm_orig;
     6789    RECT rc;
     6790    HBRUSH hbr_white = GetStockObject(WHITE_BRUSH);
     6791    HBRUSH hbr_black = GetStockObject(BLACK_BRUSH);
     6792    HIMAGELIST himl;
     6793
     6794    himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
     6795                            ILC_COLOR | ILC_MASK, 2, 2);
     6796    hdc_wnd = GetDC(infoPtr->hwndSelf);
     6797    hdc = CreateCompatibleDC(hdc_wnd);
     6798    hbm_im = CreateCompatibleBitmap(hdc_wnd, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
     6799    hbm_mask = CreateBitmap(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 1, 1, NULL);
     6800    ReleaseDC(infoPtr->hwndSelf, hdc_wnd);
     6801
     6802    rc.left = rc.top = 0;
     6803    rc.right = GetSystemMetrics(SM_CXSMICON);
     6804    rc.bottom = GetSystemMetrics(SM_CYSMICON);
     6805
     6806    hbm_orig = SelectObject(hdc, hbm_mask);
     6807    FillRect(hdc, &rc, hbr_white);
     6808    InflateRect(&rc, -3, -3);
     6809    FillRect(hdc, &rc, hbr_black);
     6810
     6811    SelectObject(hdc, hbm_im);
     6812    DrawFrameControl(hdc, &rc, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_MONO);
     6813    SelectObject(hdc, hbm_orig);
     6814    ImageList_Add(himl, hbm_im, hbm_mask);
     6815
     6816    SelectObject(hdc, hbm_im);
     6817    DrawFrameControl(hdc, &rc, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_MONO | DFCS_CHECKED);
     6818    SelectObject(hdc, hbm_orig);
     6819    ImageList_Add(himl, hbm_im, hbm_mask);
     6820
     6821    DeleteObject(hbm_mask);
     6822    DeleteObject(hbm_im);
     6823    DeleteDC(hdc);
     6824
     6825    return himl;
     6826}
     6827
     6828/***
    67246829 * DESCRIPTION:
    67256830 * Sets the extended listview style.
     
    67446849        infoPtr->dwLvExStyle = dwStyle;
    67456850
     6851    if((infoPtr->dwLvExStyle ^ dwOldStyle) & LVS_EX_CHECKBOXES)
     6852    {
     6853        HIMAGELIST himl = 0;
     6854        if(infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES)
     6855            himl = LISTVIEW_CreateCheckBoxIL(infoPtr);
     6856        LISTVIEW_SetImageList(infoPtr, LVSIL_STATE, himl);
     6857    }
     6858
    67466859    return dwOldStyle;
    67476860}
     
    67616874{
    67626875    HCURSOR oldCursor = infoPtr->hHotCursor;
    6763 
     6876   
    67646877    infoPtr->hHotCursor = hCursor;
    67656878
     
    67836896{
    67846897    INT iOldIndex = infoPtr->nHotItem;
    6785 
     6898   
    67866899    infoPtr->nHotItem = iIndex;
    6787 
     6900   
    67886901    return iOldIndex;
    67896902}
     
    68046917{
    68056918    DWORD oldHoverTime = infoPtr->dwHoverTime;
    6806 
     6919   
    68076920    infoPtr->dwHoverTime = dwHoverTime;
    6808 
     6921   
    68096922    return oldHoverTime;
    68106923}
     
    68286941
    68296942    TRACE("requested=(%d,%d)\n", cx, cy);
    6830 
     6943   
    68316944    /* this is supported only for LVS_ICON style */
    68326945    if (uView != LVS_ICON) return oldspacing;
    6833 
     6946 
    68346947    /* set to defaults, if instructed to */
    68356948    if (cx == -1) cx = GetSystemMetrics(SM_CXICONSPACING);
     
    68436956
    68446957    /* if 0 then compute height */
    6845     if (cy == 0)
     6958    if (cy == 0) 
    68466959        cy = infoPtr->iconSize.cy + 2 * infoPtr->ntmHeight +
    68476960             ICON_BOTTOM_PADDING + ICON_TOP_PADDING + LABEL_VERT_PADDING;
    6848 
     6961   
    68496962
    68506963    infoPtr->iconSpacing.cx = cx;
     
    68526965
    68536966    TRACE("old=(%d,%d), new=(%d,%d), iconSize=(%ld,%ld), ntmH=%d\n",
    6854           LOWORD(oldspacing), HIWORD(oldspacing), cx, cy,
     6967          LOWORD(oldspacing), HIWORD(oldspacing), cx, cy, 
    68556968          infoPtr->iconSize.cx, infoPtr->iconSize.cy,
    68566969          infoPtr->ntmHeight);
     
    68656978{
    68666979    INT cx, cy;
    6867 
     6980   
    68686981    if (himl && ImageList_GetIconSize(himl, &cx, &cy))
    68696982    {
     
    69827095            POINT Origin;
    69837096            RECT rcErase;
    6984        
     7097           
    69857098            LISTVIEW_GetOrigin(infoPtr, &Origin);
    69867099            nFrom = min(nOldCount, nItems);
    69877100            nTo = max(nOldCount, nItems);
    6988 
     7101   
    69897102            if (uView == LVS_REPORT)
    69907103            {
     
    70597172
    70607173    /* This point value seems to be an undocumented feature.
    7061      * The best guess is that it means either at the origin,
     7174     * The best guess is that it means either at the origin, 
    70627175     * or at true beginning of the list. I will assume the origin. */
    70637176    if ((pt.x == -1) && (pt.y == -1))
    70647177        pt = Origin;
    7065 
     7178   
    70667179    if (uView == LVS_ICON)
    70677180    {
     
    71117224        bResult = LISTVIEW_SetItemT(infoPtr, &lvItem, TRUE);
    71127225
     7226    /*
     7227     *update selection mark
     7228     *
     7229     * Investigation on windows 2k showed that selection mark was updated
     7230     * whenever a new selection was made, but if the selected item was
     7231     * unselected it was not updated.
     7232     *
     7233     * we are probably still not 100% accurate, but this at least sets the
     7234     * proper selection mark when it is needed
     7235     */
     7236
     7237    if (bResult && (lvItem.state & lvItem.stateMask & LVIS_SELECTED) &&
     7238        ((infoPtr->nSelectionMark == -1) || (lvItem.iItem <= infoPtr->nSelectionMark)))
     7239    {
     7240        int i;
     7241        infoPtr->nSelectionMark = -1;
     7242        for (i = 0; i < infoPtr->nItemCount; i++)
     7243        {
     7244            if (infoPtr->uCallbackMask & LVIS_SELECTED)
     7245            {
     7246                if (LISTVIEW_GetItemState(infoPtr, i, LVIS_SELECTED))
     7247                {
     7248                    infoPtr->nSelectionMark = i;
     7249                    break;
     7250                }
     7251            }
     7252            else if (ranges_contain(infoPtr->selectionRanges, i))
     7253            {
     7254                infoPtr->nSelectionMark = i;
     7255                break;
     7256            }
     7257        }
     7258    }
     7259
    71137260    return bResult;
    71147261}
     
    71337280
    71347281    if (nItem < 0 && nItem >= infoPtr->nItemCount) return FALSE;
    7135 
     7282   
    71367283    lvItem.iItem = nItem;
    71377284    lvItem.iSubItem = lpLVItem->iSubItem;
     
    71397286    lvItem.pszText = lpLVItem->pszText;
    71407287    lvItem.cchTextMax = lpLVItem->cchTextMax;
    7141 
     7288   
    71427289    TRACE("(nItem=%d, lpLVItem=%s, isW=%d)\n", nItem, debuglvitem_t(&lvItem, isW), isW);
    71437290
    7144     return LISTVIEW_SetItemT(infoPtr, &lvItem, isW);
     7291    return LISTVIEW_SetItemT(infoPtr, &lvItem, isW); 
    71457292}
    71467293
     
    71887335        LISTVIEW_InvalidateList(infoPtr);
    71897336    }
    7190 
     7337   
    71917338  return TRUE;
    71927339}
     
    72547401static INT WINAPI LISTVIEW_CallBackCompare(LPVOID first, LPVOID second, LPARAM lParam)
    72557402{
    7256   LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW((HWND)lParam, 0);
     7403  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)lParam;
    72577404  ITEM_INFO* lv_first = (ITEM_INFO*) DPA_GetPtr( (HDPA)first, 0 );
    72587405  ITEM_INFO* lv_second = (ITEM_INFO*) DPA_GetPtr( (HDPA)second, 0 );
     
    73027449    /*        clear the lpItem->state for non-selected ones */
    73037450    /*        remove the selection ranges */
    7304 
     7451   
    73057452    infoPtr->pfnCompare = pfnCompare;
    73067453    infoPtr->lParamSort = lParamSort;
    7307     DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, (LPARAM)infoPtr->hwndSelf);
     7454    DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, (LPARAM)infoPtr);
    73087455
    73097456    /* Adjust selections and indices so that they are the way they should
     
    73907537
    73917538  /* initialize info pointer */
    7392   infoPtr = (LISTVIEW_INFO *)COMCTL32_Alloc(sizeof(LISTVIEW_INFO));
     7539  infoPtr = (LISTVIEW_INFO *)Alloc(sizeof(LISTVIEW_INFO));
    73937540  if (!infoPtr) return -1;
    73947541
     
    73987545  infoPtr->dwStyle = lpcs->style;
    73997546  /* determine the type of structures to use */
    7400   infoPtr->notifyFormat = SendMessageW(GetParent(infoPtr->hwndSelf), WM_NOTIFYFORMAT,
     7547  infoPtr->hwndNotify = lpcs->hwndParent;
     7548  infoPtr->notifyFormat = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT,
    74017549                                       (WPARAM)infoPtr->hwndSelf, (LPARAM)NF_QUERY);
    74027550
     
    74127560  infoPtr->nHotItem = -1;
    74137561  infoPtr->bRedraw = TRUE;
    7414   infoPtr->bFirstPaint = TRUE;
    74157562  infoPtr->bNoItemMetrics = TRUE;
    74167563  infoPtr->bDoChangeNotify = TRUE;
     
    74527599  /* init item size to avoid division by 0 */
    74537600  LISTVIEW_UpdateItemSize (infoPtr);
    7454 
     7601 
    74557602  if (uView == LVS_REPORT)
    74567603  {
     
    74767623    DPA_Destroy(infoPtr->hdpaPosY);
    74777624    DPA_Destroy(infoPtr->hdpaColumns);
    7478     COMCTL32_Free(infoPtr);
     7625    Free(infoPtr);
    74797626    return -1;
    74807627}
     
    75177664{
    75187665    /* now we can scroll the list */
    7519     ScrollWindowEx(infoPtr->hwndSelf, dx, dy, &infoPtr->rcList,
     7666    ScrollWindowEx(infoPtr->hwndSelf, dx, dy, &infoPtr->rcList, 
    75207667                   &infoPtr->rcList, 0, 0, SW_ERASE | SW_INVALIDATE);
    75217668    /* if we have focus, adjust rect */
     
    75447691 *
    75457692 */
    7546 static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *infoPtr, INT nScrollCode,
     7693static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *infoPtr, INT nScrollCode, 
    75477694                                INT nScrollDiff, HWND hScrollWnd)
    75487695{
     
    75527699    BOOL is_an_icon;
    75537700
    7554     TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode,
     7701    TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, 
    75557702        debugscrollcode(nScrollCode), nScrollDiff);
    75567703
     
    75977744    /* quit right away if pos isn't changing */
    75987745    if (nScrollDiff == 0) return 0;
    7599 
     7746   
    76007747    /* calculate new position, and handle overflows */
    76017748    nNewScrollPos = scrollInfo.nPos + nScrollDiff;
     
    76147761    scrollInfo.nPos = nNewScrollPos;
    76157762    nNewScrollPos = SetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo, TRUE);
    7616 
     7763   
    76177764    /* carry on only if it really changed */
    76187765    if (nNewScrollPos == nOldScrollPos) return 0;
    7619 
     7766   
    76207767    /* now adjust to client coordinates */
    76217768    nScrollDiff = nOldScrollPos - nNewScrollPos;
    76227769    if (uView == LVS_REPORT) nScrollDiff *= infoPtr->nItemHeight;
    7623 
    7624     /* and scroll the window */
     7770   
     7771    /* and scroll the window */ 
    76257772    scroll_list(infoPtr, 0, nScrollDiff);
    76267773
     
    76567803    SCROLLINFO scrollInfo;
    76577804
    7658     TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode,
     7805    TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, 
    76597806        debugscrollcode(nScrollCode), nScrollDiff);
    76607807
     
    77007847    /* quit right away if pos isn't changing */
    77017848    if (nScrollDiff == 0) return 0;
    7702 
     7849   
    77037850    /* calculate new position, and handle overflows */
    77047851    nNewScrollPos = scrollInfo.nPos + nScrollDiff;
     
    77177864    scrollInfo.nPos = nNewScrollPos;
    77187865    nNewScrollPos = SetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo, TRUE);
    7719 
     7866   
    77207867    /* carry on only if it really changed */
    77217868    if (nNewScrollPos == nOldScrollPos) return 0;
    7722 
     7869   
    77237870    if(uView == LVS_REPORT)
    77247871        LISTVIEW_UpdateHeaderSize(infoPtr, nNewScrollPos);
    7725 
     7872     
    77267873    /* now adjust to client coordinates */
    77277874    nScrollDiff = nOldScrollPos - nNewScrollPos;
    77287875    if (uView == LVS_LIST) nScrollDiff *= infoPtr->nItemWidth;
    7729 
     7876   
    77307877    /* and scroll the window */
    77317878    scroll_list(infoPtr, nScrollDiff, 0);
     
    78848031    /* if we did not have the focus, there's nothing to do */
    78858032    if (!infoPtr->bFocus) return 0;
    7886 
     8033   
    78878034    /* send NM_KILLFOCUS notification */
    78888035    notify(infoPtr, NM_KILLFOCUS);
     
    78908037    /* if we have a focus rectagle, get rid of it */
    78918038    LISTVIEW_ShowFocusRect(infoPtr, FALSE);
    7892 
     8039   
    78938040    /* set window focus flag */
    78948041    infoPtr->bFocus = FALSE;
     
    78968043    /* invalidate the selected items before reseting focus flag */
    78978044    LISTVIEW_InvalidateSelectedItems(infoPtr);
    7898 
     8045   
    78998046    return 0;
    79008047}
     
    79918138
    79928139    /* To send the LVN_ITEMACTIVATE, it must be on an Item */
    7993     if(htInfo.iItem != -1) notify(infoPtr, LVN_ITEMACTIVATE);
     8140    if(htInfo.iItem != -1) notify_itemactivate(infoPtr,&htInfo);
    79948141
    79958142    return 0;
     
    81228269#ifdef __WIN32OS2__
    81238270  //SvL: Send WM_COMMAND as well. (also done by NT's comctl32)
    8124   SendMessageA(GetParent(infoPtr->hwndSelf), WM_COMMAND, (1<<16) | GetWindowLongW(infoPtr->hwndSelf, GWL_ID), infoPtr->hwndSelf);
     8271  SendMessageA(infoPtr->hwndNotify, WM_COMMAND, (1<<16) | GetWindowLongW(infoPtr->hwndSelf, GWL_ID), infoPtr->hwndSelf);
    81258272#endif
    8126 
    81278273  return 0;
    81288274}
     
    81438289{
    81448290    LVHITTESTINFO lvHitTestInfo;
    8145 
     8291   
    81468292    TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y);
    81478293
     
    82088354
    82098355  /* free listview info pointer*/
    8210   COMCTL32_Free(infoPtr);
     8356  Free(infoPtr);
    82118357
    82128358  return 0;
     
    82288374{
    82298375    UINT uView =  infoPtr->dwStyle & LVS_TYPEMASK;
    8230 
     8376   
    82318377    TRACE("(lpnmh=%p)\n", lpnmh);
    82328378
    8233     if (!lpnmh || lpnmh->iItem < 0 || lpnmh->iItem >= infoPtr->hdpaColumns->nItemCount) return 0;
    8234 
     8379    if (!lpnmh || lpnmh->iItem < 0 || lpnmh->iItem >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return 0;
     8380   
    82358381    switch (lpnmh->hdr.code)
    8236     {
     8382    {   
    82378383        case HDN_TRACKW:
    82388384        case HDN_TRACKA:
     
    82468392            {
    82478393                HDITEMW hdi;
    8248 
     8394   
    82498395                hdi.mask = HDI_WIDTH;
    82508396                if (!Header_GetItemW(infoPtr->hwndHeader, lpnmh->iItem, (LPARAM)&hdi)) return 0;
     
    82538399            else
    82548400                cxy = lpnmh->pitem->cxy;
    8255        
     8401           
    82568402            /* determine how much we change since the last know position */
    82578403            lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, lpnmh->iItem);
     
    83138459
    83148460    if (nCommand != NF_REQUERY) return 0;
    8315 
     8461   
    83168462    infoPtr->notifyFormat = SendMessageW(hwndFrom, WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
    8317 
     8463   
    83188464    return 0;
    83198465}
     
    83348480    TRACE("(hdc=%p)\n", hdc);
    83358481
    8336     infoPtr->bFirstPaint = FALSE;
    83378482    if (infoPtr->bNoItemMetrics && infoPtr->nItemCount)
    83388483    {
     
    83458490        LISTVIEW_UpdateScroll(infoPtr);
    83468491    }
    8347     if (hdc)
     8492    if (hdc) 
    83488493        LISTVIEW_Refresh(infoPtr, hdc);
    83498494    else
     
    83768521{
    83778522    LVHITTESTINFO lvHitTestInfo;
    8378 
     8523   
    83798524    TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y);
    83808525
     
    84238568    lvHitTestInfo.pt.y = pts.y;
    84248569    nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
    8425 
     8570 
    84268571    if ((nItem >= 0) && (nItem < infoPtr->nItemCount))
    84278572    {
     
    84598604
    84608605    if (!infoPtr->bRButtonDown) return 0;
    8461 
     8606 
    84628607    /* set button flag */
    84638608    infoPtr->bRButtonDown = FALSE;
     
    85288673    /* if we have the focus already, there's nothing to do */
    85298674    if (infoPtr->bFocus) return 0;
    8530 
     8675   
    85318676    /* send NM_SETFOCUS notification */
    85328677    notify(infoPtr, NM_SETFOCUS);
     
    85648709    infoPtr->hFont = hFont ? hFont : infoPtr->hDefaultFont;
    85658710    if (infoPtr->hFont == oldFont) return 0;
    8566 
     8711   
    85678712    LISTVIEW_SaveTextMetrics(infoPtr);
    85688713
     
    85978742
    85988743    if(!bRedraw) return 0;
    8599 
     8744   
    86008745    if (is_autoarrange(infoPtr))
    86018746        LISTVIEW_Arrange(infoPtr, LVA_DEFAULT);
     
    86308775    LISTVIEW_UpdateSize(infoPtr);
    86318776    if (EqualRect(&rcOld, &infoPtr->rcList)) return 0;
    8632 
    8633     /* do not bother with display related stuff if we're not redrawing */
     8777 
     8778    /* do not bother with display related stuff if we're not redrawing */ 
    86348779    if (!is_redrawing(infoPtr)) return 0;
    8635 
    8636     if (is_autoarrange(infoPtr))
     8780   
     8781    if (is_autoarrange(infoPtr)) 
    86378782        LISTVIEW_Arrange(infoPtr, LVA_DEFAULT);
    86388783
     
    86408785
    86418786    /* refresh all only for lists whose height changed significantly */
    8642     if ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_LIST &&
     8787    if ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_LIST && 
    86438788        (rcOld.bottom - rcOld.top) / infoPtr->nItemHeight !=
    86448789        (infoPtr->rcList.bottom - infoPtr->rcList.top) / infoPtr->nItemHeight)
     
    86638808
    86648809    TRACE("uView=%d, rcList(old)=%s\n", uView, debugrect(&infoPtr->rcList));
    8665 
     8810   
    86668811    GetClientRect(infoPtr->hwndSelf, &infoPtr->rcList);
    86678812
     
    87188863
    87198864    if (wStyleType != GWL_STYLE) return 0;
    8720 
     8865 
    87218866    /* FIXME: if LVS_NOSORTHEADER changed, update header */
    87228867    /*        what if LVS_OWNERDATA changed? */
     
    87388883        SIZE oldIconSize = infoPtr->iconSize;
    87398884        HIMAGELIST himl;
    8740 
     8885   
    87418886        SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0);
    87428887        ShowWindow(infoPtr->hwndHeader, SW_HIDE);
     
    87478892        himl = (uNewView == LVS_ICON ? infoPtr->himlNormal : infoPtr->himlSmall);
    87488893        set_icon_size(&infoPtr->iconSize, himl, uNewView != LVS_ICON);
    8749 
     8894   
    87508895        if (uNewView == LVS_ICON)
    87518896        {
     
    87738918    if (uNewView == LVS_REPORT)
    87748919        ShowWindow(infoPtr->hwndHeader, (lpss->styleNew & LVS_NOCOLUMNHEADER) ? SW_HIDE : SW_SHOWNORMAL);
    8775 
     8920     
    87768921    if ( (uNewView == LVS_ICON || uNewView == LVS_SMALLICON) &&
    87778922         (uNewView != uOldView || ((lpss->styleNew ^ lpss->styleOld) & LVS_ALIGNMASK)) )
     
    90859230  TRACE("(uMsg=%x wParam=%x lParam=%lx)\n", uMsg, wParam, lParam);
    90869231#endif
     9232
    90879233  if (!infoPtr && (uMsg != WM_CREATE))
    90889234    return DefWindowProcW(hwnd, uMsg, wParam, lParam);
     
    93409486
    93419487  case LVM_SETCOLUMNWIDTH:
    9342     return LISTVIEW_SetColumnWidth(infoPtr, (INT)wParam, SLOWORD(lParam));
     9488    return LISTVIEW_SetColumnWidth(infoPtr, (INT)wParam, (short)LOWORD(lParam));
    93439489
    93449490  case LVM_SETEXTENDEDLISTVIEWSTYLE:
     
    93599505
    93609506  case LVM_SETICONSPACING:
    9361     return LISTVIEW_SetIconSpacing(infoPtr, SLOWORD(lParam), SHIWORD(lParam));
     9507    return LISTVIEW_SetIconSpacing(infoPtr, (short)LOWORD(lParam), (short)HIWORD(lParam));
    93629508
    93639509  case LVM_SETIMAGELIST:
     
    93819527  case LVM_SETITEMPOSITION:
    93829528    {
    9383         POINT pt = { SLOWORD(lParam), SHIWORD(lParam) };
     9529        POINT pt;
     9530        pt.x = (short)LOWORD(lParam);
     9531        pt.y = (short)HIWORD(lParam);
    93849532        return LISTVIEW_SetItemPosition(infoPtr, (INT)wParam, pt);
    93859533    }
     
    95199667
    95209668  case WM_SIZE:
    9521     return LISTVIEW_Size(infoPtr, (int)SLOWORD(lParam), (int)SHIWORD(lParam));
     9669    return LISTVIEW_Size(infoPtr, (short)LOWORD(lParam), (short)HIWORD(lParam));
    95229670
    95239671  case WM_STYLECHANGED:
     
    95399687
    95409688  case WM_WINDOWPOSCHANGED:
    9541       if (!(((WINDOWPOS *)lParam)->flags & SWP_NOSIZE))
     9689      if (!(((WINDOWPOS *)lParam)->flags & SWP_NOSIZE)) 
    95429690      {
    95439691          SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE |
     
    95819729    wndClass.cbClsExtra = 0;
    95829730    wndClass.cbWndExtra = sizeof(LISTVIEW_INFO *);
    9583     wndClass.hCursor = LoadCursorW(0, IDC_ARROWW);
     9731    wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROWW);
    95849732    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    95859733    wndClass.lpszClassName = WC_LISTVIEWW;
     
    96679815
    96689816        default:
    9669           return SendMessageW (GetParent (infoPtr->hwndSelf), WM_COMMAND, wParam, lParam);
     9817          return SendMessageW (infoPtr->hwndNotify, WM_COMMAND, wParam, lParam);
    96709818    }
    96719819
     
    97379885            if (len)
    97389886            {
    9739                 if ( (buffer = COMCTL32_Alloc((len+1) * (isW ? sizeof(WCHAR) : sizeof(CHAR)))) )
     9887                if ( (buffer = Alloc((len+1) * (isW ? sizeof(WCHAR) : sizeof(CHAR)))) )
    97409888                {
    97419889                    if (isW) GetWindowTextW(hwnd, buffer, len+1);
     
    97469894        LISTVIEW_EndEditLabelT(infoPtr, buffer, isW);
    97479895
    9748         if (buffer) COMCTL32_Free(buffer);
     9896        if (buffer) Free(buffer);
    97499897
    97509898    }
     
    98209968        hOldFont = SelectObject(hdc, infoPtr->hFont);
    98219969
    9822     /*Get String Lenght in pixels */
     9970    /*Get String Length in pixels */
    98239971    GetTextExtentPoint32W(hdc, text, lstrlenW(text), &sz);
    98249972
Note: See TracChangeset for help on using the changeset viewer.