Ignore:
Timestamp:
Apr 12, 2000, 6:39:00 PM (25 years ago)
Author:
cbratschi
Message:

listview: ver 4 feature complete

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/listview.cpp

    r3351 r3369  
    1 /*$Id: listview.cpp,v 1.11 2000-04-08 18:32:54 cbratschi Exp $*/
     1/*$Id: listview.cpp,v 1.12 2000-04-12 16:38:58 cbratschi Exp $*/
    22/*
    33 * Listview control
     
    99 *
    1010 * NOTES
    11  * Listview control implementation.
     11 *   Listview control implementation.
    1212 *
    1313 * TODO:
    1414 *   - Hot item handling.
    15  *   - use hdpaSelItems for multisel
     15 *   - subitems not sort save! (sortitem.exe)
     16 *   - rcView and origin (need testcase!!!)
     17 *   - rcView not updated in LVM_SETITEMPOSITION and other messages
     18 *   - many things untested!
    1619 *
    1720 * Notifications:
     
    2932 *   LISTVIEW_GetColumnOrderArray : simple hack only
    3033 *   LISTVIEW_SetColumnOrderArray : simple hack only
    31  *   LISTVIEW_Arrange : empty stub
    3234 *   LISTVIEW_ApproximateViewRect : incomplete
    33  *   LISTVIEW_Scroll : not implemented
    34  *   LISTVIEW_RedrawItems : empty stub
    35  *   LISTVIEW_Update : not completed
    36  *
    37  * the sort algorithm isn't stable (order of same items isn't fixed)!!!
     35 *
    3836 */
    3937
     
    4341*/
    4442
    45 #include <string.h>
    46 #include <wcstr.h>
    4743#include <stdio.h>
    4844#include "winbase.h"
     
    8480
    8581/* Increment size of the horizontal scroll bar */
    86 #define LISTVIEW_SCROLL_DIV_SIZE 10
     82#define LISTVIEW_SCROLL_DIV_SIZE 1
    8783
    8884/*
     
    109105
    110106static INT     LISTVIEW_HitTestItem(HWND, LPLVHITTESTINFO);
     107static INT     LISTVIEW_GetColumnCount(HWND);
    111108static INT     LISTVIEW_GetCountPerRow(HWND);
    112109static INT     LISTVIEW_GetCountPerColumn(HWND);
     
    121118static LRESULT LISTVIEW_GetItemRect(HWND hwnd,INT nItem,LPRECT lprc,INT code);
    122119static INT     LISTVIEW_GetItemWidth(HWND);
    123 static INT     LISTVIEW_GetLabelWidth(HWND, INT);
     120static INT     LISTVIEW_GetLabelWidth(HWND,INT,INT);
    124121static LRESULT LISTVIEW_GetOrigin(HWND, LPPOINT);
    125122static INT     LISTVIEW_CalculateWidth(HWND hwnd, INT nItem);
     
    135132static LRESULT LISTVIEW_SetItem(HWND, LPLVITEMW,BOOL);
    136133static BOOL    LISTVIEW_SetItemFocus(HWND, INT);
    137 static BOOL    LISTVIEW_SetItemPosition(HWND, INT, INT, INT);
     134static BOOL    LISTVIEW_SetItemPosition(HWND,INT,INT,INT,BOOL);
    138135static VOID    LISTVIEW_UpdateScroll(HWND);
    139136static VOID    LISTVIEW_SetSelection(HWND, INT);
     
    144141static VOID    LISTVIEW_UnsupportedStyles(LONG lStyle);
    145142static HWND    LISTVIEW_EditLabel(HWND hwnd,INT nItem,BOOL unicode);
    146 static BOOL    LISTVIEW_EndEditLabel(HWND hwnd,LPSTR pszText,DWORD nItem);
     143static BOOL    LISTVIEW_EndEditLabel(HWND hwnd,LPSTR pszText,DWORD nItem,BOOL cancel);
    147144static LRESULT LISTVIEW_Command(HWND hwnd, WPARAM wParam, LPARAM lParam);
    148145static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam);
     
    151148static LRESULT LISTVIEW_GetItemState(HWND hwnd, INT nItem, UINT uMask);
    152149static LRESULT LISTVIEW_SetItemState(HWND hwnd,INT nItem,DWORD data,DWORD mask);
    153 static BOOL    LISTVIEW_SetItemPosition(HWND hwnd, INT nItem, INT nPosX, INT nPosY);
    154150static LRESULT LISTVIEW_GetStringWidth(HWND hwnd,HDC hdc,LPWSTR lpszText,BOOL unicode);
    155151static BOOL    LISTVIEW_EnsureVisible(HWND hwnd,INT nItem,BOOL bPartial);
     
    162158  if (infoPtr->internalFlags & IF_NOREDRAW) return;
    163159
    164   if ((infoPtr->uView == LVS_REPORT) && !(infoPtr->dwStyle & LVS_NOCOLUMNHEADER))
    165   {
    166     RECT rect,rect2;
    167 
    168     GetClientRect(hwnd,&rect);
    169     GetWindowRect(infoPtr->hwndHeader,&rect2);
    170     rect.top += rect2.bottom-rect2.top;
    171     InvalidateRect(hwnd,&rect,TRUE);
    172   } else InvalidateRect(hwnd,NULL,TRUE);
     160  InvalidateRect(hwnd,&infoPtr->rcList,TRUE);
    173161}
    174162
     
    190178  if ((infoPtr->uView == LVS_REPORT) && !(infoPtr->dwStyle & LVS_NOCOLUMNHEADER))
    191179  {
    192     RECT header;
    193     INT headerH;
    194180    RECT rect2;
    195181
    196182    //clip header control
    197     GetWindowRect(infoPtr->hwndHeader,&header);
    198     headerH = rect.bottom-rect.top;
    199     if (rect.bottom <= headerH) return;
    200     if (rect.top < headerH) rect.top = headerH;
     183    if (nItem < LISTVIEW_GetTopIndex(hwnd)) return;
     184
    201185    //clip width
    202186    HEADER_GetItemRect(infoPtr->hwndHeader,(WPARAM)0,(LPARAM)&rect2);
     
    207191}
    208192
     193static VOID LISTVIEW_RefreshItems(HWND hwnd,INT nFirst,INT nLast)
     194{
     195  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
     196  RECT rect;
     197
     198  if (infoPtr->internalFlags & IF_NOREDRAW) return;
     199
     200  if ((infoPtr->uView == LVS_ICON) || (infoPtr->uView == LVS_SMALLICON))
     201  {
     202    INT x;
     203    RECT rect;
     204
     205    for (x = nFirst;x < nLast;x++)
     206    {
     207      LISTVIEW_GetItemRect(hwnd,x,&rect,LVIR_BOUNDS);
     208      InvalidateRect(hwnd,&rect,TRUE);
     209    }
     210  } else if (infoPtr->uView == LVS_REPORT)
     211  {
     212    INT nTop = LISTVIEW_GetTopIndex(hwnd),nBottom,xOffset = infoPtr->lefttop.x*infoPtr->scrollStep.x;
     213    RECT rcHeader,rect;
     214
     215    if (nTop > nLast) return;
     216    if (nTop > nFirst) nFirst = nTop;
     217
     218    nBottom = nTop+LISTVIEW_GetCountPerColumn(hwnd)+1;
     219    nBottom = min(nTop,GETITEMCOUNT(infoPtr));
     220
     221    if (nFirst > nBottom) return;
     222    if (nLast > nBottom) nLast = nBottom;
     223
     224    Header_GetItemRect(infoPtr->hwndHeader,0,&rcHeader);
     225    rcHeader.left += REPORT_MARGINX;
     226    rcHeader.right = max(rcHeader.left,rcHeader.right-REPORT_MARGINX);
     227
     228    if (infoPtr->dwStyle & WS_HSCROLL)
     229    {
     230      rcHeader.left -= xOffset;
     231      rcHeader.right -= xOffset;
     232    }
     233
     234    rect.left = rcHeader.left;
     235    rect.right = rcHeader.right;
     236    rect.top = infoPtr->rcList.top+(nFirst-nTop)*infoPtr->nItemHeight;
     237    rect.bottom = rect.top+(nLast-nFirst+1)*infoPtr->nItemHeight;
     238    InvalidateRect(hwnd,&rect,TRUE);
     239  } else if (infoPtr->uView == LVS_LIST)
     240  {
     241    INT nColumnCount = LISTVIEW_GetColumnCount(hwnd);
     242    INT nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd);
     243    INT nTop = LISTVIEW_GetTopIndex(hwnd);
     244    INT xStart = 0,yStart = 0,xEnd,yEnd,x;
     245    RECT rect;
     246
     247    if (nLast < nTop) return;
     248    if (nFirst < nTop)
     249      nFirst = nTop;
     250    else
     251    {
     252      xStart = (nFirst-nTop)/nCountPerColumn;
     253      yStart = (nFirst-nTop)%nCountPerColumn;
     254      if (xStart >= nColumnCount) return;
     255    }
     256    xEnd = (nLast-nTop)/nCountPerColumn;
     257    yEnd = (nLast-nTop)%nCountPerColumn;
     258    if (xEnd >= nColumnCount)
     259    {
     260      xEnd = nColumnCount-1;
     261      yEnd = nCountPerColumn-1;
     262    }
     263
     264    for (x = xStart;x <= xEnd;x++)
     265    {
     266      if (x == xStart)
     267        rect.top = yStart*infoPtr->nItemHeight;
     268      else
     269        rect.top = 0;
     270      rect.left = x*infoPtr->nItemWidth;
     271      if (x == xEnd)
     272        rect.bottom = rect.top+(yEnd+1)*infoPtr->nItemHeight;
     273      else
     274        rect.bottom = rect.top+nCountPerColumn*infoPtr->nItemHeight;
     275      rect.right = rect.left+infoPtr->nItemWidth;
     276      InvalidateRect(hwnd,&rect,TRUE);
     277    }
     278  }
     279}
     280
    209281static VOID LISTVIEW_RefreshSubItem(HWND hwnd,INT nItem,INT nSubItem)
    210282{
     
    214286
    215287  if (infoPtr->internalFlags & IF_NOREDRAW) return;
     288
    216289  if (infoPtr->uView != LVS_REPORT) return;
     290  if (nItem < LISTVIEW_GetTopIndex(hwnd)) return;
    217291  LISTVIEW_GetItemRect(hwnd,nItem,&rect,LVIR_SELECTBOUNDS);
    218292
     
    222296  rect.right = max(column.left,column.right-REPORT_MARGINX);
    223297
    224   if (!(infoPtr->dwStyle & LVS_NOCOLUMNHEADER))
    225   {
    226     RECT header;
    227     INT headerH;
    228 
    229     //clip header control
    230     GetWindowRect(infoPtr->hwndHeader,&header);
    231     headerH = rect.bottom-rect.top;
    232     if (rect.bottom <= headerH) return;
    233     if (rect.top < headerH) rect.top = headerH;
    234   }
    235 
    236298  /* Offset the Scroll Bar Pos */
    237299  rect.left -= xOffset;
     
    249311  if ((infoPtr->uView == LVS_REPORT) && !(infoPtr->dwStyle & LVS_NOCOLUMNHEADER))
    250312  {
    251     RECT rect,header;
     313    RECT rect = infoPtr->rcList;
    252314
    253315    //clip header
    254     GetClientRect(hwnd,&rect);
    255     GetWindowRect(infoPtr->hwndHeader,&header);
    256 
    257316    if (yScroll < 0)
    258317    { //up
    259       INT headerH = header.bottom-header.top;
    260 //CB: redraw bug with _KeySelection
    261 //UpdateWindow(hwnd);
    262 //CB: inconsistent lefttop.y during this call
    263       rect.top += headerH-yScroll;
     318      rect.top -= yScroll;
    264319      if (rect.top < rect.bottom)
    265320      {
    266         ScrollWindowEx(hwnd,xScroll,yScroll,&rect,NULL,0,NULL,0);
    267         rect.top = rect.bottom+yScroll;
    268         if (rect.top < headerH) rect.top = headerH;
    269         InvalidateRect(hwnd,&rect,TRUE);
     321        INT h;
     322
     323        ScrollWindowEx(hwnd,xScroll,yScroll,&rect,NULL,0,NULL,SW_INVALIDATE);
     324        h = rect.bottom-rect.top;
     325        rect.top = infoPtr->rcList.top+h;
     326        rect.bottom = infoPtr->rcList.bottom-h;
     327        if (rect.bottom > rect.top) InvalidateRect(hwnd,&rect,TRUE);
    270328      } else
    271329      {
    272         rect.top = headerH;
    273         InvalidateRect(hwnd,&rect,TRUE);
    274       }
    275     } else if (yScroll > 0)
     330        InvalidateRect(hwnd,&infoPtr->rcList,TRUE);
     331      }
     332    } else
    276333    { //down
    277       rect.top += header.bottom-header.top;
    278       ScrollWindowEx(hwnd,xScroll,yScroll,&rect,NULL,0,NULL,SW_INVALIDATE);
    279     }
    280     if (yScroll == 0)
    281     {
    282       rect.top += header.bottom-header.top;
    283334      ScrollWindowEx(hwnd,xScroll,yScroll,&rect,NULL,0,NULL,SW_INVALIDATE);
    284335    }
     
    362413    INT nCountPerRow = LISTVIEW_GetCountPerRow(hwnd);
    363414    INT nNumOfItems = GETITEMCOUNT(infoPtr);
    364 //CB: wrong
     415
    365416    infoPtr->maxScroll.x = nNumOfItems / nCountPerColumn;
    366     if ((nNumOfItems % nCountPerColumn) == 0)
    367       infoPtr->maxScroll.x--;
     417    if (nNumOfItems % nCountPerColumn)
     418      infoPtr->maxScroll.x++;
    368419
    369420    infoPtr->lefttop.x = LISTVIEW_GetTopIndex(hwnd) / nCountPerColumn;
     
    525576        }
    526577
    527         LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);
     578        LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y,TRUE);
    528579        ptItem.x += infoPtr->nItemWidth;
    529580        rcView.right = max(rcView.right, ptItem.x);
     
    536587      for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
    537588      {
    538         LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);
     589        LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y,TRUE);
    539590        ptItem.y += infoPtr->nItemHeight;
    540591      }
     
    581632        }
    582633
    583         LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);
     634        LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y,TRUE);
    584635        ptItem.y += infoPtr->nItemHeight;
    585636        rcView.bottom = max(rcView.bottom, ptItem.y);
     
    592643      for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
    593644      {
    594         LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);
     645        LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y,TRUE);
    595646        ptItem.x += infoPtr->nItemWidth;
    596647      }
     
    690741  {
    691742    lpSubItem = (LISTVIEW_SUBITEM *) DPA_GetPtr(hdpaSubItems, i);
    692     if (lpSubItem != NULL)
     743    if (lpSubItem)
    693744    {
    694745      if (lpSubItem->iSubItem == nSubItem)
     
    742793    for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
    743794    {
    744       nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, i);
     795      nLabelWidth = LISTVIEW_GetLabelWidth(hwnd,i,0);
    745796      nItemWidth = max(nItemWidth, nLabelWidth);
    746797    }
     
    762813        nItemWidth += WIDTH_PADDING;
    763814
    764         if (infoPtr->himlSmall != NULL)
     815        if (infoPtr->himlSmall)
    765816        {
    766817          nItemWidth += infoPtr->iconSize.cx;
    767818        }
    768819
    769         if (infoPtr->himlState != NULL)
     820        if (infoPtr->himlState)
    770821        {
    771822          nItemWidth += infoPtr->iconSize.cx;
     
    822873  {
    823874    /* get width of string */
    824     nItemWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     875    nItemWidth = LISTVIEW_GetLabelWidth(hwnd,nItem,0);
    825876
    826877    /* default label size */
     
    11761227  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
    11771228  RECT rcItem;
    1178   INT i,nFirst = LISTVIEW_GetTopIndex(hwnd),nLast = GETITEMCOUNT(infoPtr);
    1179 
    1180   //CB: todo: first calc rect, then compare with item rect
    1181   //    remove loop
    11821229
    11831230  if (infoPtr->uView == LVS_REPORT)
    11841231  {
    1185     nLast = nFirst+LISTVIEW_GetCountPerColumn(hwnd)+2;
    1186     nLast = min(nLast,GETITEMCOUNT(infoPtr));
    1187   }
    1188 
    1189   for (i = nFirst;i < nLast;i++)
    1190   {
    1191     if (LISTVIEW_GetItemRect(hwnd,i,&rcItem,LVIR_SELECTBOUNDS) && PtInRect(&rcItem,pt))
    1192       return i;
     1232    INT nTop = LISTVIEW_GetTopIndex(hwnd),nItem;
     1233
     1234    nItem = nTop+((pt.y-infoPtr->rcList.top)/infoPtr->nItemHeight);
     1235    if (nItem >= GETITEMCOUNT(infoPtr)) return -1;
     1236
     1237    if (LISTVIEW_GetItemRect(hwnd,nItem,&rcItem,LVIR_SELECTBOUNDS) && PtInRect(&rcItem,pt))
     1238      return nItem;
     1239  } else if (infoPtr->uView == LVS_LIST)
     1240  {
     1241    INT nTop = LISTVIEW_GetTopIndex(hwnd),nItem;
     1242    INT nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd);
     1243
     1244    nItem = nTop+(pt.y/infoPtr->nItemHeight)+
     1245            ((INT)(pt.x-infoPtr->lefttop.x*infoPtr->scrollStep.x)/infoPtr->nItemWidth)*nCountPerColumn;
     1246    if (nItem >= GETITEMCOUNT(infoPtr)) return -1;
     1247
     1248    if (LISTVIEW_GetItemRect(hwnd,nItem,&rcItem,LVIR_SELECTBOUNDS) && PtInRect(&rcItem,pt))
     1249      return nItem;
     1250  } else
     1251  {
     1252    INT i,nFirst = LISTVIEW_GetTopIndex(hwnd),nLast = GETITEMCOUNT(infoPtr);
     1253
     1254    for (i = nFirst;i < nLast;i++)
     1255    {
     1256      if (LISTVIEW_GetItemRect(hwnd,i,&rcItem,LVIR_SELECTBOUNDS) && PtInRect(&rcItem,pt))
     1257        return i;
     1258    }
    11931259  }
    11941260
     
    12101276static VOID LISTVIEW_RemoveSelections(HWND hwnd, INT nFirst, INT nLast)
    12111277{
    1212   INT i;
    1213 
    1214   //CB: really slow!
    1215 
    1216   for (i = nFirst; i <= nLast; i++)
    1217   {
    1218     LISTVIEW_SetItemState(hwnd,i,0,LVIS_SELECTED);
     1278  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
     1279  LISTVIEW_ITEM *lpItem;
     1280
     1281  while ((lpItem = (LISTVIEW_ITEM*)DPA_GetPtr(infoPtr->hdpaSelItems,0)) != NULL)
     1282  {
     1283    LISTVIEW_SetItemState(hwnd,DPA_GetPtrIndex(infoPtr->hdpaItems,lpItem),0,LVIS_SELECTED);
    12191284  }
    12201285}
     
    12411306  {
    12421307    hdpaSubItems = (HDPA)DPA_GetPtr(hdpaItems, i);
    1243     if (hdpaSubItems != NULL)
     1308    if (hdpaSubItems)
    12441309    {
    12451310      if (LISTVIEW_RemoveSubItem(hdpaSubItems, nSubItem) == FALSE)
     
    14621527  BOOL bResult = FALSE;
    14631528
    1464   if ((lpItem != NULL) && (lpLVItem != NULL))
     1529  if (lpItem && lpLVItem)
    14651530  {
    14661531    bResult = TRUE;
     
    14981563          }
    14991564
    1500           if ((lpItem->pszText != NULL) &&
    1501               (lpItem->pszText != LPSTR_TEXTCALLBACKW))
     1565          if (lpItem->pszText && (lpItem->pszText != LPSTR_TEXTCALLBACKW))
    15021566          {
    15031567            COMCTL32_Free(lpItem->pszText);
     
    20442108  INT nDrawPosY = infoPtr->rcList.top;
    20452109  INT nColumnCount = Header_GetItemCount(infoPtr->hwndHeader);
    2046   RECT rcItem,rcClient,*rcHeader;
     2110  RECT rcItem,*rcHeader;
    20472111  INT  j,nItem,nLast,xOffset = infoPtr->lefttop.x*infoPtr->scrollStep.x;
    20482112
     
    20502114
    20512115  /* add 1 for displaying a partial item at the bottom */
    2052   nLast = nItem + LISTVIEW_GetCountPerColumn(hwnd) + 1;
     2116  nLast = nItem + LISTVIEW_GetCountPerColumn(hwnd)+1;
    20532117  nLast = min(nLast, GETITEMCOUNT(infoPtr));
    20542118
     
    20632127    sendNotify(hwnd,LVN_ODCACHEHINT,&nmlv.hdr);
    20642128  }
    2065 
    2066   GetClientRect(hwnd,&rcClient);
    20672129
    20682130  //get header rects
     
    20902152      rcItem.bottom = rcItem.top + infoPtr->nItemHeight;
    20912153
    2092       if (rcItem.top >= (updateRect ? updateRect->bottom:rcClient.bottom)) goto DR_END;
     2154      if (rcItem.top >= (updateRect ? updateRect->bottom:infoPtr->rcList.bottom)) goto DR_END;
    20932155
    20942156      if (!updateRect || IntersectRect(NULL,&rcItem,updateRect))
     
    22222284  INT nItemWidth = infoPtr->nItemWidth;
    22232285  INT nItemHeight = infoPtr->nItemHeight;
    2224   RECT rcClient;
    22252286
    22262287  /* get number of fully visible columns */
     
    22292290  nItem = LISTVIEW_GetTopIndex(hwnd);
    22302291
    2231   GetClientRect(hwnd,&rcClient);
    2232 
    22332292  for (i = 0; i < nColumnCount; i++)
    22342293  {
     
    22432302      rcItem.right = rcItem.left + nItemWidth;
    22442303
    2245       if (rcItem.left >= (updateRect ? updateRect->right:rcClient.right)) return;
     2304      if (updateRect && (rcItem.left >= updateRect->right)) return;
    22462305
    22472306      if (!updateRect || IntersectRect(NULL,&rcItem,updateRect))
     
    22762335    ptPosition.x += ptOrigin.x;
    22772336    ptPosition.y += ptOrigin.y;
    2278 //CB: wrong nItemWidth/Height!
     2337
    22792338    if (ptPosition.y + infoPtr->nItemHeight > infoPtr->rcList.top)
    22802339    {
     
    22952354              else
    22962355                LISTVIEW_DrawItem(hwnd, hdc, i, rcItem);
    2297             } else if (updateRect && (rcItem.top >= updateRect->bottom)) return;
     2356            }
    22982357          }
    2299         } else return;
     2358        }
    23002359      }
    23012360    }
     
    24402499}
    24412500
     2501static VOID LISTVIEW_SnapToGrid(HWND hwnd)
     2502{
     2503  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
     2504
     2505  if ((infoPtr->uView == LVS_SMALLICON) || (infoPtr->uView == LVS_ICON))
     2506  {
     2507    INT gridW = infoPtr->nItemWidth,gridH = infoPtr->nItemHeight,i;
     2508
     2509    for (i = 0; i < GETITEMCOUNT(infoPtr);i++)
     2510    {
     2511      POINT point;
     2512
     2513      LISTVIEW_GetItemPosition(hwnd,i,&point);
     2514      if ((point.x % gridW) || (point.y % gridH))
     2515      {
     2516        LISTVIEW_SetItemPosition(hwnd,i,point.x-point.x%gridW,point.y-point.y%gridH,TRUE);
     2517      }
     2518    }
     2519  }
     2520}
     2521
    24422522/***
    24432523 * DESCRIPTION:
     
    24552535{
    24562536  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
    2457   BOOL bResult = FALSE;
    24582537
    24592538  if ((infoPtr->uView == LVS_ICON) || (infoPtr->uView == LVS_SMALLICON))
    24602539  {
     2540    if (nAlignCode == LVA_DEFAULT)
     2541    {
     2542      switch (infoPtr->dwStyle & LVS_ALIGNMASK)
     2543      {
     2544        case LVS_ALIGNLEFT:
     2545          nAlignCode = LVA_ALIGNLEFT;
     2546          break;
     2547
     2548        case LVS_ALIGNTOP:
     2549          nAlignCode = LVA_ALIGNLEFT;
     2550          break;
     2551
     2552        default:
     2553          return FALSE;
     2554      }
     2555    }
     2556
    24612557    switch (nAlignCode)
    24622558    {
    2463     case LVA_ALIGNLEFT:
    2464       /* TO DO */
    2465       break;
    2466     case LVA_ALIGNTOP:
    2467       /* TO DO */
    2468       break;
    2469     case LVA_DEFAULT:
    2470       /* TO DO */
    2471       break;
    2472     case LVA_SNAPTOGRID:
    2473       /* TO DO */
    2474       break;
    2475     }
    2476   }
    2477 
    2478   return bResult;
    2479 }
    2480 
    2481 /* << LISTVIEW_CreateDragImage >> */
     2559      case LVA_ALIGNLEFT:
     2560        LISTVIEW_AlignLeft(hwnd);
     2561        break;
     2562
     2563      case LVA_ALIGNTOP:
     2564        LISTVIEW_AlignTop(hwnd);
     2565        break;
     2566
     2567      case LVA_SNAPTOGRID:
     2568        LISTVIEW_SnapToGrid(hwnd);
     2569        break;
     2570
     2571      default:
     2572        return FALSE;
     2573    }
     2574  }
     2575
     2576  return TRUE;
     2577}
    24822578
    24832579/***
     
    25032599  INT j;
    25042600  HDPA hdpaSubItems;
    2505 
    2506 //  TRACE("(hwnd=%x,)\n", hwnd);
    25072601
    25082602  if (GETITEMCOUNT(infoPtr) > 0)
     
    25682662    /* reinitialize listview memory */
    25692663    bResult = DPA_DeleteAllPtrs(infoPtr->hdpaItems);
     2664    DPA_DeleteAllPtrs(infoPtr->hdpaSelItems);
    25702665
    25712666    /* align items (set position of each item) */
     
    26512746  INT i;
    26522747
    2653 //  TRACE("(hwnd=%x,nItem=%d)\n", hwnd, nItem);
    2654 
    26552748  if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)))
    26562749  {
     
    26592752
    26602753    hdpaSubItems = (HDPA)DPA_DeletePtr(infoPtr->hdpaItems, nItem);
    2661     if (hdpaSubItems != NULL)
     2754    if (hdpaSubItems)
    26622755    {
    26632756      for (i = 1; i < hdpaSubItems->nItemCount; i++)
     
    26792772
    26802773      lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);
    2681       if (lpItem != NULL)
    2682       {
     2774      if (lpItem)
     2775      {
     2776        //remove from selection list
     2777        DPA_DeletePtr(infoPtr->hdpaSelItems,DPA_GetPtrIndex(infoPtr->hdpaSelItems,lpItem));
     2778
    26832779        /* send LVN_DELETEITEM notification */
    26842780        nmlv.iItem = nItem;
     
    27452841{
    27462842  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
     2843
    27472844  return infoPtr->hwndEdit;
    27482845}
     
    27632860 */
    27642861
    2765 static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem)
     2862static BOOL LISTVIEW_EndEditLabel(HWND hwnd,LPSTR pszText,DWORD nItem,BOOL cancel)
    27662863{
    27672864  NMLVDISPINFOW dispInfo;
     
    27742871  ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOW));
    27752872
    2776   if (NULL == (hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem)))
    2777           return FALSE;
    2778 
    2779   if (NULL == (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0)))
    2780           return FALSE;
     2873  if (!(hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem)))
     2874    return FALSE;
     2875
     2876  if (!(lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0)))
     2877    return FALSE;
    27812878
    27822879  dispInfo.item.mask = 0;
     
    27842881  dispInfo.item.state = lpItem->state;
    27852882  dispInfo.item.stateMask = 0;
    2786   if (isUnicodeNotify(&infoPtr->header))
    2787   {
    2788     textW = HEAP_strdupAtoW(GetProcessHeap(),0,pszText);
    2789 
    2790     dispInfo.item.pszText = textW;
    2791     dispInfo.item.cchTextMax = textW ? lstrlenW(textW):0;
     2883  if (cancel)
     2884  {
     2885    dispInfo.item.pszText = NULL;
     2886    dispInfo.item.cchTextMax = 0;
    27922887  } else
    27932888  {
    2794     dispInfo.item.pszText = (LPWSTR)pszText;
    2795     dispInfo.item.cchTextMax = pszText ? lstrlenA(pszText):0;
     2889    if (isUnicodeNotify(&infoPtr->header))
     2890    {
     2891      textW = HEAP_strdupAtoW(GetProcessHeap(),0,pszText);
     2892
     2893      dispInfo.item.pszText = textW;
     2894      dispInfo.item.cchTextMax = textW ? lstrlenW(textW):0;
     2895    } else
     2896    {
     2897      dispInfo.item.pszText = (LPWSTR)pszText;
     2898      dispInfo.item.cchTextMax = pszText ? lstrlenA(pszText):0;
     2899    }
    27962900  }
    27972901  dispInfo.item.iImage = lpItem->iImage;
     
    28022906
    28032907  /* Do we need to update the Item Text */
    2804   if(bUpdateItemText)
    2805   {
    2806     if(lpItem->pszText != LPSTR_TEXTCALLBACKW)
    2807     {
    2808       if (isUnicodeNotify(&infoPtr->header))
    2809         Str_SetPtrW(&lpItem->pszText,textW);
    2810       else
    2811       {
    2812         COMCTL32_Free(lpItem->pszText);
    2813         lpItem->pszText = HEAP_strdupAtoW(GetProcessHeap(),0,pszText);
    2814       }
    2815 
    2816     }
     2908  if (bUpdateItemText)
     2909  {
     2910    LVINTERNALITEMW lvItem;
     2911
     2912    //get old text
     2913    ZeroMemory(&lvItem, sizeof(LVITEMW));
     2914    lvItem.header.mask = LVIF_TEXT;
     2915    lvItem.header.stateMask = LVIS_SELECTED | LVIS_FOCUSED | LVIS_STATEIMAGEMASK;
     2916    lvItem.header.iItem = nItem;
     2917    lvItem.header.iSubItem = 0;
     2918    lvItem.header.cchTextMax = DISP_TEXT_SIZE;
     2919    lvItem.header.pszText = NULL;
     2920    lvItem.mustFree = FALSE;
     2921    LISTVIEW_GetItem(hwnd,(LPLVITEMW)&lvItem,TRUE,TRUE);
     2922
     2923    if ((lvItem.unicode && (lstrcmpAtoW(pszText,lvItem.header.pszText) != 0)) || (!lvItem.unicode && (lstrcmpA((LPSTR)lvItem.header.pszText,pszText) != 0)))
     2924    {
     2925      if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
     2926      {
     2927        if (isUnicodeNotify(&infoPtr->header))
     2928          Str_SetPtrW(&lpItem->pszText,textW);
     2929        else
     2930        {
     2931          COMCTL32_Free(lpItem->pszText);
     2932          lpItem->pszText = HEAP_strdupAtoW(GetProcessHeap(),0,pszText);
     2933        }
     2934      } else
     2935      {
     2936        NMLVDISPINFOW lvdi;
     2937        BOOL retval;
     2938
     2939        lvdi.item.mask        = TVIF_TEXT;
     2940        lvdi.item.iItem       = nItem;
     2941        lvdi.item.state       = lpItem->state;
     2942        lvdi.item.lParam      = lpItem->lParam;
     2943        if (isUnicodeNotify(&infoPtr->header))
     2944        {
     2945          lvdi.item.pszText     = textW;
     2946          lvdi.item.cchTextMax  = lstrlenW(textW)+1;
     2947        } else
     2948        {
     2949          lvdi.item.pszText     = (LPWSTR)pszText;
     2950          lvdi.item.cchTextMax  = lstrlenA(pszText)+1;
     2951        }
     2952
     2953        retval = (BOOL)sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? LVN_SETDISPINFOW:LVN_SETDISPINFOA,&lvdi.hdr);
     2954      }
     2955    }
     2956    if (lvItem.mustFree) COMCTL32_Free(lvItem.header.pszText);
    28172957  }
    28182958
     
    29313071 *   FAILURE : FALSE
    29323072 */
    2933 static BOOL LISTVIEW_EnsureVisible(HWND hwnd,INT nItem,BOOL bPartial)
     3073static BOOL LISTVIEW_EnsureVisible(HWND hwnd,INT nItem,BOOL bPartialOk)
    29343074{
    29353075  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
    2936   SCROLLINFO scrollInfo;
    29373076  INT nScrollPosHeight = 0;
    29383077  INT nScrollPosWidth = 0;
     
    29403079  POINT oldlefttop = infoPtr->lefttop;
    29413080
    2942   ZeroMemory(&scrollInfo,sizeof(SCROLLINFO));
    2943   scrollInfo.cbSize = sizeof(SCROLLINFO);
    2944   scrollInfo.fMask  = SIF_POS;
    2945 
    2946   /* ALWAYS bPartial == FALSE, FOR NOW! */
    2947 
    29483081  if (LISTVIEW_GetItemRect(hwnd, nItem, &rcItem,LVIR_BOUNDS))
    29493082  {
     3083    if (bPartialOk && IntersectRect(NULL,&rcItem,&infoPtr->rcList))
     3084      return TRUE;
     3085
    29503086    if (rcItem.left < infoPtr->rcList.left)
    29513087    {
     
    29743110          if (infoPtr->lefttop.x != oldlefttop.x)
    29753111          {
     3112            SCROLLINFO scrollInfo;
     3113
     3114            ZeroMemory(&scrollInfo,sizeof(SCROLLINFO));
     3115            scrollInfo.cbSize = sizeof(SCROLLINFO);
     3116            scrollInfo.fMask  = SIF_POS;
    29763117            scrollInfo.nPos = infoPtr->lefttop.x;
    29773118            SetScrollInfo(hwnd,SB_HORZ,&scrollInfo,TRUE);
     
    30073148          if (infoPtr->lefttop.x != oldlefttop.x)
    30083149          {
     3150            SCROLLINFO scrollInfo;
     3151
     3152            ZeroMemory(&scrollInfo,sizeof(SCROLLINFO));
     3153            scrollInfo.cbSize = sizeof(SCROLLINFO);
     3154            scrollInfo.fMask  = SIF_POS;
    30093155            scrollInfo.nPos   = infoPtr->lefttop.x;
    30103156            SetScrollInfo(hwnd,SB_HORZ,&scrollInfo,TRUE);
     
    30373183        if (infoPtr->lefttop.y != oldlefttop.y)
    30383184        {
     3185          SCROLLINFO scrollInfo;
     3186
     3187          ZeroMemory(&scrollInfo,sizeof(SCROLLINFO));
     3188          scrollInfo.cbSize = sizeof(SCROLLINFO);
     3189          scrollInfo.fMask  = SIF_POS;
    30393190          scrollInfo.nPos = infoPtr->lefttop.y;
    30403191          SetScrollInfo(hwnd,SB_VERT,&scrollInfo,TRUE);
     
    30623213        if (infoPtr->lefttop.y != oldlefttop.y)
    30633214        {
     3215          SCROLLINFO scrollInfo;
     3216
     3217          ZeroMemory(&scrollInfo,sizeof(SCROLLINFO));
     3218          scrollInfo.cbSize = sizeof(SCROLLINFO);
     3219          scrollInfo.fMask  = SIF_POS;
    30643220          scrollInfo.nPos = infoPtr->lefttop.y;
    30653221          SetScrollInfo(hwnd,SB_VERT,&scrollInfo,TRUE);
     
    31533309  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
    31543310  POINT ptItem;
    3155   LVITEMW lvItem;
    3156   BOOL bWrap = FALSE,rc;
     3311  LVINTERNALITEMW lvItem;
     3312  BOOL bWrap = FALSE;
    31573313  INT nItem = nStart;
    31583314  INT nLast = GETITEMCOUNT(infoPtr);
    3159   CHAR* textA = NULL;
    3160   WCHAR* textW = NULL;
    3161 
    3162   if ((nItem >= -1) && (lpFindInfo != NULL))
    3163   {
    3164     ZeroMemory(&lvItem, sizeof(LVITEMW));
     3315
     3316  if ((nItem >= -1) && lpFindInfo)
     3317  {
     3318    ZeroMemory(&lvItem,sizeof(LVITEMW));
    31653319
    31663320    if (lpFindInfo->flags & LVFI_PARAM)
    31673321    {
    3168       lvItem.mask |= LVIF_PARAM;
     3322      lvItem.header.mask |= LVIF_PARAM;
    31693323    }
    31703324
    31713325    if (lpFindInfo->flags & LVFI_STRING)
    31723326    {
    3173       lvItem.mask |= LVIF_TEXT;
    3174       if (unicode)
    3175       {
    3176         textW = (WCHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(WCHAR));
    3177         lvItem.pszText = textW;
    3178       } else
    3179       {
    3180         textA = (CHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(CHAR));
    3181         lvItem.pszText = (LPWSTR)textA;
    3182       }
    3183       lvItem.cchTextMax = DISP_TEXT_SIZE;
     3327      lvItem.header.mask |= LVIF_TEXT;
     3328      lvItem.header.pszText = NULL;
     3329      lvItem.header.cchTextMax = DISP_TEXT_SIZE;
    31843330    }
    31853331
    31863332    if (lpFindInfo->flags & LVFI_PARTIAL)
    31873333    {
    3188       lvItem.mask |= LVIF_TEXT;
    3189       if (unicode)
    3190       {
    3191         if (!textW)
    3192         {
    3193           textW = (WCHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(WCHAR));
    3194           lvItem.pszText = textW;
    3195         }
    3196       } else
    3197       {
    3198         if (!textA)
    3199         {
    3200           textA = (CHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(CHAR));
    3201           lvItem.pszText = (LPWSTR)textA;
    3202         }
    3203       }
    3204       lvItem.cchTextMax = DISP_TEXT_SIZE;
     3334      lvItem.header.mask |= LVIF_TEXT;
     3335      lvItem.header.pszText = NULL;
     3336      lvItem.header.cchTextMax = DISP_TEXT_SIZE;
    32053337    }
    32063338
     
    32223354        if (lpFindInfo->flags & LVFI_NEARESTXY)
    32233355        {
    3224           nItem = LISTVIEW_GetNearestItem(hwnd, ptItem,
    3225                                           lpFindInfo->vkDirection);
     3356          nItem = LISTVIEW_GetNearestItem(hwnd,ptItem,lpFindInfo->vkDirection);
    32263357          if (nItem != -1)
    32273358          {
     
    32383369        }
    32393370
    3240         lvItem.iItem = nItem;
    3241         lvItem.iSubItem = 0;
    3242         if (unicode)
    3243           LISTVIEW_GetItem(hwnd,&lvItem,TRUE,FALSE);//CB:todo
    3244         else
    3245           LISTVIEW_GetItem(hwnd,&lvItem,FALSE,FALSE);//CB:todo
    3246         if (rc != FALSE)
     3371        lvItem.header.iItem = nItem;
     3372        lvItem.header.iSubItem = 0;
     3373
     3374        lvItem.mustFree = FALSE;
     3375        lvItem.header.pszText = NULL;
     3376        lvItem.header.cchTextMax = DISP_TEXT_SIZE;
     3377        if (LISTVIEW_GetItem(hwnd,(LVITEMW*)&lvItem,TRUE,TRUE))
    32473378        {
    3248           if (lvItem.mask & LVIF_TEXT)
     3379          if (lvItem.header.mask & LVIF_TEXT)
    32493380          {
    32503381            if (lpFindInfo->flags & LVFI_PARTIAL)
    32513382            {
    3252               if (unicode)
     3383              if (lstrstrAW(lvItem.header.pszText,lvItem.unicode,(LPWSTR)lpFindInfo->psz,unicode))
    32533384              {
    3254                 if (wcswcs((const wchar_t*)lvItem.pszText,(wchar_t*)lpFindInfo->psz) == NULL)
     3385                if (lvItem.mustFree) COMCTL32_Free(lvItem.header.pszText);
    32553386                continue;
    3256               } else
     3387              }
     3388            } else
     3389            {
     3390              if (lstrcmpAW(lvItem.header.pszText,lvItem.unicode,(LPWSTR)lpFindInfo->psz,unicode) != 0)
    32573391              {
    3258                 if (strstr((LPSTR)lvItem.pszText,(LPSTR)lpFindInfo->psz) == NULL)
    3259                   continue;
     3392                if (lvItem.mustFree) COMCTL32_Free(lvItem.header.pszText);
     3393                continue;
    32603394              }
    32613395            }
    3262             else
    3263             {
    3264               if (unicode)
    3265               {
    3266                 if (lstrcmpW(lvItem.pszText,lpFindInfo->psz) != 0)
    3267                   continue;
    3268 
    3269               } else
    3270               {
    3271                 if (lstrcmpA((LPSTR)lvItem.pszText,(LPSTR)lpFindInfo->psz) != 0)
    3272                   continue;
    3273               }
    3274             }
     3396            if (lvItem.mustFree) COMCTL32_Free(lvItem.header.pszText);
    32753397          }
    32763398
    3277           if (lvItem.mask & LVIF_PARAM)
     3399          if (lvItem.header.mask & LVIF_PARAM)
    32783400          {
    3279             if (lpFindInfo->lParam != lvItem.lParam)
     3401            if (lpFindInfo->lParam != lvItem.header.lParam)
    32803402              continue;
    32813403          }
     
    32853407      }
    32863408
    3287       if (bWrap != FALSE)
     3409      if (bWrap)
    32883410      {
    32893411        nItem = -1;
     
    32983420  }
    32993421
    3300  return -1;
     3422  return -1;
    33013423}
    33023424
     
    33723494  BOOL bResult = FALSE;
    33733495
    3374   if (lpColumn != NULL)
     3496  if (lpColumn)
    33753497  {
    33763498    /* initialize memory */
    3377     ZeroMemory(&hdi, sizeof(HDITEMW));
     3499    ZeroMemory(&hdi,sizeof(HDITEMW));
    33783500
    33793501    if (lpColumn->mask & LVCF_FMT)
     
    34083530    else
    34093531      bResult = Header_GetItemA(infoPtr->hwndHeader,nItem,(HDITEMW*)&hdi);
    3410     if (bResult != FALSE)
     3532    if (bResult)
    34113533    {
    34123534      if (lpColumn->mask & LVCF_FMT)
     
    34893611  } else if (infoPtr->uView == LVS_REPORT)
    34903612  {
    3491     HDITEMA hdi;
     3613    HDITEMW hdi;
    34923614
    34933615    /* get column width from header */
    3494     ZeroMemory(&hdi, sizeof(HDITEMA));
     3616    ZeroMemory(&hdi,sizeof(HDITEMW));
    34953617    hdi.mask = HDI_WIDTH;
    34963618    if (Header_GetItemW(infoPtr->hwndHeader, nColumn, &hdi))
     
    36033725  switch (nImageList)
    36043726  {
    3605   case LVSIL_NORMAL:
    3606     himl = infoPtr->himlNormal;
    3607     break;
    3608   case LVSIL_SMALL:
    3609     himl = infoPtr->himlSmall;
    3610     break;
    3611   case LVSIL_STATE:
    3612     himl = infoPtr->himlState;
    3613     break;
     3727    case LVSIL_NORMAL:
     3728      himl = infoPtr->himlNormal;
     3729      break;
     3730
     3731    case LVSIL_SMALL:
     3732      himl = infoPtr->himlSmall;
     3733      break;
     3734
     3735    case LVSIL_STATE:
     3736      himl = infoPtr->himlState;
     3737      break;
    36143738  }
    36153739
    36163740  return (LRESULT)himl;
    36173741}
    3618 
    3619 /* LISTVIEW_GetISearchString */
    36203742
    36213743/***
     
    41674289  if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && lprc)
    41684290  {
    4169     if (LISTVIEW_GetItemPosition(hwnd, nItem, &ptItem) != FALSE)
     4291    if (LISTVIEW_GetItemPosition(hwnd, nItem, &ptItem))
    41704292    {
    41714293      switch(code)
     
    42394361                lprc->top = (ptItem.y + ptOrigin.y + infoPtr->iconSize.cy +
    42404362                             ICON_BOTTOM_PADDING + ICON_TOP_PADDING);
    4241                 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4363                nLabelWidth = LISTVIEW_GetLabelWidth(hwnd,nItem,0);
    42424364                if (infoPtr->iconSpacing.cx - nLabelWidth > 1)
    42434365                {
     
    42794401              }
    42804402
    4281               nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4403              nLabelWidth = LISTVIEW_GetLabelWidth(hwnd,nItem,0);
    42824404              if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
    42834405              {
     
    43074429            }
    43084430
    4309             nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4431            nLabelWidth = LISTVIEW_GetLabelWidth(hwnd,nItem,0);
    43104432            if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
    43114433            {
     
    43524474              if (infoPtr->himlSmall)
    43534475                lprc->right += infoPtr->iconSize.cx;
    4354               lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
     4476              lprc->right += LISTVIEW_GetLabelWidth(hwnd,nItem,0);
    43554477            }
    43564478          }
     
    43734495            }
    43744496
    4375             nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4497            nLabelWidth = LISTVIEW_GetLabelWidth(hwnd,nItem,0);
    43764498            if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth)
    43774499            {
     
    44264548              }
    44274549
    4428               nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4550              nLabelWidth = LISTVIEW_GetLabelWidth(hwnd,nItem,0);
    44294551              if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth)
    44304552              {
     
    44564578            }
    44574579
    4458             nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4580            nLabelWidth = LISTVIEW_GetLabelWidth(hwnd,nItem,0);
    44594581            if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
    44604582            {
     
    44854607 *   FAILURE : zero
    44864608 */
    4487 INT LISTVIEW_GetLabelWidth(HWND hwnd, INT nItem)
     4609INT LISTVIEW_GetLabelWidth(HWND hwnd,INT nItem,INT nSubItem)
    44884610{
    44894611  INT nLabelWidth = 0;
     
    44934615  lvItem.header.mask = LVIF_TEXT;
    44944616  lvItem.header.iItem = nItem;
     4617  lvItem.header.iSubItem = nSubItem;
    44954618  lvItem.header.cchTextMax = DISP_TEXT_SIZE;
    44964619  lvItem.header.pszText = NULL;
     
    45834706  INT nLength = 0;
    45844707
    4585   if (lpLVItem != NULL)
     4708  if (lpLVItem)
    45864709  {
    45874710    if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)))
     
    45894712      lpLVItem->mask = LVIF_TEXT;
    45904713      lpLVItem->iItem = nItem;
    4591       if (LISTVIEW_GetItem(hwnd,lpLVItem,unicode,FALSE) != FALSE)
     4714      if (LISTVIEW_GetItem(hwnd,lpLVItem,unicode,FALSE))
    45924715      {
    45934716        nLength = unicode ? lstrlenW(lpLVItem->pszText):lstrlenA((LPSTR)lpLVItem->pszText);
     
    47964919  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
    47974920  INT nSelectedCount = 0;
    4798   INT i;
    4799 
    4800   for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
    4801   {
    4802     if (LISTVIEW_GetItemState(hwnd, i, LVIS_SELECTED) & LVIS_SELECTED)
    4803     {
    4804       nSelectedCount++;
    4805     }
    4806   }
    4807 
    4808   return nSelectedCount;
     4921
     4922  return nSelectedCount = infoPtr->hdpaSelItems->nItemCount;
    48094923}
    48104924
     
    49025016}
    49035017
     5018static BOOL LISTVIEW_InternalHitTestItem(HWND hwnd,LISTVIEW_INFO *infoPtr,INT nItem,LPLVHITTESTINFO lpHitTestInfo)
     5019{
     5020  RECT rcItem;
     5021
     5022  if (LISTVIEW_GetItemRect(hwnd,nItem,&rcItem,LVIR_BOUNDS))
     5023  {
     5024    if (PtInRect(&rcItem,lpHitTestInfo->pt))
     5025    {
     5026      if (LISTVIEW_GetItemRect(hwnd,nItem,&rcItem,LVIR_ICON) && PtInRect(&rcItem,lpHitTestInfo->pt))
     5027      {
     5028        lpHitTestInfo->flags = LVHT_ONITEMICON;
     5029        lpHitTestInfo->iItem = nItem;
     5030        lpHitTestInfo->iSubItem = 0;
     5031        return TRUE;
     5032      }
     5033
     5034      if (LISTVIEW_GetItemRect(hwnd,nItem,&rcItem,LVIR_LABEL) && PtInRect(&rcItem,lpHitTestInfo->pt))
     5035      {
     5036        lpHitTestInfo->flags = LVHT_ONITEMLABEL;
     5037        lpHitTestInfo->iItem = nItem;
     5038        lpHitTestInfo->iSubItem = 0;
     5039        return TRUE;
     5040      }
     5041
     5042      lpHitTestInfo->flags = LVHT_ONITEMSTATEICON;
     5043      lpHitTestInfo->iItem = nItem;
     5044      lpHitTestInfo->iSubItem = 0;
     5045      return TRUE;
     5046    }
     5047  }
     5048
     5049  return FALSE;
     5050}
     5051
    49045052/***
    49055053 * DESCRIPTION:
     
    49185066  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
    49195067  RECT rcItem;
    4920   INT i;
    4921 
    4922 //CB: very slow!
    4923   for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
    4924   {
    4925     if (LISTVIEW_GetItemRect(hwnd, i, &rcItem,LVIR_BOUNDS))
    4926     {
    4927       if (PtInRect(&rcItem, lpHitTestInfo->pt))
    4928       {
    4929         if (LISTVIEW_GetItemRect(hwnd, i, &rcItem,LVIR_ICON))
    4930         {
    4931           if (PtInRect(&rcItem, lpHitTestInfo->pt))
    4932           {
    4933             lpHitTestInfo->flags = LVHT_ONITEMICON;
    4934             lpHitTestInfo->iItem = i;
    4935             lpHitTestInfo->iSubItem = 0;
    4936             return i;
    4937           }
    4938         }
    4939 
    4940         if (LISTVIEW_GetItemRect(hwnd, i, &rcItem,LVIR_LABEL))
    4941         {
    4942           if (PtInRect(&rcItem, lpHitTestInfo->pt))
    4943           {
    4944             lpHitTestInfo->flags = LVHT_ONITEMLABEL;
    4945             lpHitTestInfo->iItem = i;
    4946             lpHitTestInfo->iSubItem = 0;
    4947             return i;
    4948           }
    4949         }
    4950 
    4951         lpHitTestInfo->flags = LVHT_ONITEMSTATEICON;
    4952         lpHitTestInfo->iItem = i;
    4953         lpHitTestInfo->iSubItem = 0;
     5068
     5069  if (!lpHitTestInfo) return -1;
     5070
     5071  if (infoPtr->uView == LVS_REPORT)
     5072  {
     5073    INT nTop = LISTVIEW_GetTopIndex(hwnd),nItem;
     5074
     5075    nItem = nTop+((lpHitTestInfo->pt.y-infoPtr->rcList.top)/infoPtr->nItemHeight);
     5076    if (nItem >= GETITEMCOUNT(infoPtr)) return -1;
     5077
     5078    if (LISTVIEW_InternalHitTestItem(hwnd,infoPtr,nItem,lpHitTestInfo))
     5079      return nItem;
     5080  } else if (infoPtr->uView == LVS_LIST)
     5081  {
     5082    INT nTop = LISTVIEW_GetTopIndex(hwnd),nItem;
     5083    INT nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd);
     5084
     5085    nItem = nTop+(lpHitTestInfo->pt.y/infoPtr->nItemHeight)+
     5086            ((INT)(lpHitTestInfo->pt.x-infoPtr->lefttop.x*infoPtr->scrollStep.x)/infoPtr->nItemWidth)*nCountPerColumn;
     5087    if (nItem >= GETITEMCOUNT(infoPtr)) return -1;
     5088
     5089    if (LISTVIEW_InternalHitTestItem(hwnd,infoPtr,nItem,lpHitTestInfo))
     5090      return nItem;
     5091  } else
     5092  {
     5093    INT i;
     5094
     5095    for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
     5096    {
     5097      if (LISTVIEW_InternalHitTestItem(hwnd,infoPtr,i,lpHitTestInfo))
    49545098        return i;
    4955       }
    49565099    }
    49575100  }
     
    50525195      {
    50535196        hdi.fmt |= HDF_BITMAP_ON_RIGHT;
    5054         /* ??? */
    50555197      }
    50565198
    50575199      if (lpColumn->fmt & LVCFMT_COL_HAS_IMAGES)
    50585200      {
    5059         /* ??? */
     5201        hdi.fmt |= HDF_IMAGE;
    50605202      }
    50615203
     
    50925234      hdi.iOrder = lpColumn->iOrder;
    50935235    }
    5094 //CB: todo: use macros
     5236
    50955237    /* insert item in header control */
    50965238    if (unicode)
     
    52715413{
    52725414  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
    5273   BOOL bResult = FALSE;
    52745415
    52755416  if (nFirst <= nLast)
     
    52795420      if ((nLast >= 0) && (nLast < GETITEMCOUNT(infoPtr)))
    52805421      {
    5281         /* bResult = */
    5282         LISTVIEW_Refresh(hwnd);
    5283       }
    5284     }
    5285   }
    5286 
    5287   return bResult;
    5288 }
    5289 
    5290 /* LISTVIEW_Scroll */
     5422        if ((nFirst == 0) && (nLast == GETITEMCOUNT(infoPtr)))
     5423        {
     5424          InvalidateRect(hwnd,NULL,TRUE);
     5425
     5426          return TRUE;
     5427        }
     5428
     5429        if (nFirst == nLast)
     5430          LISTVIEW_RefreshItem(hwnd,nFirst,TRUE);
     5431        else
     5432          LISTVIEW_RefreshItems(hwnd,nFirst,nLast);
     5433
     5434        return TRUE;
     5435      }
     5436    }
     5437  }
     5438
     5439  return FALSE;
     5440}
     5441
     5442static LRESULT LISTVIEW_Scroll(HWND hwnd,WPARAM wParam,LPARAM lParam)
     5443{
     5444  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
     5445  INT dx = (INT)wParam,dy = (INT)lParam,maxX,maxY;
     5446  POINT oldlefttop = infoPtr->lefttop;
     5447
     5448  //x units: (icon, report -> pixels; list -> columns)
     5449  if (infoPtr->uView != LVS_LIST)
     5450  {
     5451    dx /= infoPtr->scrollStep.x;
     5452  }
     5453
     5454  //y units: (icon, list -> pixels; report -> lines)
     5455  if (infoPtr->uView == LVS_LIST)
     5456  {
     5457    //no vertical scrolling (so far)
     5458    dy = 0;
     5459  } else if ((infoPtr->uView == LVS_ICON) || (infoPtr->uView == LVS_SMALLICON))
     5460  {
     5461    dy /= infoPtr->scrollStep.y;
     5462  }
     5463
     5464  infoPtr->lefttop.x += dx;
     5465  infoPtr->lefttop.y += dy;
     5466  maxX = infoPtr->maxScroll.x-infoPtr->scrollPage.x;
     5467  maxY = infoPtr->maxScroll.y-infoPtr->scrollPage.y;
     5468
     5469  if (infoPtr->lefttop.x > maxX)
     5470    infoPtr->lefttop.x = maxX;
     5471
     5472  if (infoPtr->lefttop.x < 0)
     5473    infoPtr->lefttop.x = 0;
     5474
     5475  if (infoPtr->lefttop.y > maxY)
     5476    infoPtr->lefttop.y = maxY;
     5477
     5478  if (infoPtr->lefttop.y < 0)
     5479    infoPtr->lefttop.y = 0;
     5480
     5481  if ((oldlefttop.x != infoPtr->lefttop.x) || (oldlefttop.y != infoPtr->lefttop.y))
     5482  {
     5483    SCROLLINFO scrollInfo;
     5484    RECT rect;
     5485    INT xScroll = (oldlefttop.x-infoPtr->lefttop.x)*infoPtr->scrollStep.x;
     5486    INT yScroll = (oldlefttop.y-infoPtr->lefttop.y)*infoPtr->scrollStep.y;
     5487
     5488    if (xScroll != 0)
     5489    {
     5490      ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));
     5491      scrollInfo.cbSize = sizeof(SCROLLINFO);
     5492      scrollInfo.nPos   = infoPtr->lefttop.x;
     5493      scrollInfo.fMask  = SIF_POS;
     5494      SetScrollInfo(hwnd,SB_HORZ,&scrollInfo,TRUE);
     5495    }
     5496
     5497    if (yScroll != 0)
     5498    {
     5499      ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));
     5500      scrollInfo.cbSize = sizeof(SCROLLINFO);
     5501      scrollInfo.nPos   = infoPtr->lefttop.y;
     5502      scrollInfo.fMask  = SIF_POS;
     5503      SetScrollInfo(hwnd,SB_VERT,&scrollInfo,TRUE);
     5504    }
     5505
     5506    LISTVIEW_ScrollWindow(hwnd,xScroll,yScroll);
     5507
     5508    return TRUE;
     5509  }
     5510
     5511  return FALSE;
     5512}
    52915513
    52925514/***
     
    54955717    // make sure we can get the listview info
    54965718    if (!infoPtr)
    5497         return (FALSE);
     5719      return (FALSE);
    54985720
    54995721    // set column width only if in report mode
    55005722    if (infoPtr->uView != LVS_REPORT)
    5501         return (FALSE);
     5723      return (FALSE);
    55025724
    55035725    if (!infoPtr->hwndHeader) // make sure we have a header
    5504         return (FALSE);
     5726      return (FALSE);
    55055727
    55065728    if (cx == LVSCW_AUTOSIZE_USEHEADER)
     
    55095731    } else if (cx == LVSCW_AUTOSIZE)
    55105732    {
     5733      INT nItemWidth,i;
     5734
    55115735      cx = HEADER_GetExpandedColumnTextWidth(infoPtr->hwndHeader,iCol);
    55125736
    5513       //CB: todo
     5737      for (i = 0;i < GETITEMCOUNT(infoPtr);i++)
     5738      {
     5739        nItemWidth = LISTVIEW_GetLabelWidth(hwnd,i,iCol)+2*REPORT_MARGINX;
     5740        if (nItemWidth > cx) cx = nItemWidth;
     5741      }
    55145742    }
    55155743
     
    56475875  HDPA hdpaSubItems;
    56485876  NMLISTVIEW nmlv;
    5649 //CB: LVS_REPORT (and other) and new text: invalidate if item rect > nItemWidth
    5650   if (lpLVItem != NULL)
     5877
     5878  if (lpLVItem)
    56515879  {
    56525880    if ((lpLVItem->iItem >= 0) && (lpLVItem->iItem < GETITEMCOUNT(infoPtr)))
     
    56825910
    56835911              /* copy information */
     5912              if (uChanged & LVIF_STATE)
     5913              {
     5914                if ((nmlv.uNewState & LVIS_SELECTED) != (nmlv.uOldState & LVIS_SELECTED))
     5915                {
     5916                  if (nmlv.uOldState & LVIS_SELECTED)
     5917                    DPA_DeletePtr(infoPtr->hdpaSelItems,DPA_GetPtrIndex(infoPtr->hdpaSelItems,lpItem));
     5918                  else
     5919                    DPA_InsertPtr(infoPtr->hdpaSelItems,0,lpItem);
     5920                }
     5921              }
    56845922              bResult = LISTVIEW_InitItem(hwnd, lpItem, lpLVItem,unicode);
    56855923
    56865924              /* send LVN_ITEMCHANGED notification */
    56875925              sendNotify(hwnd,LVN_ITEMCHANGED,&nmlv.hdr);
     5926
     5927              if ((uChanged & LVIF_TEXT) && ((infoPtr->uView == LVS_SMALLICON) || (infoPtr->uView == LVS_LIST)))
     5928              {
     5929                INT nItemWidth = LISTVIEW_CalculateWidth(hwnd,lpLVItem->iItem);
     5930
     5931                if (nItemWidth > infoPtr->nItemWidth)
     5932                {
     5933                  infoPtr->nItemWidth = nItemWidth;
     5934                  LISTVIEW_Refresh(hwnd);
     5935
     5936                  return bResult;
     5937                }
     5938              }
    56885939
    56895940              LISTVIEW_RefreshItem(hwnd,lpLVItem->iItem,TRUE);
     
    57355986  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
    57365987
    5737 //  FIXME("(%d %08lx)empty stub!\n", nItems, dwFlags);
    57385988
    57395989  if (nItems == 0)
     
    57425992  if (infoPtr->dwStyle & LVS_OWNERDATA)
    57435993  {
    5744 //    FIXME("LVS_OWNERDATA is set!\n");
    5745   }
    5746   else
    5747   {
    5748   if (nItems > GETITEMCOUNT(infoPtr))
    5749 {
    5750     /* append items */
    5751 //    FIXME("append items\n");
    5752 
    5753   }
    5754   else if (nItems < GETITEMCOUNT(infoPtr))
    5755   {
    5756     /* remove items */
    5757 //    FIXME("remove items\n");
    5758 
    5759   }
     5994    //FIXME("LVS_OWNERDATA is set!\n");
     5995  } else
     5996  {
     5997    if (nItems > GETITEMCOUNT(infoPtr))
     5998    {
     5999      /* append items */
     6000
     6001      //CB: todo: what does the Windows version?
     6002    } else if (nItems < GETITEMCOUNT(infoPtr))
     6003    {
     6004      /* remove items */
     6005
     6006      //CB: todo: what does the Windows version?
     6007    }
    57606008  }
    57616009
     
    57776025 *   FAILURE : FALSE
    57786026 */
    5779 static BOOL LISTVIEW_SetItemPosition(HWND hwnd, INT nItem, INT nPosX, INT nPosY)
     6027static BOOL LISTVIEW_SetItemPosition(HWND hwnd,INT nItem,INT nPosX,INT nPosY,BOOL ignoreAutoArrange)
    57806028{
    57816029  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
     
    57896037    {
    57906038      hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem);
    5791       if (hdpaSubItems != NULL)
     6039      if (hdpaSubItems)
    57926040      {
    57936041        lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);
    5794         if (lpItem != NULL)
     6042        if (lpItem)
    57956043        {
    57966044          bResult = TRUE;
    5797           lpItem->ptPosition.x = nPosX;
    5798           lpItem->ptPosition.y = nPosY;
     6045
     6046          if ((lpItem->ptPosition.x == nPosX) && (lpItem->ptPosition.y == nPosY))
     6047            return bResult;
     6048
     6049          if (infoPtr->dwStyle & LVS_AUTOARRANGE)
     6050          {
     6051            lpItem->ptPosition.x = nPosX;
     6052            lpItem->ptPosition.y = nPosY;
     6053
     6054            if (!ignoreAutoArrange) LISTVIEW_Arrange(hwnd,LVA_DEFAULT);
     6055          } else
     6056          {
     6057            POINT point;
     6058            RECT rect1,rect2;
     6059
     6060            LISTVIEW_GetItemRect(hwnd,nItem,&rect1,LVIR_BOUNDS);
     6061            lpItem->ptPosition.x = nPosX;
     6062            lpItem->ptPosition.y = nPosY;
     6063            LISTVIEW_GetItemRect(hwnd,nItem,&rect2,LVIR_BOUNDS);
     6064            InvalidateRect(hwnd,&rect1,TRUE);
     6065            InvalidateRect(hwnd,&rect2,TRUE);
     6066          }
    57996067        }
    58006068      }
     
    58056073}
    58066074
    5807 /* LISTVIEW_SetItemPosition32 */
     6075static BOOL LISTVIEW_SetItemPosition32(HWND hwnd,INT nItem,LPPOINT lpptNewPos)
     6076{
     6077  if (!lpptNewPos) return FALSE;
     6078
     6079  return LISTVIEW_SetItemPosition(hwnd,nItem,lpptNewPos->x,lpptNewPos->y,FALSE);
     6080}
    58086081
    58096082//replaces ListView_SetItemState macro
     
    62446517    RECT rc;
    62456518    HBRUSH hBrush = CreateSolidBrush(infoPtr->clrBk);
     6519
    62466520    GetClientRect(hwnd, &rc);
    62476521    FillRect((HDC)wParam, &rc, hBrush);
     
    63236597    case SB_THUMBTRACK:
    63246598      infoPtr->lefttop.y = nCurrentPos;
     6599
    63256600      if (infoPtr->lefttop.y > maxY)
    63266601        infoPtr->lefttop.y = maxY;
     
    63356610    SCROLLINFO scrollInfo;
    63366611    RECT rect;
    6337     INT yScroll = (oldY-infoPtr->lefttop.y)*infoPtr->nItemHeight;
     6612    INT yScroll = (oldY-infoPtr->lefttop.y)*infoPtr->scrollStep.y;
    63386613
    63396614    ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));
     
    64316706}
    64326707
    6433 static LRESULT LISTVIEW_MouseWheel(HWND hwnd, INT wheelDelta)
     6708static LRESULT LISTVIEW_MouseWheel(HWND hwnd,WPARAM wParam,LPARAM lParam)
    64346709{
    64356710    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
    64366711    INT gcWheelDelta = 0;
    64376712    UINT pulScrollLines = 3;
     6713    INT wheelDelta = (short int)HIWORD(wParam);
     6714
     6715   if (wParam & (MK_SHIFT | MK_CONTROL))
     6716     return DefWindowProcA(hwnd,WM_MOUSEWHEEL,wParam,lParam);
     6717
    64386718
    64396719    SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
     
    66336913            if ( timeSinceLastKeyPress - infoPtr->timeSinceLastKeyPress < KEY_DELAY )
    66346914            {    /* append new character to search string */
    6635                 strcat( infoPtr->szSearchParam, szCharCode );
     6915                lstrcatA( infoPtr->szSearchParam, szCharCode );
    66366916                infoPtr->nSearchParamLength++;
    66376917
     
    66646944                    }
    66656945                }
    6666                 strcpy( infoPtr->szSearchParam, szCharCode );
     6946                lstrcpyA( infoPtr->szSearchParam, szCharCode );
    66676947                infoPtr->nSearchParamLength = 1;
    66686948            }
    66696949            else
    66706950            {   /* Save szCharCode for use in later searches */
    6671                 strcpy( infoPtr->szSearchParam, szCharCode );
     6951                lstrcpyA( infoPtr->szSearchParam, szCharCode );
    66726952                infoPtr->nSearchParamLength = 1;
    66736953
     
    67317011                    }
    67327012                }
    6733                 strcpy( infoPtr->szSearchParam, szCharCode );
     7013                lstrcpyA( infoPtr->szSearchParam, szCharCode );
    67347014                infoPtr->nSearchParamLength = 1;
    67357015            }
     
    67477027                    }
    67487028                }
    6749                 strcpy( infoPtr->szSearchParam, szCharCode );
     7029                lstrcpyA( infoPtr->szSearchParam, szCharCode );
    67507030                infoPtr->nSearchParamLength = 1;
    67517031            }
     
    67537033            {
    67547034                /* append new character to search string */
    6755                 strcat( infoPtr->szSearchParam, szCharCode );
     7035                lstrcatA( infoPtr->szSearchParam, szCharCode );
    67567036                infoPtr->nSearchParamLength++;
    67577037
     
    75747854            }
    75757855
    7576             if (GetTextExtentPoint32A(hdc, buffer, strlen(buffer), &sz))
     7856            if (GetTextExtentPoint32A(hdc, buffer, lstrlenA(buffer), &sz))
    75777857            {
    75787858                TEXTMETRICA textMetric;
     
    76787958        /* eg. Using a messagebox                                         */
    76797959        bIgnoreKillFocus = TRUE;
    7680         einfo->EditLblCb(GetParent(hwnd), buffer, einfo->param);
     7960        einfo->EditLblCb(GetParent(hwnd),buffer,einfo->param,cancel);
    76817961
    76827962        if (buffer)
     
    77238003
    77248004    /*Get String Lenght in pixels */
    7725     GetTextExtentPoint32A(hdc, text, strlen(text), &sz);
     8005    GetTextExtentPoint32A(hdc, text, lstrlenA(text), &sz);
    77268006
    77278007    /*Add Extra spacing for the next character */
     
    77528032}
    77538033
     8034static LRESULT LISTVIEW_CreateDragImage(HWND hwnd,WPARAM wParam,LPARAM lParam)
     8035{
     8036  //CB: todo
     8037
     8038  return 0;
     8039}
     8040
     8041static LRESULT LISTVIEW_GetISearchString(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
     8042{
     8043  //CB: todo
     8044
     8045  return 0;
     8046}
     8047
    77548048/***
    77558049 * DESCRIPTION:
     
    77628056  switch (uMsg)
    77638057  {
    7764   case LVM_APPROXIMATEVIEWRECT:
    7765     return LISTVIEW_ApproximateViewRect(hwnd, (INT)wParam,
    7766                                         LOWORD(lParam), HIWORD(lParam));
    7767   case LVM_ARRANGE:
    7768     return LISTVIEW_Arrange(hwnd, (INT)wParam);
    7769 
    7770 /* case LVM_CREATEDRAGIMAGE: */
    7771 
    7772   case LVM_DELETEALLITEMS:
    7773     return LISTVIEW_DeleteAllItems(hwnd);
    7774 
    7775   case LVM_DELETECOLUMN:
    7776     return LISTVIEW_DeleteColumn(hwnd, (INT)wParam);
    7777 
    7778   case LVM_DELETEITEM:
    7779     return LISTVIEW_DeleteItem(hwnd, (INT)wParam);
    7780 
    7781   case LVM_EDITLABELA:
    7782     return LISTVIEW_EditLabel(hwnd,(INT)wParam,FALSE);
    7783 
    7784   case LVM_EDITLABELW:
    7785     return LISTVIEW_EditLabel(hwnd,(INT)wParam,TRUE);
    7786 
    7787   case LVM_ENSUREVISIBLE:
    7788     return LISTVIEW_EnsureVisible(hwnd,(INT)wParam,(BOOL)lParam);
    7789 
    7790   case LVM_FINDITEMA:
    7791     return LISTVIEW_FindItem(hwnd,(INT)wParam,(LPLVFINDINFOW)lParam,FALSE);
    7792 
    7793   case LVM_FINDITEMW:
    7794     return LISTVIEW_FindItem(hwnd,(INT)wParam,(LPLVFINDINFOW)lParam,TRUE);
    7795 
    7796   case LVM_GETBKCOLOR:
    7797     return LISTVIEW_GetBkColor(hwnd);
     8058    case LVM_APPROXIMATEVIEWRECT:
     8059      return LISTVIEW_ApproximateViewRect(hwnd,(INT)wParam,LOWORD(lParam),HIWORD(lParam));
     8060
     8061    case LVM_ARRANGE:
     8062      return LISTVIEW_Arrange(hwnd, (INT)wParam);
     8063
     8064
     8065    case LVM_CREATEDRAGIMAGE:
     8066      return LISTVIEW_CreateDragImage(hwnd,wParam,lParam);
     8067
     8068    case LVM_DELETEALLITEMS:
     8069      return LISTVIEW_DeleteAllItems(hwnd);
     8070
     8071    case LVM_DELETECOLUMN:
     8072      return LISTVIEW_DeleteColumn(hwnd, (INT)wParam);
     8073
     8074    case LVM_DELETEITEM:
     8075      return LISTVIEW_DeleteItem(hwnd, (INT)wParam);
     8076
     8077    case LVM_EDITLABELA:
     8078      return LISTVIEW_EditLabel(hwnd,(INT)wParam,FALSE);
     8079
     8080    case LVM_EDITLABELW:
     8081      return LISTVIEW_EditLabel(hwnd,(INT)wParam,TRUE);
     8082
     8083    case LVM_ENSUREVISIBLE:
     8084      return LISTVIEW_EnsureVisible(hwnd,(INT)wParam,(BOOL)lParam);
     8085
     8086    case LVM_FINDITEMA:
     8087      return LISTVIEW_FindItem(hwnd,(INT)wParam,(LPLVFINDINFOW)lParam,FALSE);
     8088
     8089    case LVM_FINDITEMW:
     8090      return LISTVIEW_FindItem(hwnd,(INT)wParam,(LPLVFINDINFOW)lParam,TRUE);
     8091
     8092    case LVM_GETBKCOLOR:
     8093      return LISTVIEW_GetBkColor(hwnd);
    77988094
    77998095/*      case LVM_GETBKIMAGE: */
    78008096
    7801   case LVM_GETCALLBACKMASK:
    7802     return LISTVIEW_GetCallbackMask(hwnd);
    7803 
    7804   case LVM_GETCOLUMNA:
    7805     return LISTVIEW_GetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
    7806 
    7807   case LVM_GETCOLUMNW:
    7808     return LISTVIEW_GetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
    7809 
    7810   case LVM_GETCOLUMNORDERARRAY:
    7811     return LISTVIEW_GetColumnOrderArray(hwnd, (INT)wParam, (LPINT)lParam);
    7812 
    7813   case LVM_GETCOLUMNWIDTH:
    7814     return LISTVIEW_GetColumnWidth(hwnd, (INT)wParam);
    7815 
    7816   case LVM_GETCOUNTPERPAGE:
    7817     return LISTVIEW_GetCountPerPage(hwnd);
    7818 
    7819   case LVM_GETEDITCONTROL:
    7820     return LISTVIEW_GetEditControl(hwnd);
    7821 
    7822   case LVM_GETEXTENDEDLISTVIEWSTYLE:
    7823     return LISTVIEW_GetExtendedListViewStyle(hwnd);
    7824 
    7825   case LVM_GETHEADER:
    7826     return LISTVIEW_GetHeader(hwnd);
     8097    case LVM_GETCALLBACKMASK:
     8098      return LISTVIEW_GetCallbackMask(hwnd);
     8099
     8100    case LVM_GETCOLUMNA:
     8101      return LISTVIEW_GetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
     8102
     8103    case LVM_GETCOLUMNW:
     8104      return LISTVIEW_GetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
     8105
     8106    case LVM_GETCOLUMNORDERARRAY:
     8107      return LISTVIEW_GetColumnOrderArray(hwnd, (INT)wParam, (LPINT)lParam);
     8108
     8109    case LVM_GETCOLUMNWIDTH:
     8110      return LISTVIEW_GetColumnWidth(hwnd, (INT)wParam);
     8111
     8112    case LVM_GETCOUNTPERPAGE:
     8113      return LISTVIEW_GetCountPerPage(hwnd);
     8114
     8115    case LVM_GETEDITCONTROL:
     8116      return LISTVIEW_GetEditControl(hwnd);
     8117
     8118    case LVM_GETEXTENDEDLISTVIEWSTYLE:
     8119      return LISTVIEW_GetExtendedListViewStyle(hwnd);
     8120
     8121    case LVM_GETHEADER:
     8122      return LISTVIEW_GetHeader(hwnd);
    78278123
    78288124/*      case LVM_GETHOTCURSOR: */
    78298125
    7830   case LVM_GETHOTITEM:
    7831     return LISTVIEW_GetHotItem(hwnd);
     8126    case LVM_GETHOTITEM:
     8127      return LISTVIEW_GetHotItem(hwnd);
    78328128
    78338129/*      case LVM_GETHOVERTIME: */
    78348130
    7835   case LVM_GETIMAGELIST:
    7836     return LISTVIEW_GetImageList(hwnd, (INT)wParam);
    7837 
    7838 /*      case LVM_GETISEARCHSTRING: */
    7839 
    7840   case LVM_GETITEMA:
    7841     return LISTVIEW_GetItem(hwnd,(LPLVITEMW)lParam,FALSE,FALSE);
    7842 
    7843   case LVM_GETITEMW:
    7844     return LISTVIEW_GetItem(hwnd,(LPLVITEMW)lParam,TRUE,FALSE);
    7845 
    7846   case LVM_GETITEMCOUNT:
    7847     return LISTVIEW_GetItemCount(hwnd);
    7848 
    7849   case LVM_GETITEMPOSITION:
    7850     return LISTVIEW_GetItemPosition(hwnd, (INT)wParam, (LPPOINT)lParam);
    7851 
    7852   case LVM_GETITEMRECT:
    7853     return LISTVIEW_GetItemRect(hwnd,(INT)wParam,(LPRECT)lParam,lParam ? ((LPRECT)lParam)->left:0);
    7854 
    7855   case LVM_GETITEMSPACING:
    7856     return LISTVIEW_GetItemSpacing(hwnd, (BOOL)wParam);
    7857 
    7858   case LVM_GETITEMSTATE:
    7859     return LISTVIEW_GetItemState(hwnd, (INT)wParam, (UINT)lParam);
    7860 
    7861   case LVM_GETITEMTEXTA:
    7862     LISTVIEW_GetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,FALSE);
    7863     break;
    7864 
    7865   case LVM_GETITEMTEXTW:
    7866     LISTVIEW_GetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,TRUE);
    7867     break;
    7868 
    7869   case LVM_GETNEXTITEM:
    7870     return LISTVIEW_GetNextItem(hwnd, (INT)wParam, LOWORD(lParam));
     8131    case LVM_GETIMAGELIST:
     8132      return LISTVIEW_GetImageList(hwnd, (INT)wParam);
     8133
     8134    case LVM_GETISEARCHSTRINGA:
     8135      return LISTVIEW_GetISearchString(hwnd,wParam,lParam,FALSE);
     8136
     8137    case LVM_GETISEARCHSTRINGW:
     8138      return LISTVIEW_GetISearchString(hwnd,wParam,lParam,TRUE);
     8139
     8140    case LVM_GETITEMA:
     8141      return LISTVIEW_GetItem(hwnd,(LPLVITEMW)lParam,FALSE,FALSE);
     8142
     8143    case LVM_GETITEMW:
     8144      return LISTVIEW_GetItem(hwnd,(LPLVITEMW)lParam,TRUE,FALSE);
     8145
     8146    case LVM_GETITEMCOUNT:
     8147      return LISTVIEW_GetItemCount(hwnd);
     8148
     8149    case LVM_GETITEMPOSITION:
     8150      return LISTVIEW_GetItemPosition(hwnd, (INT)wParam, (LPPOINT)lParam);
     8151
     8152    case LVM_GETITEMRECT:
     8153      return LISTVIEW_GetItemRect(hwnd,(INT)wParam,(LPRECT)lParam,lParam ? ((LPRECT)lParam)->left:0);
     8154
     8155    case LVM_GETITEMSPACING:
     8156      return LISTVIEW_GetItemSpacing(hwnd, (BOOL)wParam);
     8157
     8158    case LVM_GETITEMSTATE:
     8159      return LISTVIEW_GetItemState(hwnd, (INT)wParam, (UINT)lParam);
     8160
     8161    case LVM_GETITEMTEXTA:
     8162      return LISTVIEW_GetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,FALSE);
     8163
     8164    case LVM_GETITEMTEXTW:
     8165      return LISTVIEW_GetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,TRUE);
     8166
     8167    case LVM_GETNEXTITEM:
     8168      return LISTVIEW_GetNextItem(hwnd, (INT)wParam, LOWORD(lParam));
    78718169
    78728170/*      case LVM_GETNUMBEROFWORKAREAS: */
    78738171
    7874   case LVM_GETORIGIN:
    7875     return LISTVIEW_GetOrigin(hwnd, (LPPOINT)lParam);
    7876 
    7877   case LVM_GETSELECTEDCOUNT:
    7878     return LISTVIEW_GetSelectedCount(hwnd);
    7879 
    7880   case LVM_GETSELECTIONMARK:
    7881     return LISTVIEW_GetSelectionMark(hwnd);
    7882 
    7883   case LVM_GETSTRINGWIDTHA:
    7884     return LISTVIEW_GetStringWidth(hwnd,0,(LPWSTR)lParam,FALSE);
    7885 
    7886   case LVM_GETSTRINGWIDTHW:
    7887     return LISTVIEW_GetStringWidth(hwnd,0,(LPWSTR)lParam,TRUE);
     8172    case LVM_GETORIGIN:
     8173      return LISTVIEW_GetOrigin(hwnd, (LPPOINT)lParam);
     8174
     8175    case LVM_GETSELECTEDCOUNT:
     8176      return LISTVIEW_GetSelectedCount(hwnd);
     8177
     8178    case LVM_GETSELECTIONMARK:
     8179      return LISTVIEW_GetSelectionMark(hwnd);
     8180
     8181    case LVM_GETSTRINGWIDTHA:
     8182      return LISTVIEW_GetStringWidth(hwnd,0,(LPWSTR)lParam,FALSE);
     8183
     8184    case LVM_GETSTRINGWIDTHW:
     8185      return LISTVIEW_GetStringWidth(hwnd,0,(LPWSTR)lParam,TRUE);
    78888186
    78898187/*      case LVM_GETSUBITEMRECT: */
    78908188
    7891   case LVM_GETTEXTBKCOLOR:
    7892     return LISTVIEW_GetTextBkColor(hwnd);
    7893 
    7894   case LVM_GETTEXTCOLOR:
    7895     return LISTVIEW_GetTextColor(hwnd);
     8189    case LVM_GETTEXTBKCOLOR:
     8190      return LISTVIEW_GetTextBkColor(hwnd);
     8191
     8192    case LVM_GETTEXTCOLOR:
     8193      return LISTVIEW_GetTextColor(hwnd);
    78968194
    78978195/*      case LVM_GETTOOLTIPS: */
    78988196
    7899   case LVM_GETTOPINDEX:
    7900     return LISTVIEW_GetTopIndex(hwnd);
    7901 
    7902   case LVM_GETVIEWRECT:
    7903     return LISTVIEW_GetViewRect(hwnd, (LPRECT)lParam);
     8197    case LVM_GETTOPINDEX:
     8198      return LISTVIEW_GetTopIndex(hwnd);
     8199
     8200    case LVM_GETVIEWRECT:
     8201      return LISTVIEW_GetViewRect(hwnd, (LPRECT)lParam);
    79048202
    79058203/*      case LVM_GETWORKAREAS: */
    79068204
    7907   case LVM_HITTEST:
    7908     return LISTVIEW_HitTest(hwnd, (LPLVHITTESTINFO)lParam);
    7909 
    7910   case LVM_INSERTCOLUMNA:
    7911     return LISTVIEW_InsertColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
    7912 
    7913   case LVM_INSERTCOLUMNW:
    7914     return LISTVIEW_InsertColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
    7915 
    7916   case LVM_INSERTITEMA:
    7917     return LISTVIEW_InsertItem(hwnd,(LPLVITEMW)lParam,FALSE);
    7918 
    7919   case LVM_INSERTITEMW:
    7920     return LISTVIEW_InsertItem(hwnd,(LPLVITEMW)lParam,TRUE);
    7921 
    7922   case LVM_REDRAWITEMS:
    7923     return LISTVIEW_RedrawItems(hwnd, (INT)wParam, (INT)lParam);
    7924 
    7925 /*   case LVM_SCROLL:  */
    7926 /*     return LISTVIEW_Scroll(hwnd, (INT)wParam, (INT)lParam); */
    7927 
    7928   case LVM_SETBKCOLOR:
    7929     return LISTVIEW_SetBkColor(hwnd, (COLORREF)lParam);
     8205    case LVM_HITTEST:
     8206      return LISTVIEW_HitTest(hwnd, (LPLVHITTESTINFO)lParam);
     8207
     8208    case LVM_INSERTCOLUMNA:
     8209      return LISTVIEW_InsertColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
     8210
     8211    case LVM_INSERTCOLUMNW:
     8212      return LISTVIEW_InsertColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
     8213
     8214    case LVM_INSERTITEMA:
     8215      return LISTVIEW_InsertItem(hwnd,(LPLVITEMW)lParam,FALSE);
     8216
     8217    case LVM_INSERTITEMW:
     8218      return LISTVIEW_InsertItem(hwnd,(LPLVITEMW)lParam,TRUE);
     8219
     8220    case LVM_REDRAWITEMS:
     8221      return LISTVIEW_RedrawItems(hwnd, (INT)wParam, (INT)lParam);
     8222
     8223    case LVM_SCROLL:
     8224      return LISTVIEW_Scroll(hwnd,wParam,lParam);
     8225
     8226    case LVM_SETBKCOLOR:
     8227      return LISTVIEW_SetBkColor(hwnd, (COLORREF)lParam);
    79308228
    79318229/*      case LVM_SETBKIMAGE: */
    79328230
    7933   case LVM_SETCALLBACKMASK:
    7934     return LISTVIEW_SetCallbackMask(hwnd, (UINT)wParam);
    7935 
    7936   case LVM_SETCOLUMNA:
    7937     return LISTVIEW_SetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
    7938 
    7939   case LVM_SETCOLUMNW:
    7940     return LISTVIEW_SetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
    7941 
    7942   case LVM_SETCOLUMNORDERARRAY:
    7943     return LISTVIEW_SetColumnOrderArray(hwnd, (INT)wParam, (LPINT)lParam);
    7944 
    7945   case LVM_SETCOLUMNWIDTH:
    7946     return LISTVIEW_SetColumnWidth(hwnd, (INT)wParam, (INT)lParam);
    7947 
    7948   case LVM_SETEXTENDEDLISTVIEWSTYLE:
    7949     return LISTVIEW_SetExtendedListViewStyle(hwnd, (DWORD)wParam, (DWORD)lParam);
     8231    case LVM_SETCALLBACKMASK:
     8232      return LISTVIEW_SetCallbackMask(hwnd, (UINT)wParam);
     8233
     8234    case LVM_SETCOLUMNA:
     8235      return LISTVIEW_SetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
     8236
     8237    case LVM_SETCOLUMNW:
     8238      return LISTVIEW_SetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
     8239
     8240    case LVM_SETCOLUMNORDERARRAY:
     8241      return LISTVIEW_SetColumnOrderArray(hwnd, (INT)wParam, (LPINT)lParam);
     8242
     8243    case LVM_SETCOLUMNWIDTH:
     8244      return LISTVIEW_SetColumnWidth(hwnd, (INT)wParam, (INT)lParam);
     8245
     8246    case LVM_SETEXTENDEDLISTVIEWSTYLE:
     8247      return LISTVIEW_SetExtendedListViewStyle(hwnd, (DWORD)wParam, (DWORD)lParam);
    79508248
    79518249/*      case LVM_SETHOTCURSOR: */
    79528250
    7953   case LVM_SETHOTITEM:
    7954     return LISTVIEW_SetHotItem(hwnd, (INT)wParam);
     8251    case LVM_SETHOTITEM:
     8252      return LISTVIEW_SetHotItem(hwnd, (INT)wParam);
    79558253
    79568254/*      case LVM_SETHOVERTIME: */
    79578255/*      case LVM_SETICONSPACING: */
    79588256
    7959   case LVM_SETIMAGELIST:
    7960     return LISTVIEW_SetImageList(hwnd, (INT)wParam, (HIMAGELIST)lParam);
    7961 
    7962   case LVM_SETITEMA:
    7963     return LISTVIEW_SetItem(hwnd,(LPLVITEMW)lParam,FALSE);
    7964 
    7965   case LVM_SETITEMW:
    7966     return LISTVIEW_SetItem(hwnd,(LPLVITEMW)lParam,TRUE);
    7967 
    7968   case LVM_SETITEMCOUNT:
    7969     return LISTVIEW_SetItemCount(hwnd, (INT)wParam, (DWORD)lParam);
    7970 
    7971   case LVM_SETITEMPOSITION:
    7972     return LISTVIEW_SetItemPosition(hwnd, (INT)wParam, (INT)LOWORD(lParam),
    7973                                     (INT)HIWORD(lParam));
    7974 
    7975 /*      case LVM_SETITEMPOSITION32: */
    7976 
    7977   case LVM_SETITEMSTATE:
    7978     return LISTVIEW_SetItemState(hwnd, (INT)wParam, (LPLVITEMW)lParam);
    7979 
    7980   case LVM_SETITEMTEXTA:
    7981     return LISTVIEW_SetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,FALSE);
    7982 
    7983   case LVM_SETITEMTEXTW:
    7984     return LISTVIEW_SetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,TRUE);
    7985 
    7986   case LVM_SETSELECTIONMARK:
    7987     return LISTVIEW_SetSelectionMark(hwnd, (INT)lParam);
    7988 
    7989   case LVM_SETTEXTBKCOLOR:
    7990     return LISTVIEW_SetTextBkColor(hwnd, (COLORREF)lParam);
    7991 
    7992   case LVM_SETTEXTCOLOR:
    7993     return LISTVIEW_SetTextColor(hwnd, (COLORREF)lParam);
     8257    case LVM_SETIMAGELIST:
     8258      return LISTVIEW_SetImageList(hwnd, (INT)wParam, (HIMAGELIST)lParam);
     8259
     8260    case LVM_SETITEMA:
     8261      return LISTVIEW_SetItem(hwnd,(LPLVITEMW)lParam,FALSE);
     8262
     8263    case LVM_SETITEMW:
     8264      return LISTVIEW_SetItem(hwnd,(LPLVITEMW)lParam,TRUE);
     8265
     8266    case LVM_SETITEMCOUNT:
     8267      return LISTVIEW_SetItemCount(hwnd, (INT)wParam, (DWORD)lParam);
     8268
     8269    case LVM_SETITEMPOSITION:
     8270      return LISTVIEW_SetItemPosition(hwnd,(INT)wParam,(INT)LOWORD(lParam),(INT)HIWORD(lParam),FALSE);
     8271
     8272    case LVM_SETITEMPOSITION32:
     8273      return LISTVIEW_SetItemPosition32(hwnd,(INT)wParam,(LPPOINT)lParam);
     8274
     8275    case LVM_SETITEMSTATE:
     8276      return LISTVIEW_SetItemState(hwnd, (INT)wParam, (LPLVITEMW)lParam);
     8277
     8278    case LVM_SETITEMTEXTA:
     8279      return LISTVIEW_SetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,FALSE);
     8280
     8281    case LVM_SETITEMTEXTW:
     8282      return LISTVIEW_SetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,TRUE);
     8283
     8284    case LVM_SETSELECTIONMARK:
     8285      return LISTVIEW_SetSelectionMark(hwnd, (INT)lParam);
     8286
     8287    case LVM_SETTEXTBKCOLOR:
     8288      return LISTVIEW_SetTextBkColor(hwnd, (COLORREF)lParam);
     8289
     8290    case LVM_SETTEXTCOLOR:
     8291      return LISTVIEW_SetTextColor(hwnd, (COLORREF)lParam);
    79948292
    79958293/*      case LVM_SETTOOLTIPS: */
    79968294/*      case LVM_SETWORKAREAS: */
    79978295
    7998   case LVM_SORTITEMS:
    7999     return LISTVIEW_SortItems(hwnd, wParam, lParam);
     8296    case LVM_SORTITEMS:
     8297      return LISTVIEW_SortItems(hwnd, wParam, lParam);
    80008298
    80018299/*      case LVM_SUBITEMHITTEST: */
    80028300
    8003   case LVM_UPDATE:
    8004     return LISTVIEW_Update(hwnd, (INT)wParam);
    8005 
    8006   case WM_CHAR:
    8007     return LISTVIEW_ProcessLetterKeys( hwnd, wParam, lParam );
    8008 
    8009   case WM_COMMAND:
    8010     return LISTVIEW_Command(hwnd, wParam, lParam);
    8011 
    8012   case WM_CREATE:
    8013     return LISTVIEW_Create(hwnd, wParam, lParam);
    8014 
    8015   case WM_ERASEBKGND:
    8016     return LISTVIEW_EraseBackground(hwnd, wParam, lParam);
    8017 
    8018   case WM_GETDLGCODE:
    8019     return DLGC_WANTCHARS | DLGC_WANTARROWS;
    8020 
    8021   case WM_GETFONT:
    8022     return LISTVIEW_GetFont(hwnd);
    8023 
    8024   case WM_HSCROLL:
    8025     return LISTVIEW_HScroll(hwnd, (INT)LOWORD(wParam),
    8026                             (INT)HIWORD(wParam), (HWND)lParam);
    8027 
    8028   case WM_KEYDOWN:
    8029     return LISTVIEW_KeyDown(hwnd, (INT)wParam, (LONG)lParam);
    8030 
    8031   case WM_KILLFOCUS:
    8032     return LISTVIEW_KillFocus(hwnd);
    8033 
    8034   case WM_LBUTTONDBLCLK:
    8035     return LISTVIEW_LButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam),
    8036                                 HIWORD(lParam));
    8037 
    8038   case WM_LBUTTONDOWN:
    8039     return LISTVIEW_LButtonDown(hwnd, (WORD)wParam, LOWORD(lParam),
    8040                                 HIWORD(lParam));
    8041   case WM_LBUTTONUP:
    8042     return LISTVIEW_LButtonUp(hwnd, (WORD)wParam, LOWORD(lParam),
    8043                               HIWORD(lParam));
     8301    case LVM_UPDATE:
     8302      return LISTVIEW_Update(hwnd, (INT)wParam);
     8303
     8304    case WM_CHAR:
     8305      return LISTVIEW_ProcessLetterKeys( hwnd, wParam, lParam );
     8306
     8307    case WM_COMMAND:
     8308      return LISTVIEW_Command(hwnd, wParam, lParam);
     8309
     8310    case WM_CREATE:
     8311      return LISTVIEW_Create(hwnd, wParam, lParam);
     8312
     8313    case WM_ERASEBKGND:
     8314      return LISTVIEW_EraseBackground(hwnd, wParam, lParam);
     8315
     8316    case WM_GETDLGCODE:
     8317      return DLGC_WANTCHARS | DLGC_WANTARROWS;
     8318
     8319    case WM_GETFONT:
     8320      return LISTVIEW_GetFont(hwnd);
     8321
     8322    case WM_HSCROLL:
     8323      return LISTVIEW_HScroll(hwnd,(INT)LOWORD(wParam),(INT)HIWORD(wParam),(HWND)lParam);
     8324
     8325    case WM_KEYDOWN:
     8326      return LISTVIEW_KeyDown(hwnd, (INT)wParam, (LONG)lParam);
     8327
     8328    case WM_KILLFOCUS:
     8329      return LISTVIEW_KillFocus(hwnd);
     8330
     8331    case WM_LBUTTONDBLCLK:
     8332      return LISTVIEW_LButtonDblClk(hwnd,(WORD)wParam,LOWORD(lParam),HIWORD(lParam));
     8333
     8334    case WM_LBUTTONDOWN:
     8335      return LISTVIEW_LButtonDown(hwnd,(WORD)wParam,LOWORD(lParam),HIWORD(lParam));
     8336
     8337    case WM_LBUTTONUP:
     8338      return LISTVIEW_LButtonUp(hwnd,(WORD)wParam,LOWORD(lParam),HIWORD(lParam));
    80448339
    80458340/*      case WM_MOUSEMOVE: */
    80468341/*          return LISTVIEW_MouseMove (hwnd, wParam, lParam); */
    80478342
    8048   case WM_NCCREATE:
    8049     return LISTVIEW_NCCreate(hwnd, wParam, lParam);
    8050 
    8051   case WM_NCDESTROY:
    8052     return LISTVIEW_NCDestroy(hwnd);
    8053 
    8054   case WM_NOTIFY:
    8055     return LISTVIEW_Notify(hwnd, (INT)wParam, (LPNMHDR)lParam);
    8056 
    8057   case WM_PAINT:
    8058     return LISTVIEW_Paint(hwnd, (HDC)wParam);
    8059 
    8060   case WM_RBUTTONDBLCLK:
    8061     return LISTVIEW_RButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam),
    8062                                   HIWORD(lParam));
    8063 
    8064   case WM_RBUTTONDOWN:
    8065     return LISTVIEW_RButtonDown(hwnd, (WORD)wParam, LOWORD(lParam),
    8066                                 HIWORD(lParam));
    8067 
    8068   case WM_RBUTTONUP:
    8069     return LISTVIEW_RButtonUp(hwnd, (WORD)wParam, LOWORD(lParam),
    8070                               HIWORD(lParam));
    8071 
    8072   case WM_SETFOCUS:
    8073     return LISTVIEW_SetFocus(hwnd, (HWND)wParam);
    8074 
    8075   case WM_SETFONT:
    8076     return LISTVIEW_SetFont(hwnd, (HFONT)wParam, (WORD)lParam);
    8077 
    8078   case WM_SETREDRAW:
    8079     return LISTVIEW_SetRedraw(hwnd, (BOOL)wParam);
    8080 
    8081   case WM_SIZE:
    8082     return LISTVIEW_Size(hwnd, (int)SLOWORD(lParam), (int)SHIWORD(lParam));
    8083 
    8084   case WM_STYLECHANGED:
    8085     return LISTVIEW_StyleChanged(hwnd, wParam, (LPSTYLESTRUCT)lParam);
    8086 
    8087   case WM_TIMER:
    8088     return LISTVIEW_Timer(hwnd,wParam,lParam);
    8089 
    8090   case WM_VSCROLL:
    8091     return LISTVIEW_VScroll(hwnd,(INT)LOWORD(wParam),(INT)HIWORD(wParam),(HWND)lParam);
    8092 
    8093   case WM_MOUSEWHEEL:
    8094       if (wParam & (MK_SHIFT | MK_CONTROL))
    8095           return DefWindowProcA( hwnd, uMsg, wParam, lParam );
    8096       return LISTVIEW_MouseWheel(hwnd, (short int)HIWORD(wParam));
     8343    case WM_NCCREATE:
     8344      return LISTVIEW_NCCreate(hwnd, wParam, lParam);
     8345
     8346    case WM_NCDESTROY:
     8347      return LISTVIEW_NCDestroy(hwnd);
     8348
     8349    case WM_NOTIFY:
     8350      return LISTVIEW_Notify(hwnd, (INT)wParam, (LPNMHDR)lParam);
     8351
     8352    case WM_PAINT:
     8353      return LISTVIEW_Paint(hwnd, (HDC)wParam);
     8354
     8355    case WM_RBUTTONDBLCLK:
     8356      return LISTVIEW_RButtonDblClk(hwnd,(WORD)wParam,LOWORD(lParam),HIWORD(lParam));
     8357
     8358    case WM_RBUTTONDOWN:
     8359      return LISTVIEW_RButtonDown(hwnd,(WORD)wParam,LOWORD(lParam),HIWORD(lParam));
     8360
     8361    case WM_RBUTTONUP:
     8362      return LISTVIEW_RButtonUp(hwnd,(WORD)wParam,LOWORD(lParam),HIWORD(lParam));
     8363
     8364    case WM_SETFOCUS:
     8365      return LISTVIEW_SetFocus(hwnd, (HWND)wParam);
     8366
     8367    case WM_SETFONT:
     8368      return LISTVIEW_SetFont(hwnd, (HFONT)wParam, (WORD)lParam);
     8369
     8370    case WM_SETREDRAW:
     8371      return LISTVIEW_SetRedraw(hwnd, (BOOL)wParam);
     8372
     8373    case WM_SIZE:
     8374      return LISTVIEW_Size(hwnd, (int)SLOWORD(lParam), (int)SHIWORD(lParam));
     8375
     8376    case WM_STYLECHANGED:
     8377      return LISTVIEW_StyleChanged(hwnd, wParam, (LPSTYLESTRUCT)lParam);
     8378
     8379    case WM_TIMER:
     8380      return LISTVIEW_Timer(hwnd,wParam,lParam);
     8381
     8382    case WM_VSCROLL:
     8383      return LISTVIEW_VScroll(hwnd,(INT)LOWORD(wParam),(INT)HIWORD(wParam),(HWND)lParam);
     8384
     8385    case WM_MOUSEWHEEL:
     8386      return LISTVIEW_MouseWheel(hwnd,wParam,lParam);
    80978387
    80988388/*      case WM_WINDOWPOSCHANGED: */
    80998389/*      case WM_WININICHANGE: */
    81008390
    8101   default:
    8102     //if (uMsg >= WM_USER)
    8103     //{
    8104     //  ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam,
    8105     //      lParam);
    8106     //}
    8107 
    8108     /* call default window procedure */
    8109     return defComCtl32ProcA(hwnd, uMsg, wParam, lParam);
     8391    default:
     8392      //if (uMsg >= WM_USER)
     8393      //{
     8394      //  ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam,
     8395      //      lParam);
     8396      //}
     8397
     8398      /* call default window procedure */
     8399      return defComCtl32ProcA(hwnd, uMsg, wParam, lParam);
    81108400  }
    81118401
Note: See TracChangeset for help on using the changeset viewer.