Changeset 2858 for trunk/src


Ignore:
Timestamp:
Feb 22, 2000, 6:11:41 PM (26 years ago)
Author:
cbratschi
Message:

Corel 20000212, TREEVIEW_Sort fix, CCBase

Location:
trunk/src/comctl32
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/animate.c

    r1431 r2858  
    1 /* $Id: animate.c,v 1.6 1999-10-24 22:49:42 sandervl Exp $ */
     1/* $Id: animate.c,v 1.7 2000-02-22 17:11:38 cbratschi Exp $ */
    22/*
    33 * Animation control
     
    446446    WNDCLASSA wndClass;
    447447
    448 //SvL: Don't check this now
    449 //    if (GlobalFindAtomA (ANIMATE_CLASSA)) return;
    450 
    451448    ZeroMemory (&wndClass, sizeof(WNDCLASSA));
    452449    wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS;
     
    465462ANIMATE_Unregister (VOID)
    466463{
    467     if (GlobalFindAtomA (ANIMATE_CLASSA))
    468         UnregisterClassA (ANIMATE_CLASSA, (HINSTANCE)NULL);
    469 }
    470 
     464    UnregisterClassA (ANIMATE_CLASSA, (HINSTANCE)NULL);
     465}
     466
  • trunk/src/comctl32/comctl32undoc.c

    r2820 r2858  
    1 /* $Id: comctl32undoc.c,v 1.18 2000-02-18 17:13:37 cbratschi Exp $ */
     1/* $Id: comctl32undoc.c,v 1.19 2000-02-22 17:11:38 cbratschi Exp $ */
    22/*
    33 * Undocumented functions from COMCTL32.DLL
     
    1212 */
    1313
    14 /* WINE 20000130 level */
     14/*
     15 - Corel 20000212 level
     16 - WINE 20000130 level
     17*/
    1518
    1619/* CB: todo
     
    14851488    INT  i, j;
    14861489
    1487 //    TRACE (commctrl, "l=%i r=%i\n", l, r);
     1490    //TRACE("l=%i r=%i\n", l, r);
    14881491
    14891492    i = l;
    14901493    j = r;
     1494
     1495    if ( i >= j )
     1496        return;
     1497    else if ( i == (j - 1) )
     1498    {
     1499        if ( (pfnCompare)( lpPtrs[i], lpPtrs[j], lParam ) > 0 )
     1500        {
     1501            t = lpPtrs[i];
     1502            lpPtrs[i] = lpPtrs[j];
     1503            lpPtrs[j] = t;
     1504        }
     1505        return;
     1506    }
     1507
    14911508    v = lpPtrs[(int)(l+r)/2];
    1492     do {
    1493         while ((pfnCompare)(lpPtrs[i], v, lParam) < 0) i++;
    1494         while ((pfnCompare)(lpPtrs[j], v, lParam) > 0) j--;
    1495         if (i <= j)
     1509
     1510    while ( i < j)
     1511    {
     1512        while ( (pfnCompare)( lpPtrs[i], v, lParam ) <= 0 && i < j )
     1513            i++;
     1514
     1515        while ( (pfnCompare)( v, lpPtrs[j], lParam ) <= 0 && i < j )
     1516            j--;
     1517
     1518        if ( i < j )
    14961519        {
     1520            /* Swap the values; increment i and decrement j to avoid
     1521               infinite conditions where i and j swap forever */
    14971522            t = lpPtrs[i];
    14981523            lpPtrs[i++] = lpPtrs[j];
    14991524            lpPtrs[j--] = t;
    15001525        }
    1501     } while (i <= j);
    1502     if (l < j) DPA_QuickSort (lpPtrs, l, j, pfnCompare, lParam);
    1503     if (i < r) DPA_QuickSort (lpPtrs, i, r, pfnCompare, lParam);
     1526    }
     1527
     1528    if ( i - 1 > l )
     1529        DPA_QuickSort (lpPtrs, l, i - 1, pfnCompare, lParam);
     1530    if ( j + 1 < r )
     1531        DPA_QuickSort (lpPtrs, j + 1, r, pfnCompare, lParam);
    15041532}
    15051533
  • trunk/src/comctl32/listview.c

    r2740 r2858  
    1 /*$Id: listview.c,v 1.22 2000-02-10 18:51:17 cbratschi Exp $*/
     1/*$Id: listview.c,v 1.23 2000-02-22 17:11:38 cbratschi Exp $*/
    22/*
    33 * Listview control
     
    4545 */
    4646
    47 /* WINE 20000130 level */
     47/*
     48 - Corel 20000212 level
     49 - WINE 20000130 level
     50*/
    4851
    4952#include <string.h>
     
    5962
    6063/* maximum size of a label */
    61 #define DISP_TEXT_SIZE 512
     64#define DISP_TEXT_SIZE 128
    6265
    6366/* padding for items in list and small icon display modes */
     
    105108 * forward declarations
    106109 */
    107 static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem, BOOL internal);
     110
    108111static INT LISTVIEW_HitTestItem(HWND, LPLVHITTESTINFO);
    109112static INT LISTVIEW_GetCountPerRow(HWND);
     
    144147static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem);
    145148static LRESULT LISTVIEW_Command(HWND hwnd, WPARAM wParam, LPARAM lParam);
     149static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam);
    146150
    147151/*************************************************************************
     
    209213    INT nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd);
    210214    INT nCountPerRow = LISTVIEW_GetCountPerRow(hwnd);
    211     INT nCountPerPage = nCountPerRow * nCountPerColumn;
    212215    INT nNumOfItems = GETITEMCOUNT(infoPtr);
    213216
    214     if (nCountPerPage < GETITEMCOUNT(infoPtr))
    215     {
    216       scrollInfo.nMax = nNumOfItems / nCountPerColumn;
    217       if((nNumOfItems % nCountPerColumn) == 0)
    218       {
    219           scrollInfo.nMax--;
    220       }
    221       scrollInfo.nPos = ListView_GetTopIndex(hwnd) / nCountPerColumn;
    222       scrollInfo.nPage = nCountPerRow;
    223       scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
    224       SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
    225     }
    226     else
    227     {
    228       /* hide scrollbar */
    229       if (lStyle & WS_HSCROLL)
    230       {
    231         ShowScrollBar(hwnd, SB_HORZ, FALSE);
    232       }
    233     }
     217    scrollInfo.nMax = nNumOfItems / nCountPerColumn;
     218    if((nNumOfItems % nCountPerColumn) == 0)
     219    {
     220        scrollInfo.nMax--;
     221    }
     222    scrollInfo.nPos = ListView_GetTopIndex(hwnd) / nCountPerColumn;
     223    scrollInfo.nPage = nCountPerRow;
     224    scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
     225    SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
    234226  }
    235227  else if (uView == LVS_REPORT)
     
    244236
    245237    /* update horizontal scrollbar */
    246     if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE)
     238    nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;
     239    if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE
     240       || GETITEMCOUNT(infoPtr) == 0)
    247241    {
    248242      scrollInfo.nPos = 0;
     
    269263      INT nViewHeight = rcView.bottom - rcView.top;
    270264
    271       if (nViewWidth > nListWidth)
    272       {
    273         scrollInfo.fMask = SIF_POS;
    274         if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE)
    275         {
    276           scrollInfo.nPos = 0;
    277         }
    278         scrollInfo.nMax = max(nViewWidth / LISTVIEW_SCROLL_DIV_SIZE, 0)-1;
    279         scrollInfo.nMin = 0;
    280         scrollInfo.nPage = nListWidth / LISTVIEW_SCROLL_DIV_SIZE;
    281         scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
    282         SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
    283       }
    284       else
    285       {
    286         if (lStyle & WS_HSCROLL)
    287         {
    288           ShowScrollBar(hwnd, SB_HORZ, FALSE);
    289         }
    290       }
    291 
    292       if (nViewHeight > nListHeight)
    293       {
    294         scrollInfo.fMask = SIF_POS;
    295         if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) == FALSE)
    296         {
    297           scrollInfo.nPos = 0;
    298         }
    299         scrollInfo.nMax = max(nViewHeight / LISTVIEW_SCROLL_DIV_SIZE,0)-1;
    300         scrollInfo.nMin = 0;
    301         scrollInfo.nPage = nListHeight / LISTVIEW_SCROLL_DIV_SIZE;
    302         scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
    303         SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE);
    304       }
    305       else
    306       {
    307         if (lStyle & WS_VSCROLL)
    308         {
    309           ShowScrollBar(hwnd, SB_VERT, FALSE);
    310         }
    311       }
     265      /* Update Horizontal Scrollbar */
     266      scrollInfo.fMask = SIF_POS;
     267      if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE
     268        || GETITEMCOUNT(infoPtr) == 0)
     269      {
     270        scrollInfo.nPos = 0;
     271      }
     272      scrollInfo.nMax = max(nViewWidth / LISTVIEW_SCROLL_DIV_SIZE, 0)-1;
     273      scrollInfo.nMin = 0;
     274      scrollInfo.nPage = nListWidth / LISTVIEW_SCROLL_DIV_SIZE;
     275      scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
     276      SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
     277
     278      /* Update Vertical Scrollbar */
     279      nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;
     280      scrollInfo.fMask = SIF_POS;
     281      if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) == FALSE
     282        || GETITEMCOUNT(infoPtr) == 0)
     283      {
     284        scrollInfo.nPos = 0;
     285      }
     286      scrollInfo.nMax = max(nViewHeight / LISTVIEW_SCROLL_DIV_SIZE,0)-1;
     287      scrollInfo.nMin = 0;
     288      scrollInfo.nPage = nListHeight / LISTVIEW_SCROLL_DIV_SIZE;
     289      scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
     290      SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE);
    312291    }
    313292  }
     
    654633      }
    655634    }
     635  }
     636
     637  if(nItemWidth == 0)
     638  {
     639      /* nItemWidth Cannot be Zero */
     640      nItemWidth = 1;
    656641  }
    657642
     
    17791764  lvItem.cchTextMax = DISP_TEXT_SIZE;
    17801765  lvItem.pszText = szDispText;
    1781   LISTVIEW_GetItemA(hwnd,&lvItem,TRUE);
     1766  ListView_GetItemA(hwnd,&lvItem);
    17821767
    17831768  /* set item colors */
     
    18231808  lvItem.cchTextMax = DISP_TEXT_SIZE;
    18241809  lvItem.pszText = szDispText;
    1825   LISTVIEW_GetItemA(hwnd,&lvItem,TRUE);
     1810  ListView_GetItemA(hwnd,&lvItem);
    18261811
    18271812  /* state icons */
     
    18881873  nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText);
    18891874  if (rcItem.left + nLabelWidth < rcItem.right)
    1890   {
    18911875    rcItem.right = rcItem.left + nLabelWidth;
    1892   }
    18931876
    18941877  /* draw label */
     
    19441927  lvItem.cchTextMax = DISP_TEXT_SIZE;
    19451928  lvItem.pszText = szDispText;
    1946   LISTVIEW_GetItemA(hwnd, &lvItem,TRUE);
     1929  ListView_GetItemA(hwnd, &lvItem);
    19471930
    19481931  if (lvItem.state & LVIS_SELECTED)
     
    27642747  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    27652748  HDPA hdpaSubItems;
     2749  BOOL bUpdateItemText;
    27662750
    27672751  ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA));
     
    27842768  dispInfo.item.iImage = lpItem->iImage;
    27852769  dispInfo.item.lParam = lpItem->lParam;
    2786 
    2787   ListView_Notify(GetParent(hwnd), nCtrlId, &dispInfo);
    27882770  infoPtr->hwndEdit = 0;
     2771
     2772  bUpdateItemText = ListView_Notify(GetParent(hwnd), nCtrlId, &dispInfo);
     2773
     2774  /* Do we need to update the Item Text */
     2775  if(bUpdateItemText)
     2776  {
     2777    if(lpItem->pszText != LPSTR_TEXTCALLBACKA)
     2778    {
     2779        Str_SetPtrA(&lpItem->pszText, pszText);
     2780    }
     2781  }
    27892782
    27902783  return TRUE;
     
    28142807  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    28152808  HDPA hdpaSubItems;
     2809  CHAR szDispText[DISP_TEXT_SIZE];
     2810  LVITEMA lvItem;
     2811
    28162812
    28172813  if (~GetWindowLongA(hwnd, GWL_STYLE) & LVS_EDITLABELS)
    28182814      return FALSE;
     2815
     2816  /* Is the EditBox still there, if so remove it */
     2817  if(infoPtr->hwndEdit != 0)
     2818  {
     2819      SetFocus(hwnd);
     2820  }
    28192821
    28202822  LISTVIEW_SetSelection(hwnd, nItem);
     
    28272829  if (NULL == (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0)))
    28282830          return 0;
     2831
     2832  /* get information needed for drawing the item */
     2833  ZeroMemory(&lvItem, sizeof(LVITEMA));
     2834  lvItem.mask = LVIF_TEXT;
     2835  lvItem.iItem = nItem;
     2836  lvItem.iSubItem = 0;
     2837  lvItem.cchTextMax = DISP_TEXT_SIZE;
     2838  lvItem.pszText = szDispText;
     2839  ListView_GetItemA(hwnd, &lvItem);
    28292840
    28302841  dispInfo.hdr.hwndFrom = hwnd;
     
    28352846  dispInfo.item.state = lpItem->state;
    28362847  dispInfo.item.stateMask = 0;
    2837   dispInfo.item.pszText = lpItem->pszText;
    2838   dispInfo.item.cchTextMax = strlen(lpItem->pszText);
     2848  dispInfo.item.pszText = lvItem.pszText;
     2849  dispInfo.item.cchTextMax = strlen(lvItem.pszText);
    28392850  dispInfo.item.iImage = lpItem->iImage;
    28402851  dispInfo.item.lParam = lpItem->lParam;
     
    28472858          return 0;
    28482859
    2849  if (!(hedit = CreateEditLabel(dispInfo.item.pszText , WS_VISIBLE,
    2850                  rect.left, rect.top, rect.right - rect.left + 15,
    2851                  rect.bottom - rect.top,
     2860  if (!(hedit = CreateEditLabel(szDispText , WS_VISIBLE,
     2861                 rect.left-2, rect.top-1, 0,
     2862                 rect.bottom - rect.top+2,
    28522863                 hwnd, hinst, LISTVIEW_EndEditLabel, nItem)))
    28532864         return 0;
     
    28772888  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    28782889  UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
    2879   INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;
    2880   INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;
    28812890  INT nScrollPosHeight = 0;
    28822891  INT nScrollPosWidth = 0;
     
    29052914        else if ((uView == LVS_SMALLICON) || (uView == LVS_ICON))
    29062915        {
    2907           nScrollPosWidth = max(1, nListWidth / LISTVIEW_SCROLL_DIV_SIZE);
     2916          nScrollPosWidth = LISTVIEW_SCROLL_DIV_SIZE;
    29082917          rcItem.left += infoPtr->rcList.left;
    29092918        }
    29102919
    2911         if (rcItem.left % nScrollPosWidth == 0)
    2912         {
    2913           scrollInfo.nPos += rcItem.left / nScrollPosWidth;
    2914         }
    2915         else
    2916         {
    2917           scrollInfo.nPos += rcItem.left / nScrollPosWidth - 1;
    2918         }
    2919 
    2920         SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
     2920        /* When in LVS_REPORT view, the scroll position should
     2921           not be updated. */
     2922        if (nScrollPosWidth != 0)
     2923        {
     2924          if (rcItem.left % nScrollPosWidth == 0)
     2925          {
     2926            scrollInfo.nPos += rcItem.left / nScrollPosWidth;
     2927          }
     2928          else
     2929          {
     2930            scrollInfo.nPos += rcItem.left / nScrollPosWidth - 1;
     2931          }
     2932
     2933          SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
     2934        }
    29212935      }
    29222936    }
     
    29342948        {
    29352949          rcItem.right -= infoPtr->rcList.right;
    2936           nScrollPosWidth = max(1, nListWidth / LISTVIEW_SCROLL_DIV_SIZE);
    2937         }
    2938 
    2939         if (rcItem.right % nScrollPosWidth == 0)
    2940         {
    2941           scrollInfo.nPos += rcItem.right / nScrollPosWidth;
    2942         }
    2943         else
    2944         {
    2945           scrollInfo.nPos += rcItem.right / nScrollPosWidth + 1;
    2946         }
    2947 
    2948         SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
     2950          nScrollPosWidth = LISTVIEW_SCROLL_DIV_SIZE;
     2951        }
     2952
     2953        /* When in LVS_REPORT view, the scroll position should
     2954           not be updated. */
     2955        if (nScrollPosWidth != 0)
     2956        {
     2957          if (rcItem.right % nScrollPosWidth == 0)
     2958          {
     2959            scrollInfo.nPos += rcItem.right / nScrollPosWidth;
     2960          }
     2961          else
     2962          {
     2963            scrollInfo.nPos += rcItem.right / nScrollPosWidth + 1;
     2964          }
     2965
     2966          SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
     2967        }
    29492968      }
    29502969    }
     
    29622981        else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON))
    29632982        {
    2964           nScrollPosHeight = max(1, nListHeight / LISTVIEW_SCROLL_DIV_SIZE);
     2983          nScrollPosHeight = LISTVIEW_SCROLL_DIV_SIZE;
    29652984          rcItem.top += infoPtr->rcList.top;
    29662985        }
     
    29903009        else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON))
    29913010        {
    2992           nScrollPosHeight = max(1, nListHeight / LISTVIEW_SCROLL_DIV_SIZE);
     3011          nScrollPosHeight = LISTVIEW_SCROLL_DIV_SIZE;
    29933012          rcItem.bottom -= infoPtr->rcList.bottom;
    29943013        }
     
    31543173        lvItem.iItem = nItem;
    31553174        lvItem.iSubItem = 0;
    3156         if (LISTVIEW_GetItemA(hwnd, &lvItem,TRUE) != FALSE)
     3175        if (ListView_GetItemA(hwnd, &lvItem) != FALSE)
    31573176        {
    31583177          if (lvItem.mask & LVIF_TEXT)
     
    32843303    if (lpColumn->mask & LVCF_TEXT)
    32853304    {
    3286       hdi.mask |= (HDI_TEXT | HDI_FORMAT);
     3305      hdi.mask |= HDI_TEXT;
     3306      hdi.cchTextMax = lpColumn->cchTextMax;
     3307      hdi.pszText    = lpColumn->pszText;
    32873308    }
    32883309
     
    33263347      {
    33273348        lpColumn->cx = hdi.cxy;
    3328       }
    3329 
    3330       if ((lpColumn->mask & LVCF_TEXT) && (lpColumn->pszText) && (hdi.pszText))
    3331       {
    3332         lstrcpynA (lpColumn->pszText, hdi.pszText, lpColumn->cchTextMax);
    33333349      }
    33343350
     
    35323548 *   FAILURE : FALSE
    35333549 */
    3534 static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem, BOOL internal)
     3550static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem)
    35353551{
    35363552  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    35373553  LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);
     3554  BOOL bResult = FALSE;
    35383555  NMLVDISPINFOA dispInfo;
    35393556  LISTVIEW_SUBITEM *lpSubItem;
    35403557  LISTVIEW_ITEM *lpItem;
    3541   INT* piImage;
    3542   LPSTR* ppszText;
    35433558  HDPA hdpaSubItems;
    35443559
    3545   /* In the following:
    3546    * lpLVItem describes the information requested by the user
    3547    * lpItem/lpSubItem is what we have
    3548    * dispInfo is a structure we use to request the missing
    3549    *     information from the application
    3550    */
    3551 
    35523560  //TRACE("(hwnd=%x, lpLVItem=%p)\n", hwnd, lpLVItem);
    3553   if ((lpLVItem == NULL) ||
    3554       (lpLVItem->iItem < 0) ||
    3555       (lpLVItem->iItem >= GETITEMCOUNT(infoPtr))
    3556      )
    3557     return FALSE;
    3558 
    3559   hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem);
    3560   if (hdpaSubItems == NULL)
    3561     return FALSE;
    3562 
    3563   lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);
    3564   if (lpItem == NULL)
    3565     return FALSE;
    3566 
    3567   ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA));
    3568   if (lpLVItem->iSubItem == 0)
    3569   {
    3570     piImage=&lpItem->iImage;
    3571     ppszText=&lpItem->pszText;
    3572     if ((infoPtr->uCallbackMask != 0) && (lpLVItem->mask & LVIF_STATE))
    3573     {
    3574       dispInfo.item.mask |= LVIF_STATE;
    3575       dispInfo.item.stateMask = infoPtr->uCallbackMask;
    3576     }
    3577   }
    3578   else
    3579   {
    3580     lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, lpLVItem->iSubItem);
    3581     if (lpSubItem != NULL)
    3582     {
    3583       piImage=&lpItem->iImage;
    3584       ppszText=&lpItem->pszText;
    3585     }
    3586     else
    3587     {
    3588       piImage=NULL;
    3589       ppszText=NULL;
    3590     }
    3591   }
    3592   if ((lpLVItem->mask & LVIF_IMAGE) &&
    3593       ((piImage==NULL) || (*piImage == I_IMAGECALLBACK)))
    3594   {
    3595     dispInfo.item.mask |= LVIF_IMAGE;
    3596   }
    3597   if ((lpLVItem->mask & LVIF_TEXT) &&
    3598       ((ppszText==NULL) || (*ppszText == LPSTR_TEXTCALLBACKA)))
    3599   {
    3600     dispInfo.item.mask |= LVIF_TEXT;
    3601     dispInfo.item.pszText = lpLVItem->pszText;
    3602     dispInfo.item.cchTextMax = lpLVItem->cchTextMax;
    3603   }
    3604   if (dispInfo.item.mask != 0)
    3605   {
    3606     /* We don't have all the requested info, query the application */
    3607     dispInfo.hdr.hwndFrom = hwnd;
    3608     dispInfo.hdr.idFrom = lCtrlId;
    3609     dispInfo.hdr.code = LVN_GETDISPINFOA;
    3610     dispInfo.item.iItem = lpLVItem->iItem;
    3611     dispInfo.item.iSubItem = lpLVItem->iSubItem;
    3612     dispInfo.item.lParam = lpItem->lParam;
    3613     ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo);
    3614   }
    3615   if (dispInfo.item.mask & LVIF_IMAGE)
    3616   {
    3617     lpLVItem->iImage = dispInfo.item.iImage;
    3618   }
    3619   else if (lpLVItem->mask & LVIF_IMAGE)
    3620   {
    3621     lpLVItem->iImage = *piImage;
    3622   }
    3623   if (dispInfo.item.mask & LVIF_TEXT)
    3624   {
    3625     if ((dispInfo.item.mask & LVIF_DI_SETITEM) && (ppszText != NULL))
    3626     {
    3627       Str_SetPtrA(ppszText, dispInfo.item.pszText);
    3628     }
    3629     /* Here lpLVItem->pszText==dispInfo.item.pszText so a copy is unnecessary */
    3630   }
    3631   else if (lpLVItem->mask & LVIF_TEXT)
    3632   {
    3633     if (internal==TRUE)
    3634     {
    3635       lpLVItem->pszText=*ppszText;
    3636     } else {
    3637       lstrcpynA(lpLVItem->pszText, *ppszText, lpLVItem->cchTextMax);
    3638     }
    3639   }
    3640 
    3641   if (lpLVItem->iSubItem == 0)
    3642   {
    3643     if (dispInfo.item.mask & LVIF_STATE)
    3644     {
    3645       lpLVItem->state = lpItem->state;
    3646       lpLVItem->state &= ~dispInfo.item.stateMask;
    3647       lpLVItem->state |= (dispInfo.item.state & dispInfo.item.stateMask);
    3648     }
    3649     else if (lpLVItem->mask & LVIF_STATE)
    3650     {
    3651       lpLVItem->state = lpItem->state & lpLVItem->stateMask;
    3652     }
    3653 
    3654     if (lpLVItem->mask & LVIF_PARAM)
    3655     {
    3656       lpLVItem->lParam = lpItem->lParam;
    3657     }
    3658 
    3659     if (lpLVItem->mask & LVIF_INDENT)
    3660     {
    3661       lpLVItem->iIndent = lpItem->iIndent;
    3662     }
    3663   }
    3664 
    3665   return TRUE;
     3561
     3562  if (lpLVItem != NULL)
     3563  {
     3564    if ((lpLVItem->iItem >= 0) && (lpLVItem->iItem < GETITEMCOUNT(infoPtr)))
     3565    {
     3566      ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA));
     3567      hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem);
     3568      if (hdpaSubItems != NULL)
     3569      {
     3570        lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);
     3571        if (lpItem != NULL)
     3572        {
     3573          bResult = TRUE;
     3574          if (lpLVItem->iSubItem == 0)
     3575          {
     3576            if ((lpItem->iImage == I_IMAGECALLBACK) &&
     3577                (lpLVItem->mask & LVIF_IMAGE))
     3578            {
     3579              dispInfo.item.mask |= LVIF_IMAGE;
     3580            }
     3581
     3582            if ((lpItem->pszText == LPSTR_TEXTCALLBACKA) &&
     3583                (lpLVItem->mask & LVIF_TEXT))
     3584            {
     3585              dispInfo.item.mask |= LVIF_TEXT;
     3586              ZeroMemory(lpLVItem->pszText, sizeof(CHAR)*lpLVItem->cchTextMax);
     3587              dispInfo.item.pszText = lpLVItem->pszText;
     3588              dispInfo.item.cchTextMax = lpLVItem->cchTextMax;
     3589            }
     3590
     3591            if ((infoPtr->uCallbackMask != 0) && (lpLVItem->mask & LVIF_STATE))
     3592            {
     3593              dispInfo.item.mask |= LVIF_STATE;
     3594              dispInfo.item.stateMask = infoPtr->uCallbackMask;
     3595            }
     3596
     3597            if (dispInfo.item.mask != 0)
     3598            {
     3599              dispInfo.hdr.hwndFrom = hwnd;
     3600              dispInfo.hdr.idFrom = lCtrlId;
     3601              dispInfo.hdr.code = LVN_GETDISPINFOA;
     3602              dispInfo.item.iItem = lpLVItem->iItem;
     3603              dispInfo.item.iSubItem = 0;
     3604              dispInfo.item.lParam = lpItem->lParam;
     3605              ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo);
     3606            }
     3607
     3608            if (dispInfo.item.mask & LVIF_IMAGE)
     3609            {
     3610              lpLVItem->iImage = dispInfo.item.iImage;
     3611            }
     3612            else if (lpLVItem->mask & LVIF_IMAGE)
     3613            {
     3614              lpLVItem->iImage = lpItem->iImage;
     3615            }
     3616
     3617            if (dispInfo.item.mask & LVIF_TEXT)
     3618            {
     3619              if (dispInfo.item.mask & LVIF_DI_SETITEM)
     3620              {
     3621                Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText);
     3622              }
     3623              /* Make sure the source string is valid */
     3624              if (dispInfo.item.pszText == NULL)
     3625                lpLVItem->pszText[0] = '\0';
     3626              else
     3627              {
     3628                strncpy(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
     3629                lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0';
     3630              }
     3631            }
     3632            else if (lpLVItem->mask & LVIF_TEXT)
     3633            {
     3634              if (lpItem->pszText != NULL)
     3635              {
     3636                strncpy(lpLVItem->pszText, lpItem->pszText,
     3637                        lpLVItem->cchTextMax);
     3638                lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0';
     3639              }
     3640              else
     3641              {
     3642                ZeroMemory(lpLVItem->pszText, sizeof(char)*
     3643                           lpLVItem->cchTextMax);
     3644              }
     3645            }
     3646
     3647            if (dispInfo.item.mask & LVIF_STATE)
     3648            {
     3649              lpLVItem->state = lpItem->state;
     3650              lpLVItem->state &= ~dispInfo.item.stateMask;
     3651              lpLVItem->state |= (dispInfo.item.state &
     3652                                  dispInfo.item.stateMask);
     3653            }
     3654            else if (lpLVItem->mask & LVIF_STATE)
     3655            {
     3656              lpLVItem->state = lpItem->state & lpLVItem->stateMask;
     3657            }
     3658
     3659            if (lpLVItem->mask & LVIF_PARAM)
     3660            {
     3661              lpLVItem->lParam = lpItem->lParam;
     3662            }
     3663
     3664            if (lpLVItem->mask & LVIF_INDENT)
     3665            {
     3666              lpLVItem->iIndent = lpItem->iIndent;
     3667            }
     3668          }
     3669          else
     3670          {
     3671            lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems,
     3672                                               lpLVItem->iSubItem);
     3673            if (lpSubItem != NULL)
     3674            {
     3675              if ((lpSubItem->iImage == I_IMAGECALLBACK) &&
     3676                  (lpLVItem->mask & LVIF_IMAGE))
     3677              {
     3678                dispInfo.item.mask |= LVIF_IMAGE;
     3679              }
     3680
     3681              if ((lpSubItem->pszText == LPSTR_TEXTCALLBACKA) &&
     3682                  (lpLVItem->mask & LVIF_TEXT))
     3683              {
     3684                dispInfo.item.mask |= LVIF_TEXT;
     3685                ZeroMemory(lpLVItem->pszText,
     3686                           sizeof(CHAR)*lpLVItem->cchTextMax);
     3687                dispInfo.item.pszText = lpLVItem->pszText;
     3688                dispInfo.item.cchTextMax = lpLVItem->cchTextMax;
     3689              }
     3690            }
     3691            else
     3692            {
     3693              if (lpLVItem->mask & LVIF_IMAGE)
     3694              {
     3695                dispInfo.item.mask |= LVIF_IMAGE;
     3696              }
     3697
     3698              if (lpLVItem->mask & LVIF_TEXT)
     3699              {
     3700                dispInfo.item.mask |= LVIF_TEXT;
     3701                ZeroMemory(lpLVItem->pszText,
     3702                           sizeof(CHAR)*lpLVItem->cchTextMax);
     3703                dispInfo.item.pszText = lpLVItem->pszText;
     3704                dispInfo.item.cchTextMax = lpLVItem->cchTextMax;
     3705              }
     3706            }
     3707
     3708            if (dispInfo.item.mask != 0)
     3709            {
     3710              dispInfo.hdr.hwndFrom = hwnd;
     3711              dispInfo.hdr.idFrom = lCtrlId;
     3712              dispInfo.hdr.code = LVN_GETDISPINFOA;
     3713              dispInfo.item.iItem = lpLVItem->iItem;
     3714              dispInfo.item.iSubItem = lpLVItem->iSubItem;
     3715              dispInfo.item.lParam = lpItem->lParam;
     3716              ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo);
     3717            }
     3718
     3719            if (dispInfo.item.mask & LVIF_IMAGE)
     3720            {
     3721              lpLVItem->iImage = dispInfo.item.iImage;
     3722            }
     3723            else if (lpLVItem->mask & LVIF_IMAGE)
     3724            {
     3725              lpLVItem->iImage = lpItem->iImage;
     3726            }
     3727
     3728            if (dispInfo.item.mask & LVIF_PARAM)
     3729            {
     3730                lpLVItem->lParam = dispInfo.item.lParam;
     3731            }
     3732            else if (lpLVItem->mask & LVIF_PARAM)
     3733            {
     3734                lpLVItem->lParam = lpItem->lParam;
     3735            }
     3736
     3737            if (dispInfo.item.mask & LVIF_TEXT)
     3738            {
     3739              if (dispInfo.item.mask & LVIF_DI_SETITEM)
     3740              {
     3741                if (lpSubItem)
     3742                  Str_SetPtrA(&lpSubItem->pszText, dispInfo.item.pszText);
     3743              }
     3744              /* Make sure the source string is valid */
     3745              if (dispInfo.item.pszText == NULL)
     3746                lpLVItem->pszText[0] = '\0';
     3747              else
     3748              {
     3749                strncpy(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
     3750                lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0';
     3751              }
     3752            }
     3753            else if (lpLVItem->mask & LVIF_TEXT)
     3754            {
     3755              if (lpItem->pszText != NULL)
     3756              {
     3757                strncpy(lpLVItem->pszText, lpSubItem->pszText,
     3758                        lpLVItem->cchTextMax);
     3759                lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0';
     3760              }
     3761              else
     3762              {
     3763                ZeroMemory(lpLVItem->pszText, sizeof(char)*
     3764                           lpLVItem->cchTextMax);
     3765              }
     3766            }
     3767          }
     3768        }
     3769      }
     3770    }
     3771  }
     3772
     3773  return bResult;
    36663774}
    36673775
     
    41404248  lvItem.cchTextMax = DISP_TEXT_SIZE;
    41414249  lvItem.pszText = szDispText;
    4142   if (LISTVIEW_GetItemA(hwnd, &lvItem,TRUE) != FALSE)
     4250  if (LISTVIEW_GetItemA(hwnd, &lvItem) != FALSE)
    41434251  {
    41444252    nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText);
     
    42014309    lvItem.stateMask = uMask;
    42024310    lvItem.mask = LVIF_STATE;
    4203     if (LISTVIEW_GetItemA(hwnd, &lvItem,TRUE) != FALSE)
     4311    if (LISTVIEW_GetItemA(hwnd, &lvItem) != FALSE)
    42044312    {
    42054313      uState = lvItem.state;
     
    42344342      lpLVItem->mask = LVIF_TEXT;
    42354343      lpLVItem->iItem = nItem;
    4236       if (LISTVIEW_GetItemA(hwnd, lpLVItem,FALSE) != FALSE)
     4344      if (LISTVIEW_GetItemA(hwnd, lpLVItem) != FALSE)
    42374345      {
    42384346        nLength = lstrlenA(lpLVItem->pszText);
     
    47894897    HeapFree(GetProcessHeap(),0,lvca.pszText);
    47904898  return lres;
     4899}
     4900
     4901/* LISTVIEW_InsertCompare:  callback routine for comparing pszText members of the LV_ITEMS
     4902   in a LISTVIEW on insert.  Passed to DPA_Sort in LISTVIEW_InsertItem.
     4903   This function should only be used for inserting items into a sorted list (LVM_INSERTITEM)
     4904   and not during the processing of a LVM_SORTITEMS message. Applications should provide
     4905   their own sort proc. when sending LVM_SORTITEMS.
     4906*/
     4907/* Platform SDK:
     4908    (remarks on LVITEM: LVM_INSERTITEM will insert the new item in the proper sort postion...
     4909        if:
     4910          LVS_SORTXXX must be specified,
     4911          LVS_OWNERDRAW is not set,
     4912          <item>.pszText is not LPSTR_TEXTCALLBACK.
     4913
     4914    (LVS_SORT* flags): "For the LVS_SORTASCENDING... styles, item indices
     4915    are sorted based on item text..."
     4916*/
     4917static INT WINAPI LISTVIEW_InsertCompare(  LPVOID first, LPVOID second,  LPARAM lParam)
     4918{
     4919  HDPA  hdpa_first = (HDPA) first;
     4920  HDPA  hdpa_second = (HDPA) second;
     4921  LISTVIEW_ITEM* lv_first = (LISTVIEW_ITEM*) DPA_GetPtr( hdpa_first, 0 );
     4922  LISTVIEW_ITEM* lv_second = (LISTVIEW_ITEM*) DPA_GetPtr( hdpa_second, 0 );
     4923  LONG lStyle = GetWindowLongA((HWND) lParam, GWL_STYLE);
     4924  INT  cmpv = lstrcmpA( lv_first->pszText, lv_second->pszText );
     4925  /* if we're sorting descending, negate the return value */
     4926  return (lStyle & LVS_SORTDESCENDING) ? -cmpv : cmpv;
    47914927}
    47924928
     
    48354971            if (nItem != -1)
    48364972            {
    4837               nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem,
     4973              if ( ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
     4974                      && !(lStyle & LVS_OWNERDRAWFIXED)
     4975                      && (LPSTR_TEXTCALLBACKA != lpLVItem->pszText) )
     4976              {
     4977                /* Insert the item in the proper sort order based on the pszText
     4978                  member. See comments for LISTVIEW_InsertCompare() for greater detail */
     4979                  nItem = DPA_InsertPtr( infoPtr->hdpaItems,
     4980                          GETITEMCOUNT( infoPtr ) + 1, hdpaSubItems );
     4981                  DPA_Sort( infoPtr->hdpaItems, LISTVIEW_InsertCompare, hwnd );
     4982                  nItem = DPA_GetPtrIndex( infoPtr->hdpaItems, hdpaSubItems );
     4983              }
     4984              else
     4985              {
     4986                nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem,
    48384987                                    hdpaSubItems);
     4988              }
     4989
    48394990              if (nItem != -1)
    48404991              {
     
    55855736{
    55865737  /* Forward the call to the client defined callback */
     5738  INT rv;
    55875739  HWND hwnd = (HWND)lParam;
    55885740  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    55895741
    5590   return (infoPtr->pfnCompare)(
    5591     ((LISTVIEW_ITEM *)first)->lParam,
    5592     ((LISTVIEW_ITEM *)second)->lParam,
    5593     infoPtr->lParamSort);
     5742  rv = (infoPtr->pfnCompare)( ((LISTVIEW_ITEM*) first)->lParam,
     5743          ((LISTVIEW_ITEM*) second)->lParam, infoPtr->lParamSort );
     5744
     5745  return rv;
    55945746}
    55955747
     
    57475899  infoPtr->hwndEdit = 0;
    57485900  infoPtr->pedititem = NULL;
     5901  infoPtr->bDoEditLabel = FALSE;
    57495902
    57505903  /* get default font (icon title) */
     
    59246077    case SB_THUMBTRACK:
    59256078        scrollInfo.nPos = nCurrentPos;
     6079        if (scrollInfo.nPos > scrollInfo.nMax)
     6080            scrollInfo.nPos=scrollInfo.nMax;
     6081
     6082        if (scrollInfo.nPos < scrollInfo.nMin)
     6083            scrollInfo.nPos=scrollInfo.nMin;
     6084
    59266085      break;
    59276086    }
     
    60116170    case SB_THUMBTRACK:
    60126171        scrollInfo.nPos = nCurrentPos;
     6172
     6173        if (scrollInfo.nPos > scrollInfo.nMax)
     6174            scrollInfo.nPos=scrollInfo.nMax;
     6175
     6176        if (scrollInfo.nPos < scrollInfo.nMin)
     6177            scrollInfo.nPos=scrollInfo.nMin;
     6178
    60136179      break;
    60146180    }
     
    60306196
    60316197  return 0;
     6198}
     6199
     6200static LRESULT LISTVIEW_MouseWheel(HWND hwnd, INT wheelDelta)
     6201{
     6202    INT gcWheelDelta = 0;
     6203    UINT pulScrollLines = 3;
     6204    SCROLLINFO scrollInfo;
     6205
     6206    UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
     6207
     6208    SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
     6209    gcWheelDelta -= wheelDelta;
     6210
     6211    ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));
     6212    scrollInfo.cbSize = sizeof(SCROLLINFO);
     6213    scrollInfo.fMask = SIF_POS | SIF_RANGE;
     6214
     6215    switch(uView)
     6216    {
     6217    case LVS_ICON:
     6218    case LVS_SMALLICON:
     6219       /*
     6220        *  listview should be scrolled by a multiple of 37 dependently on its dimension or its visible item number
     6221        *  should be fixed in the future.
     6222        */
     6223        if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE)
     6224            LISTVIEW_VScroll(hwnd, SB_THUMBPOSITION, scrollInfo.nPos + (gcWheelDelta < 0) ? 37 : -37, 0);
     6225        break;
     6226
     6227    case LVS_REPORT:
     6228        if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines)
     6229        {
     6230            if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE)
     6231            {
     6232                int cLineScroll = min(LISTVIEW_GetCountPerColumn(hwnd), pulScrollLines);
     6233                cLineScroll *= (gcWheelDelta / WHEEL_DELTA);
     6234                LISTVIEW_VScroll(hwnd, SB_THUMBPOSITION, scrollInfo.nPos + cLineScroll, 0);
     6235            }
     6236        }
     6237        break;
     6238
     6239    case LVS_LIST:
     6240        LISTVIEW_HScroll(hwnd, (gcWheelDelta < 0) ? SB_LINELEFT : SB_LINERIGHT, 0, 0);
     6241        break;
     6242    }
     6243    return 0;
    60326244}
    60336245
     
    61846396  LONG nCtrlId = GetWindowLongA(hwnd, GWL_ID);
    61856397  NMHDR nmh;
     6398  LVHITTESTINFO htInfo;
    61866399
    61876400//  TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
     
    61936406  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
    61946407
    6195   /* send LVN_ITEMACTIVATE notification */
    6196   nmh.code = LVN_ITEMACTIVATE;
    6197   ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
     6408  /* To send the LVN_ITEMACTIVATE, it must be on an Item */
     6409  ZeroMemory(&htInfo, sizeof(LVHITTESTINFO));
     6410  htInfo.pt.x = wPosX;
     6411  htInfo.pt.y = wPosY;
     6412  if(LISTVIEW_HitTest(hwnd, &htInfo) != -1)
     6413  {
     6414    /* send LVN_ITEMACTIVATE notification */
     6415    nmh.code = LVN_ITEMACTIVATE;
     6416    ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
     6417  }
    61986418
    61996419  return 0;
     
    62486468    if (lStyle & LVS_SINGLESEL)
    62496469    {
    6250       LISTVIEW_SetSelection(hwnd, nItem);
     6470      if ((ListView_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED)
     6471          && infoPtr->bDoEditLabel != TRUE)
     6472      {
     6473          infoPtr->bDoEditLabel = TRUE;
     6474      }
     6475      else
     6476      {
     6477        LISTVIEW_SetSelection(hwnd, nItem);
     6478      }
    62516479    }
    62526480    else
     
    62736501      else
    62746502      {
    6275         LISTVIEW_SetSelection(hwnd, nItem);
     6503        if (ListView_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED
     6504            && infoPtr->bDoEditLabel != TRUE)
     6505        {
     6506          infoPtr->bDoEditLabel = TRUE;
     6507        }
     6508        else
     6509        {
     6510          LISTVIEW_SetSelection(hwnd, nItem);
     6511        }
    62766512      }
    62776513    }
     
    63216557    /* set left button flag */
    63226558    infoPtr->bLButtonDown = FALSE;
     6559
     6560    if(infoPtr->bDoEditLabel)
     6561    {
     6562      LVHITTESTINFO htInfo;
     6563      int nItem;
     6564      ZeroMemory(&htInfo, sizeof(LVHITTESTINFO));
     6565      htInfo.pt.x = wPosX;
     6566      htInfo.pt.y = wPosY;
     6567      nItem = LISTVIEW_HitTest(hwnd, &htInfo);
     6568      if(nItem != -1 && htInfo.flags == LVHT_ONITEMLABEL)
     6569      {
     6570        LISTVIEW_EditLabelA(hwnd, nItem);
     6571      }
     6572      infoPtr->bDoEditLabel = FALSE;
     6573    }
    63236574  }
    63246575
     
    66336884  if (infoPtr->bRButtonDown != FALSE)
    66346885  {
     6886    LPARAM lParam;
     6887
    66356888    /* send NM_RClICK notification */
    66366889    ZeroMemory(&nmh, sizeof(NMHDR));
     
    66426895    /* set button flag */
    66436896    infoPtr->bRButtonDown = FALSE;
     6897
     6898    lParam = MAKELPARAM(wPosX, wPosY);
     6899    ClientToScreen(hwnd, (LPPOINT)&lParam);
     6900
     6901    SendMessageA( hwnd, WM_CONTEXTMENU, (WPARAM) hwnd, lParam);
    66446902  }
    66456903
     
    67236981
    67246982  return 0;
     6983}
     6984
     6985/***
     6986 * DESCRIPTION:
     6987 * Message handling for WM_SETREDRAW.
     6988 * For the Listview, it invalidates the entire window (the doc specifies otherwise)
     6989 *
     6990 * PARAMETER(S):
     6991 * [I] HWND   : window handle
     6992 * [I] bRedraw: state of redraw flag
     6993 *
     6994 * RETURN:
     6995 * DefWinProc return value
     6996 */
     6997static LRESULT LISTVIEW_SetRedraw(HWND hwnd, BOOL bRedraw)
     6998{
     6999    LRESULT lResult;
     7000    lResult = DefWindowProcA(hwnd, WM_SETREDRAW, bRedraw, 0);
     7001    if(bRedraw)
     7002    {
     7003        RedrawWindow(hwnd, NULL, 0,
     7004            RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN | RDW_ERASENOW);
     7005    }
     7006    return lResult;
    67257007}
    67267008
     
    70227304
    70237305  case LVM_GETITEMA:
    7024     return LISTVIEW_GetItemA(hwnd, (LPLVITEMA)lParam,FALSE);
     7306    return LISTVIEW_GetItemA(hwnd, (LPLVITEMA)lParam);
    70257307
    70267308/*      case LVM_GETITEMW: */
     
    72577539    return LISTVIEW_SetFont(hwnd, (HFONT)wParam, (WORD)lParam);
    72587540
    7259 /*      case WM_SETREDRAW: */
     7541  case WM_SETREDRAW:
     7542    return LISTVIEW_SetRedraw(hwnd, (BOOL)wParam);
    72607543
    72617544  case WM_SIZE:
     
    72707553    return LISTVIEW_VScroll(hwnd, (INT)LOWORD(wParam),
    72717554                            (INT)HIWORD(wParam), (HWND)lParam);
     7555
     7556  case WM_MOUSEWHEEL:
     7557      if (wParam & (MK_SHIFT | MK_CONTROL))
     7558          return DefWindowProcA( hwnd, uMsg, wParam, lParam );
     7559      return LISTVIEW_MouseWheel(hwnd, (short int)HIWORD(wParam));
    72727560
    72737561/*      case WM_WINDOWPOSCHANGED: */
     
    73027590  WNDCLASSA wndClass;
    73037591
    7304 //SvL: Don't check this now
    7305 //  if (!GlobalFindAtomA(WC_LISTVIEWA))
    7306 //  {
    7307     ZeroMemory(&wndClass, sizeof(WNDCLASSA));
    7308     wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
    7309     wndClass.lpfnWndProc = (WNDPROC)LISTVIEW_WindowProc;
    7310     wndClass.cbClsExtra = 0;
    7311     wndClass.cbWndExtra = sizeof(LISTVIEW_INFO *);
    7312     wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
    7313     wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    7314     wndClass.lpszClassName = WC_LISTVIEWA;
    7315     RegisterClassA(&wndClass);
    7316 //  }
     7592  ZeroMemory(&wndClass, sizeof(WNDCLASSA));
     7593  wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
     7594  wndClass.lpfnWndProc = (WNDPROC)LISTVIEW_WindowProc;
     7595  wndClass.cbClsExtra = 0;
     7596  wndClass.cbWndExtra = sizeof(LISTVIEW_INFO *);
     7597  wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
     7598  wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
     7599  wndClass.lpszClassName = WC_LISTVIEWA;
     7600  RegisterClassA(&wndClass);
    73177601}
    73187602
     
    73297613VOID LISTVIEW_Unregister(VOID)
    73307614{
    7331   if (GlobalFindAtomA(WC_LISTVIEWA))
    7332   {
    7333     UnregisterClassA(WC_LISTVIEWA, (HINSTANCE)NULL);
    7334   }
     7615  UnregisterClassA(WC_LISTVIEWA, (HINSTANCE)NULL);
    73357616}
    73367617
     
    73557636            LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    73567637            HDC           hdc      = GetDC(infoPtr->hwndEdit);
     7638            HFONT         hFont, hOldFont = 0;
    73577639            RECT          rect;
    73587640            SIZE          sz;
    7359 
    7360             GetWindowTextA(infoPtr->hwndEdit, buffer, 1024);
     7641            int           len;
     7642
     7643            len = GetWindowTextA(infoPtr->hwndEdit, buffer, 1023);
    73617644            GetWindowRect(infoPtr->hwndEdit, &rect);
     7645
     7646            /* Select font to get the right dimension of the string */
     7647            hFont = SendMessageA(infoPtr->hwndEdit, WM_GETFONT, 0, 0);
     7648            if(hFont != 0)
     7649            {
     7650                hOldFont = SelectObject(hdc, hFont);
     7651            }
     7652
    73627653            if (GetTextExtentPoint32A(hdc, buffer, strlen(buffer), &sz))
    73637654            {
    7364                     SetWindowPos (
    7365                 infoPtr->hwndEdit,
    7366                 HWND_TOP,
    7367                 0,
    7368                 0,
    7369                 sz.cx + 15,
    7370                 rect.bottom - rect.top,
    7371                 SWP_DRAWFRAME|SWP_NOMOVE);
     7655                TEXTMETRICA textMetric;
     7656
     7657                /* Add Extra spacing for the next character */
     7658                GetTextMetricsA(hdc, &textMetric);
     7659                sz.cx += (textMetric.tmMaxCharWidth * 2);
     7660
     7661                SetWindowPos (
     7662                    infoPtr->hwndEdit,
     7663                    HWND_TOP,
     7664                    0,
     7665                    0,
     7666                    sz.cx,
     7667                    rect.bottom - rect.top,
     7668                    SWP_DRAWFRAME|SWP_NOMOVE);
    73727669            }
     7670            if(hFont != 0)
     7671            {
     7672                SelectObject(hdc, hOldFont);
     7673            }
     7674
    73737675            ReleaseDC(hwnd, hdc);
    73747676
     
    73837685}
    73847686
    7385 
    73867687/***
    73877688 * DESCRIPTION:
     
    73957696        WPARAM wParam, LPARAM lParam)
    73967697{
    7397     BOOL cancel = TRUE;
     7698    BOOL cancel = FALSE;
    73987699    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(GetParent(hwnd), 0);
    73997700    EDITLABEL_ITEM *einfo = infoPtr->pedititem;
     7701    static BOOL bIgnoreKillFocus = FALSE;
    74007702
    74017703    switch (uMsg)
     
    74057707
    74067708        case WM_KILLFOCUS:
     7709            if(bIgnoreKillFocus)
     7710            {
     7711                return TRUE;
     7712            }
    74077713            break;
    74087714
     
    74177723
    74187724        case WM_CHAR:
    7419             if (VK_RETURN == (INT)wParam)
     7725            if (VK_ESCAPE == (INT)wParam)
    74207726            {
    7421                 cancel = FALSE;
     7727                cancel = TRUE;
    74227728                break;
    74237729            }
    7424             else if (VK_ESCAPE == (INT)wParam)
     7730            else if (VK_RETURN == (INT)wParam)
    74257731                break;
    74267732
     
    74467752            }
    74477753        }
    7448 
     7754        /* Processing LVN_ENDLABELEDIT message could kill the focus       */
     7755        /* eg. Using a messagebox                                         */
     7756        bIgnoreKillFocus = TRUE;
    74497757        einfo->EditLblCb(GetParent(hwnd), buffer, einfo->param);
    74507758
     
    74537761
    74547762        einfo->EditLblCb = NULL;
     7763        bIgnoreKillFocus = FALSE;
    74557764    }
    74567765
     
    74587767    return TRUE;
    74597768}
    7460 
    74617769
    74627770/***
     
    74737781{
    74747782    HWND hedit;
     7783    SIZE sz;
     7784    HDC hdc;
     7785    HDC hOldFont=0;
     7786    TEXTMETRICA textMetric;
    74757787    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(parent, 0);
     7788
    74767789    if (NULL == (infoPtr->pedititem = COMCTL32_Alloc(sizeof(EDITLABEL_ITEM))))
    74777790        return 0;
    74787791
    74797792    style |= WS_CHILDWINDOW|WS_CLIPSIBLINGS|ES_LEFT|WS_BORDER;
    7480     if (!(hedit = CreateWindowA("Edit", text, style, x, y, width, height,
     7793    hdc = GetDC(parent);
     7794
     7795    /* Select the font to get appropriate metric dimensions */
     7796    if(infoPtr->hFont != 0)
     7797    {
     7798        hOldFont = SelectObject(hdc, infoPtr->hFont);
     7799    }
     7800
     7801    /*Get String Lenght in pixels */
     7802    GetTextExtentPoint32A(hdc, text, strlen(text), &sz);
     7803
     7804    /*Add Extra spacing for the next character */
     7805    GetTextMetricsA(hdc, &textMetric);
     7806    sz.cx += (textMetric.tmMaxCharWidth * 2);
     7807
     7808    if(infoPtr->hFont != 0)
     7809    {
     7810        SelectObject(hdc, hOldFont);
     7811    }
     7812
     7813    ReleaseDC(parent, hdc);
     7814    if (!(hedit = CreateWindowA("Edit", text, style, x, y, sz.cx, height,
    74817815                    parent, 0, hinst, 0)))
    74827816    {
     
    74907824          GWL_WNDPROC, (LONG) EditLblWndProc);
    74917825
     7826    SendMessageA(hedit, WM_SETFONT, infoPtr->hFont, FALSE);
     7827
    74927828    return hedit;
    74937829}
  • trunk/src/comctl32/makefile

    r2712 r2858  
    1 # $Id: makefile,v 1.21 2000-02-09 23:46:53 bird Exp $
     1# $Id: makefile,v 1.22 2000-02-22 17:11:40 cbratschi Exp $
    22#
    33# PD-Win32 API
     
    2424        nativefont.obj pager.obj tab.obj status.obj header.obj updown.obj \
    2525        rebar.obj cache.obj trackbar.obj tooltips.obj toolbar.obj treeview.obj \
    26         propsheet.obj listview.obj draglist.obj ipaddress.obj resource.obj
     26        propsheet.obj listview.obj draglist.obj ipaddress.obj resource.obj \
     27        ccbase.obj
    2728
    2829all: $(TARGET).dll $(TARGET).lib
  • trunk/src/comctl32/toolbar.c

    r2523 r2858  
    1 /* $Id: toolbar.c,v 1.25 2000-01-26 18:04:30 cbratschi Exp $ */
     1/* $Id: toolbar.c,v 1.26 2000-02-22 17:11:40 cbratschi Exp $ */
    22/*
    33 * Toolbar control
     
    2828 */
    2929
    30 /* WINE 991212 level */
     30/*
     31 - Corel 20000212 level
     32 - WINE 991212 level
     33*/
    3134
    3235/* CB: Odin32/WINE bugs
     
    616619    /* the last row.                                                    */
    617620    infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
    618                         nSepRows * SEPARATOR_WIDTH * 2 / 3 +
     621                        nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
    619622                        nSepRows * (infoPtr->nBitmapHeight + 1) +
    620623                        BOTTOM_BORDER;
     
    21972200    RECT parent_rect;
    21982201    HWND parent;
    2199     /* INT32  x, y; */
     2202    INT  x, y;
    22002203    INT  cx, cy;
    22012204    UINT uPosFlags = 0;
    22022205
    2203 //    TRACE (toolbar, "resize forced!\n");
    2204 
     2206    //TRACE (toolbar, "resize forced!\n");
     2207
     2208    x = y = 0;
    22052209    parent = GetParent (hwnd);
    22062210    GetClientRect(parent, &parent_rect);
     
    22252229        cy += GetSystemMetrics(SM_CYEDGE);
    22262230
     2231    if (dwStyle & WS_BORDER)
     2232    {
     2233        x = y = 1;
     2234        cy += GetSystemMetrics(SM_CYEDGE);
     2235        cx += GetSystemMetrics(SM_CYEDGE);
     2236    }
     2237
    22272238    infoPtr->bAutoSize = TRUE;
    2228     SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
     2239    SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
    22292240                    cx, cy, uPosFlags);
    22302241
     
    22902301    INT nIndex;
    22912302    INT nOldIndex = -1;
     2303    BOOL bChecked = FALSE;
    22922304
    22932305    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     
    22992311    if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
    23002312        return FALSE;
     2313
     2314    bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
    23012315
    23022316    if (LOWORD(lParam) == FALSE)
     
    23142328    }
    23152329
    2316     hdc = GetDC (hwnd);
    2317     if (nOldIndex != -1)
    2318         TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
    2319     TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2320     ReleaseDC (hwnd, hdc);
     2330    if( bChecked != LOWORD(lParam) )
     2331    {
     2332      hdc = GetDC (hwnd);
     2333      if (nOldIndex != -1)
     2334          TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
     2335     TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2336      ReleaseDC (hwnd, hdc);
     2337    }
    23212338
    23222339    /* FIXME: Send a WM_NOTIFY?? */
     
    24392456    HDC hdc;
    24402457    INT nIndex;
     2458    BOOL bEnabled = FALSE;
    24412459
    24422460    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     
    24452463
    24462464    btnPtr = &infoPtr->buttons[nIndex];
     2465    bEnabled = (btnPtr->fsState & TBSTATE_ENABLED )? TRUE : FALSE ;
     2466
    24472467    if (LOWORD(lParam) == FALSE)
    24482468        btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
     
    24502470        btnPtr->fsState |= TBSTATE_ENABLED;
    24512471
    2452     hdc = GetDC (hwnd);
    2453     TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
    2454     ReleaseDC (hwnd, hdc);
     2472    if( bEnabled !=  LOWORD(lParam) )
     2473    {
     2474      hdc = GetDC (hwnd);
     2475      TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
     2476      ReleaseDC (hwnd, hdc);
     2477    }
    24552478
    24562479    return TRUE;
     
    32303253    if (((INT)LOWORD(lParam) <= 0) || ((INT)HIWORD(lParam) <= 0)) return FALSE;
    32313254
     3255    /* Bitmap size can only be set before adding any button to the toolbar
     3256       according to the documentation.  */
     3257    if( infoPtr->nNumButtons != 0 )
     3258        return FALSE;
     3259
    32323260    infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
    32333261    infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
     
    33393367    if (((INT)LOWORD(lParam) <= 0) || ((INT)HIWORD(lParam) <= 0)) return FALSE;
    33403368
     3369    /* Button size can only be set before adding any button to the toolbar
     3370       according to the documentation.  */
     3371    if( infoPtr->nNumButtons != 0 )
     3372        return FALSE;
     3373
    33413374    infoPtr->nButtonWidth = (INT)LOWORD(lParam);
    33423375    infoPtr->nButtonHeight = (INT)HIWORD(lParam);
     
    36703703    /* initialize info structure */
    36713704    infoPtr->nButtonHeight = 22;
    3672     infoPtr->nButtonWidth = 23;
     3705    infoPtr->nButtonWidth = 24;
    36733706    infoPtr->nBitmapHeight = 15;
    36743707    infoPtr->nBitmapWidth = 16;
     
    41014134        GetWindowRect (hwnd, &rcWindow);
    41024135        OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
     4136        if( dwStyle & WS_BORDER )
     4137            OffsetRect (&rcWindow, 1, 1);
    41034138        DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
    41044139    }
     
    41624197    RECT parent_rect;
    41634198    HWND parent;
    4164     INT  x,y,cx,cy;
     4199    INT  x = 0,y = 0,cx,cy;
    41654200    INT  flags;
    41664201    UINT uPosFlags = 0;
     
    42134248            cy += GetSystemMetrics(SM_CYEDGE);
    42144249
    4215         SetWindowPos (hwnd, 0, x, y,
     4250        if (dwStyle & WS_BORDER)
     4251        {
     4252            x = y = 1;
     4253            cy += GetSystemMetrics(SM_CYEDGE);
     4254            cx += GetSystemMetrics(SM_CYEDGE);
     4255        }
     4256
     4257        SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
    42164258                        cx, cy, uPosFlags | SWP_NOZORDER);
    42174259    }
     
    45874629{
    45884630    WNDCLASSA wndClass;
    4589 
    4590 //SvL: Don't check this now
    4591 //    if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
    45924631
    45934632    ZeroMemory (&wndClass, sizeof(WNDCLASSA));
     
    46074646TOOLBAR_Unregister (VOID)
    46084647{
    4609     if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
    4610         UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
    4611 }
    4612 
     4648    UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);
     4649}
     4650
  • trunk/src/comctl32/treeview.c

    r2835 r2858  
    1 /* $Id: treeview.c,v 1.29 2000-02-20 18:29:58 cbratschi Exp $ */
     1/* $Id: treeview.c,v 1.30 2000-02-22 17:11:41 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    4747#include "commctrl.h"
    4848#include "comctl32.h"
     49#include "ccbase.h"
    4950#include "treeview.h"
    5051
     
    20022003  INT            cChildren;
    20032004  HTREEITEM      hti;
    2004   BOOL root;
     2005  BOOL root = FALSE;
    20052006
    20062007  /* Obtain the TVSORTBC struct */
     
    26902691
    26912692  /* allocate memory for info structure */
    2692   infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO));
    2693 
    2694   SetWindowLongA( hwnd, 0, (DWORD)infoPtr);
     2693  infoPtr = (TREEVIEW_INFO*)initControl(hwnd,sizeof(TREEVIEW_INFO));
    26952694
    26962695  if (infoPtr == NULL) return 0;
    2697 
    2698   if ((TREEVIEW_INFO*)GetWindowLongA(hwnd,0) != infoPtr) return 0;
    26992696
    27002697  hdc = GetDC(hwnd);
     
    27022699  /* set default settings */
    27032700  infoPtr->uInternalStatus = TV_CALCALL;
    2704   if (IsWindowUnicode(hwnd)) infoPtr->uInternalStatus |= TV_UNICODE;
    27052701  infoPtr->uNumItems = 0;
    27062702  infoPtr->clrBk   = GetSysColor (COLOR_WINDOW);
     
    28092805   DeleteObject(infoPtr->hBoldFont);
    28102806   COMCTL32_Free(infoPtr->pszISearch);
    2811    COMCTL32_Free (infoPtr);
     2807   doneControl(hwnd);
    28122808
    28132809   return 0;
     
    29062902  TREEVIEW_ITEM  *wineItem;
    29072903  HWND parent = GetParent(hwnd);
    2908   BOOL unicode = IsWindowUnicode(parent),rc;
    29092904  CHAR *oldText = NULL,*newText = NULL;
     2905  BOOL rc;
    29102906
    29112907  ZeroMemory(&nmhdr,sizeof(NMTREEVIEWW));
     
    29232919    nmhdr.itemOld.stateMask = wineItem->stateMask;
    29242920    nmhdr.itemOld.iImage    = wineItem->iImage;
    2925     if (!unicode)
     2921    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
    29262922    {
    29272923      if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else
     
    29492945    nmhdr.itemNew.stateMask = wineItem->stateMask;
    29502946    nmhdr.itemNew.iImage    = wineItem->iImage;
    2951     if (!unicode)
     2947    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
    29522948    {
    29532949      if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else
     
    29702966  nmhdr.ptDrag.y = 0;
    29712967
    2972   if (unicode)
    2973     rc = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)GetWindowLongW(hwnd,GWL_ID),(LPARAM)&nmhdr);
    2974   else
    2975     rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)GetWindowLongA(hwnd,GWL_ID),(LPARAM)&nmhdr);
     2968  rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
    29762969
    29772970  if (oldText) COMCTL32_Free(oldText);
     
    30103003TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, UINT code, UINT what)
    30113004{
     3005  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    30123006  NMTVDISPINFOW tvdi;
    30133007  BOOL retval;
    30143008  WCHAR *buf;
    30153009  HWND parent = GetParent(hwnd);
    3016   BOOL unicode = IsWindowUnicode(parent);
    30173010
    30183011  tvdi.hdr.hwndFrom     = hwnd;
     
    30233016  tvdi.item.state       = wineItem->state;
    30243017  tvdi.item.lParam      = wineItem->lParam;
    3025   tvdi.item.pszText     = COMCTL32_Alloc(128*(unicode? sizeof(WCHAR):sizeof(char)));
     3018  tvdi.item.pszText     = COMCTL32_Alloc(128*((infoPtr->header.uNotifyFormat == NFR_UNICODE) ? sizeof(WCHAR):sizeof(char)));
    30263019  tvdi.item.cchTextMax = 128;
    30273020  buf = tvdi.item.pszText;
    30283021
    3029   if (unicode)
    3030     retval = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    3031   else
    3032     retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
     3022  retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    30333023
    30343024  /* Ignore posible changes */
     
    30383028  if (what & TVIF_TEXT)
    30393029  {
    3040     if (unicode)
     3030    if (infoPtr->header.uNotifyFormat == NFR_UNICODE)
    30413031    {
    30423032      wineItem->pszText = tvdi.item.pszText;
     
    30693059
    30703060  if (what & TVIF_SELECTEDIMAGE)
    3071                 wineItem->iSelectedImage = tvdi.item.iSelectedImage;
     3061    wineItem->iSelectedImage = tvdi.item.iSelectedImage;
    30723062  if (what & TVIF_IMAGE)
    3073                 wineItem->iImage         = tvdi.item.iImage;
     3063    wineItem->iImage         = tvdi.item.iImage;
    30743064  if (what & TVIF_CHILDREN)
    3075                 wineItem->cChildren      = tvdi.item.cChildren;
    3076 
    3077  return retval;
     3065    wineItem->cChildren      = tvdi.item.cChildren;
     3066
     3067  return retval;
    30783068}
    30793069
     
    30863076  LPNMCUSTOMDRAW nmcd;
    30873077
    3088   nmcd= & nmcdhdr.nmcd;
     3078  nmcd =& nmcdhdr.nmcd;
    30893079  nmcd->hdr.hwndFrom = hwnd;
    30903080  nmcd->hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
     
    34523442  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    34533443  HWND parent = GetParent(hwnd);
    3454   BOOL unicode = IsWindowUnicode(parent);
    34553444  BOOL bCommit;
    34563445  WCHAR *textW = NULL;
     
    34793468    //}
    34803469
    3481     if (unicode) tvdi.item.pszText = textW; else
     3470    if (infoPtr->header.uNotifyFormat == NFR_UNICODE) tvdi.item.pszText = textW; else
    34823471    {
    34833472      INT len = iLength+1;
     
    34953484  }
    34963485
    3497   if (unicode)
    3498     bCommit=(BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    3499   else
    3500     bCommit=(BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
     3486  bCommit = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    35013487
    35023488  if (!bCancel && bCommit) /* Apply the changes */
    35033489  {
    3504     if (!unicode)
     3490    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
    35053491      lstrcpynAtoW(textW,textA,iLength+1);
    35063492    if (lstrcmpW(textW,editedItem->pszText) != 0)
     
    36463632        NMTVGETINFOTIPW tvgit;
    36473633        HWND parent = GetParent(hwnd);
    3648         BOOL unicode = IsWindowUnicode(parent);
    36493634
    36503635        tvgit.hdr.hwndFrom = hwnd;
    36513636        tvgit.hdr.idFrom   =  GetWindowLongA(hwnd,GWL_ID);
    3652         tvgit.hdr.code     = unicode ? TVN_GETINFOTIPW:TVN_GETINFOTIPA;
    3653         tvgit.pszText    = COMCTL32_Alloc(unicode ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));
     3637        tvgit.hdr.code     = (infoPtr->header.uNotifyFormat == NFR_UNICODE) ? TVN_GETINFOTIPW:TVN_GETINFOTIPA;
     3638        tvgit.pszText    = COMCTL32_Alloc((infoPtr->header.uNotifyFormat == NFR_UNICODE) ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));
    36543639        tvgit.cchTextMax = INFOTIPSIZE;
    36553640        tvgit.hItem      = item->hItem;
    36563641        tvgit.lParam     = item->lParam;
    36573642
    3658         if (unicode)
     3643        SendMessageA(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);
     3644        if (infoPtr->header.uNotifyFormat == NFR_UNICODE)
    36593645        {
    3660           SendMessageW(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);
    36613646          text = tvgit.pszText;
    36623647        } else
    36633648        {
    3664           SendMessageA(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);
    36653649          text = COMCTL32_Alloc(tvgit.cchTextMax*sizeof(WCHAR));
    36663650          lstrcpyAtoW(text,(LPSTR)tvgit.pszText);
     
    45984582}
    45994583
    4600 static LRESULT TREEVIEW_GetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)
    4601 {
    4602   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    4603 
    4604   return infoPtr->uInternalStatus & TV_UNICODE;
    4605 }
    4606 
    4607 static LRESULT TREEVIEW_SetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)
    4608 {
    4609   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    4610   BOOL oldFormat = infoPtr->uInternalStatus & TV_UNICODE;
    4611 
    4612   if (wParam)
    4613     infoPtr->uInternalStatus |= TV_UNICODE;
    4614   else
    4615     infoPtr->uInternalStatus &= ~TV_UNICODE;
    4616 
    4617   return oldFormat;
    4618 }
    4619 
    46204584static LRESULT WINAPI
    46214585TREEVIEW_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     
    47604724        case TVM_GETINSERTMARKCOLOR:
    47614725                return TREEVIEW_GetInsertMarkColor (hwnd,wParam, lParam);
    4762 
    4763         case TVM_GETUNICODEFORMAT:
    4764                 return TREEVIEW_GetUnicodeFormat(hwnd,wParam,lParam);
    4765 
    4766         case TVM_SETUNICODEFORMAT:
    4767                 return TREEVIEW_SetUnicodeFormat(hwnd,wParam,lParam);
    47684726
    47694727        case WM_COMMAND:
     
    48534811              //  FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n",
    48544812              //     uMsg, wParam, lParam);
    4855             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     4813            return defComCtl32ProcA(hwnd,uMsg,wParam,lParam);
    48564814      }
    48574815    return 0;
Note: See TracChangeset for help on using the changeset viewer.