Changeset 2806 for trunk/src


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

treeview: finished soon

Location:
trunk/src/comctl32
Files:
3 edited

Legend:

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

    r2523 r2806  
    1 /* $Id: progress.c,v 1.12 2000-01-26 18:04:29 cbratschi Exp $ */
     1/* $Id: progress.c,v 1.13 2000-02-16 17:22:18 cbratschi Exp $ */
    22/*
    33 * Progress control
     
    2323#define BORDER_WIDTH 1
    2424
    25 /* Work constants */
    26 
    27 //#define UNKNOWN_PARAM(msg, wParam, lParam) WARN(progress, \
    28 //        "Unknown parameter(s) for message " #msg     \
    29 //      "(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam);
    30 //#define UNKNOWN_PARAM(msg, wParam, lParam)
    31 
    3225#define PROGRESS_GetInfoPtr(hwnd) ((PROGRESS_INFO *)GetWindowLongA(hwnd,0))
    3326
  • trunk/src/comctl32/tooltips.c

    r2635 r2806  
    1 /* $Id: tooltips.c,v 1.20 2000-02-04 17:02:09 cbratschi Exp $ */
     1/* $Id: tooltips.c,v 1.21 2000-02-16 17:22:18 cbratschi Exp $ */
    22/*
    33 * Tool tip control
     
    8585    {
    8686      /* load a resource */
    87 //    TRACE (tooltips,"load res string %x %x\n",toolPtr->hinst,(int)toolPtr->lpszText);
     87
    8888      LoadStringW(toolPtr->hinst,(UINT)toolPtr->lpszText,infoPtr->szTipText,INFOTIPSIZE);
    8989    } else if (toolPtr->lpszText)
     
    101101        ttnmdi.uFlags = toolPtr->uFlags;
    102102        ttnmdi.lParam = toolPtr->lParam;
    103         //          TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
    104103        SendMessageA (toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&ttnmdi);
    105104
     
    138137        } else
    139138        {
    140 //        ERR (tooltips, "recursive text callback!\n");
     139          //ERR (tooltips, "recursive text callback!\n");
    141140          infoPtr->szTipText[0] = '\0';
    142141        }
  • trunk/src/comctl32/treeview.c

    r2782 r2806  
    1 /* $Id: treeview.c,v 1.25 2000-02-14 17:31:40 cbratschi Exp $ */
     1/* $Id: treeview.c,v 1.26 2000-02-16 17:22:19 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    1111 * TODO:
    1212 *   Using DPA to store the item ptr would be good.
    13  *   Node label edition is implemented but something appened in wine in the
    14  *   two last weeks of march 99 that broke it.
    15  *   refreshtreeview:
    16                 -small array containing info about positions.
    17                 -better implementation of RefreshItem:
    18               1) draw lines between parents
    19               2) draw items
    20                           3) draw lines from parent<->items.
    21                 -implement partial drawing?
    22  *  -drag&drop: TVM_CREATEDRAGIMAGE should create drag bitmap.
    23  *  -scrollbars: horizontal scrollbar doesn't work.
    24  *  -Unicode messages
    2513 *  -check custom draw
    26  *  -I_CHILDRENCALLBACK
    2714 *   FIXME: check fontsize. (uRealItemHeight)
    28  *          test focusItem  (redraw in different color)
    2915                        uHotItem
    30                         Edit: needs timer
    31                                   better implementation.
    32  *   WM_HSCROLL is broken.
    3316 *   use separate routine to get item text/image.
    34  *
    35  *   Separate drawing/calculation.
    3617 *
    3718 * FIXMEs  (for personal use)
     
    3920   -DblClick:   ctlmacro.exe's NM_DBLCLK seems to go wrong (returns FALSE).
    4021   -treehelper: stack corruption makes big window.
    41 
     22 *
     23 * Status: in progress
     24 * Version: 5.00
    4225 */
    4326
     
    5033/* CB: todo
    5134
    52  - WM_LBUTTONDOWN: bug in highlight code
    53  - WM_SIZE: redraw doesn't work
    54  - hscroll not set
    55 
     35 - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems
    5636*/
    5737
     
    8868static void    TREEVIEW_Refresh(HWND hwnd);
    8969static void    TREEVIEW_Draw(HWND hwnd,HDC hdc,RECT *updateRect);
    90 static void    TREEVIEW_UnqueueRefresh(HWND hwnd,BOOL calc,BOOL refresh);
     70static BOOL    TREEVIEW_UnqueueRefresh(HWND hwnd,BOOL calc,BOOL refresh);
    9171static void    TREEVIEW_QueueRefresh(HWND hwnd);
     72static void    TREEVIEW_CalcItem(HWND hwnd,HDC hdc,DWORD dwStyle,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *item);
     73static BOOL    TREEVIEW_CalcItems(HWND hwnd,HDC hdc,TREEVIEW_INFO *infoPtr);
     74static LRESULT TREEVIEW_EnsureVisible(HWND hwnd,HTREEITEM hItem);
    9275
    9376static LRESULT CALLBACK TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
     
    9578LRESULT WINAPI TREEVIEW_EndEditLabelNow (HWND hwnd, BOOL bCancel);
    9679
    97 HWND TREEVIEW_EditLabelA(HWND hwnd, HTREEITEM hItem);
     80HWND TREEVIEW_EditLabel(HWND hwnd, HTREEITEM hItem,BOOL unicode);
    9881
    9982/* helper functions. Work with the assumption that validity of operands
     
    335318    infoPtr->uNumItems--;
    336319    killItem=& infoPtr->items[kill];
    337     if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
     320    if (killItem->pszText != LPSTR_TEXTCALLBACKW)
    338321      COMCTL32_Free (killItem->pszText);
    339322    TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)kill, 0);
     
    355338 INT iItem;
    356339
     340 if (infoPtr->hwndEdit) SetFocus(hwnd);
     341
    357342 iItem=(INT)wineItem->hItem;
    358343 tv_set_bit(iItem,infoPtr->freeList);
    359344 infoPtr->uNumItems--;
    360345 parentItem=NULL;
    361  if (wineItem->pszText!=LPSTR_TEXTCALLBACKA)
    362         COMCTL32_Free (wineItem->pszText);
     346 if (wineItem->pszText != LPSTR_TEXTCALLBACKW)
     347   COMCTL32_Free (wineItem->pszText);
    363348
    364349 TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)iItem, 0);
    365350
    366351 if (wineItem->firstChild)
    367         TREEVIEW_RemoveAllChildren (hwnd,wineItem);
     352   TREEVIEW_RemoveAllChildren (hwnd,wineItem);
    368353
    369354 if (wineItem->parent) {
     
    392377}
    393378
    394 
    395 
    396 
    397 
    398379/* Note:TREEVIEW_RemoveTree doesn't remove infoPtr itself */
    399380
    400381static void TREEVIEW_RemoveTree (HWND hwnd)
    401 
    402 {
    403  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    404  TREEVIEW_ITEM *killItem;
    405  int i;
    406 
    407  for (i=1; i<=(INT)infoPtr->uMaxHandle; i++)
     382{
     383  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     384  TREEVIEW_ITEM *killItem;
     385  int i;
     386
     387  TREEVIEW_EndEditLabelNow(hwnd,TRUE);
     388
     389  for (i=1; i<=(INT)infoPtr->uMaxHandle; i++)
    408390        if (!tv_test_bit (i, infoPtr->freeList)) {
    409391                killItem=& infoPtr->items [i];
    410                 if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
    411                         COMCTL32_Free (killItem->pszText);
     392                if (killItem->pszText != LPSTR_TEXTCALLBACKW)
     393                  COMCTL32_Free (killItem->pszText);
    412394                TREEVIEW_SendTreeviewNotify
    413395                                        (hwnd, TVN_DELETEITEM, 0, killItem->hItem, 0);
    414396                }
    415397
    416  if (infoPtr->uNumPtrsAlloced) {
     398  if (infoPtr->uNumPtrsAlloced) {
    417399        COMCTL32_Free (infoPtr->items);
    418400        COMCTL32_Free (infoPtr->freeList);
     
    420402        infoPtr->uNumPtrsAlloced=0;
    421403        infoPtr->uMaxHandle=0;
     404        infoPtr->cx = infoPtr->cy = 0;
    422405    }
    423406}
     
    443426    HIMAGELIST himlTemp;
    444427
    445     //TRACE (treeview,"\n");
    446428    switch ((INT)wParam) {
    447429        case TVSIL_NORMAL:
     
    622604#endif
    623605
    624 //CB: pen must be selected!
     606//pen must be selected!
    625607
    626608static void TREEVIEW_DrawVLines(HDC hdc,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *wineItem)
     
    656638                   wineItem->rect.bottom-3:  /* is linked to an icon       */
    657639                   wineItem->rect.bottom+1;  /* is linked to a +/- box     */
    658     points[1].x = points[0].x = 28 + (20*wineItem->iLevel);
     640    points[1].x = points[0].x = 28+20*wineItem->iLevel-infoPtr->cx;
    659641    points[1].y = (lastItem->rect.top+lastItem->rect.bottom)/2;  /* is linked to a +/- box     */
    660642#ifdef OS2LINEHACK
     
    667649
    668650static void
    669 TREEVIEW_DrawItem (HWND hwnd, HDC hdc, TREEVIEW_ITEM *wineItem)
    670 {
    671   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    672   DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     651TREEVIEW_DrawItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *wineItem,DWORD dwStyle,TREEVIEW_INFO *infoPtr)
     652{
    673653  INT   center,xpos,cx,cy, cditem;
    674654  HFONT hOldFont;
    675655  UINT  uTextJustify = DT_LEFT;
    676656  RECT  r;
     657
     658  if (!wineItem->calculated) TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,wineItem);
    677659
    678660  if (wineItem->state & TVIS_BOLD)
     
    742724      } else
    743725      {
    744         points[1].x = 8 + (20*wineItem->iLevel);
     726        points[1].x = 8+(20*wineItem->iLevel)-infoPtr->cx;
    745727        points[1].y = points[0].y = center;
    746728        points[0].x = points[1].x + 10;
     
    764746   */
    765747  if (wineItem->iLevel != 0)/*  update position only for non root node */
    766     xpos+=(5*wineItem->iLevel);
    767 
    768   if (( dwStyle & TVS_HASBUTTONS) && ( dwStyle & TVS_HASLINES))
     748    xpos += 5*wineItem->iLevel;
     749
     750  if ((dwStyle & TVS_HASBUTTONS) && (dwStyle & TVS_HASLINES))
    769751  {
    770752    if (TREEVIEW_HasChildren(hwnd, wineItem))
    771753    {
    772       /* Setup expand box coordinate to facilitate the LMBClick handling */
    773       wineItem->expandBox.left   = xpos-4;
    774       wineItem->expandBox.top    = center-4;
    775       wineItem->expandBox.right  = xpos+5;
    776       wineItem->expandBox.bottom = center+5;
    777 
    778754      Rectangle(hdc,wineItem->expandBox.left,wineItem->expandBox.top,wineItem->expandBox.right,wineItem->expandBox.bottom);
    779755
     
    804780    if (infoPtr->himlState)
    805781      himlp=&infoPtr->himlState;
    806     imageIndex=wineItem->state>>12;
     782    imageIndex=wineItem->state >> 12;
    807783
    808784    if ((himlp) && (imageIndex))
     
    810786      imageIndex--;       /* see FIXME */
    811787      ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL);
    812       ImageList_GetIconSize (*himlp, &cx, &cy);
    813       wineItem->statebitmap.left=xpos-2;
    814       wineItem->statebitmap.right=xpos-2+cx;
    815       wineItem->statebitmap.top=r.top+1;
    816       wineItem->statebitmap.bottom=r.top+1+cy;
    817       xpos += cx;
     788      xpos += wineItem->statebitmap.right-wineItem->statebitmap.left;
    818789    }
    819790
     
    850821
    851822      if(wineItem->stateMask & TVIS_OVERLAYMASK)
    852       ovlIdx = wineItem->state & TVIS_OVERLAYMASK;
     823        ovlIdx = wineItem->state & TVIS_OVERLAYMASK;
    853824
    854825      ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL|ovlIdx);
    855       ImageList_GetIconSize (*himlp, &cx, &cy);
    856       wineItem->bitmap.left=xpos-2;
    857       wineItem->bitmap.right=xpos-2+cx;
    858       wineItem->bitmap.top=r.top+1;
    859       wineItem->bitmap.bottom=r.top+1+cy;
    860       xpos += cx;
     826      xpos += wineItem->bitmap.right-wineItem->bitmap.left;
    861827    }
    862828  }
     
    878844      r.left += 3;
    879845      r.right -= 3;
    880 
    881       wineItem->text.left  = r.left;
    882       wineItem->text.right = r.right;
    883       wineItem->text.top   = r.top;
    884       wineItem->text.bottom= r.bottom;
    885 
    886846      oldBkMode = SetBkMode(hdc, TRANSPARENT);
    887847
     
    919879      }
    920880
    921       if (wineItem->pszText== LPSTR_TEXTCALLBACKA) {
    922         //TRACE("LPSTR_TEXTCALLBACK\n");
     881      if (wineItem->pszText == LPSTR_TEXTCALLBACKW)
    923882        TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT);
    924       }
    925 
    926       /* Obtain the text coordinate */
    927      DrawTextA (
    928             hdc,
    929             wineItem->pszText,
    930             lstrlenA(wineItem->pszText),
    931             &wineItem->text,
    932             uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT | DT_NOPREFIX);
    933 
    934       /* We need to reset it to items height */
    935       wineItem->text.top = r.top;
    936       wineItem->text.bottom = r.bottom;
    937       wineItem->text.right += 4; /* This is extra for focus rectangle */
    938883
    939884      if (hbrBk)
     
    946891
    947892      /* Draw it */
    948       DrawTextA ( hdc,
     893      DrawTextW ( hdc,
    949894        wineItem->pszText,
    950         lstrlenA(wineItem->pszText),
     895        lstrlenW(wineItem->pszText),
    951896        &wineItem->text,
    952         uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX | DT_END_ELLIPSIS);
    953 
    954        wineItem->text.left -=2;
     897        uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
     898
     899       wineItem->text.left -= 2;
    955900
    956901      /* Restore the hdc state */
     
    1035980  LPRECT        lpRect   = (LPRECT)lParam;
    1036981
    1037 //  TRACE (treeview,"\n");
    1038982  /*
    1039983   * validate parameters
     
    1049993  iItem = (HTREEITEM *) lParam;
    1050994  wineItem = TREEVIEW_ValidItem (infoPtr, *iItem);
    1051   if ((!wineItem) || (!wineItem->visible))
     995  if (!wineItem || !wineItem->visible)
    1052996    return FALSE;
    1053997
     
    10561000   * the whole item size
    10571001   */
    1058   if ((INT) wParam) {
    1059         lpRect->left      = wineItem->text.left;
    1060     lpRect->right         = wineItem->text.right;
    1061     lpRect->bottom      = wineItem->text.bottom;
    1062     lpRect->top     = wineItem->text.top;
    1063   } else {
    1064     lpRect->left          = wineItem->rect.left;
    1065     lpRect->right         = wineItem->rect.right;
    1066     lpRect->bottom  = wineItem->rect.bottom;
    1067     lpRect->top     = wineItem->rect.top;
    1068   }
    1069 
    1070 //  TRACE (treeview,"[L:%d R:%d T:%d B:%d]\n",
    1071 //      lpRect->left,lpRect->right,
    1072 //                      lpRect->top,lpRect->bottom);
     1002  if (wParam)
     1003  {
     1004    lpRect->left   = wineItem->text.left;
     1005    lpRect->right  = wineItem->text.right;
     1006    lpRect->bottom = wineItem->text.bottom;
     1007    lpRect->top    = wineItem->text.top;
     1008  } else
     1009  {
     1010    lpRect->left   = wineItem->rect.left;
     1011    lpRect->right  = wineItem->rect.right;
     1012    lpRect->bottom = wineItem->rect.bottom;
     1013    lpRect->top    = wineItem->rect.top;
     1014  }
    10731015
    10741016  return TRUE;
     
    10811023  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    10821024
    1083   //CB: todo: that's the number of completely visible items
    1084 
    1085   return (LRESULT) infoPtr->uVisibleHeight / infoPtr->uRealItemHeight;
    1086 }
    1087 
    1088 
    1089 
    1090 static LRESULT
    1091 TREEVIEW_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1025  return (LRESULT)infoPtr->uVisibleHeight/infoPtr->uRealItemHeight;
     1026}
     1027
     1028static LRESULT TREEVIEW_SetItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
    10921029{
    10931030  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    10941031  TREEVIEW_ITEM *wineItem;
    1095   TVITEMEXA *tvItem;
     1032  TVITEMEXW *tvItem;
    10961033  INT iItem,len;
    10971034
    1098   tvItem=(LPTVITEMEXA) lParam;
    1099   iItem=(INT)tvItem->hItem;
    1100 //  TRACE (treeview,"item %d,mask %x\n",iItem,tvItem->mask);
     1035  if (infoPtr->hwndEdit) SetFocus(hwnd);
     1036
     1037  tvItem = (LPTVITEMEXW)lParam;
     1038  iItem = (INT)tvItem->hItem;
    11011039
    11021040  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
    11031041  if (!wineItem) return FALSE;
    11041042
    1105   if (tvItem->mask & TVIF_CHILDREN) {
    1106         wineItem->cChildren=tvItem->cChildren;
    1107   }
    1108 
    1109   if (tvItem->mask & TVIF_IMAGE) {
    1110        wineItem->iImage=tvItem->iImage;
    1111   }
    1112 
    1113   if (tvItem->mask & TVIF_INTEGRAL) {
    1114         wineItem->iIntegral=tvItem->iIntegral;
    1115   }
    1116 
    1117   if (tvItem->mask & TVIF_PARAM) {
    1118         wineItem->lParam=tvItem->lParam;
    1119   }
    1120 
    1121   if (tvItem->mask & TVIF_SELECTEDIMAGE) {
    1122         wineItem->iSelectedImage=tvItem->iSelectedImage;
    1123   }
    1124 
    1125   if (tvItem->mask & TVIF_STATE) {
    1126                 //TRACE ("prevstate,state,mask:%x,%x,%x\n",wineItem->state,tvItem->state,
    1127 //tvItem->stateMask);
    1128         wineItem->state&= ~tvItem->stateMask;
    1129                 wineItem->state|= (tvItem->state & tvItem->stateMask);
    1130                 wineItem->stateMask|= tvItem->stateMask;
    1131   }
    1132 
    1133   if (tvItem->mask & TVIF_TEXT) {
    1134                 if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) {
    1135         len=lstrlenA (tvItem->pszText) + 1;
    1136         if (len>wineItem->cchTextMax) {
    1137            wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len);
    1138            wineItem->cchTextMax = len;
     1043  if (tvItem->mask & TVIF_CHILDREN)
     1044    wineItem->cChildren = tvItem->cChildren;
     1045
     1046  if (tvItem->mask & TVIF_IMAGE)
     1047    wineItem->iImage = tvItem->iImage;
     1048
     1049  if (tvItem->mask & TVIF_INTEGRAL)
     1050    wineItem->iIntegral = tvItem->iIntegral;
     1051
     1052  if (tvItem->mask & TVIF_PARAM)
     1053    wineItem->lParam = tvItem->lParam;
     1054
     1055  if (tvItem->mask & TVIF_SELECTEDIMAGE)
     1056    wineItem->iSelectedImage = tvItem->iSelectedImage;
     1057
     1058  if (tvItem->mask & TVIF_STATE)
     1059  {
     1060    wineItem->state &= ~tvItem->stateMask;
     1061    wineItem->state |= (tvItem->state & tvItem->stateMask);
     1062    wineItem->stateMask |= tvItem->stateMask;
     1063  }
     1064
     1065  if (tvItem->mask & TVIF_TEXT)
     1066  {
     1067    if (unicode)
     1068    {
     1069      if (tvItem->pszText != LPSTR_TEXTCALLBACKW)
     1070      {
     1071        len = lstrlenW(tvItem->pszText)+1;
     1072        if (len > wineItem->cchTextMax)
     1073        {
     1074          wineItem->pszText= COMCTL32_ReAlloc(wineItem->pszText,len*sizeof(WCHAR));
     1075          wineItem->cchTextMax = len;
    11391076        }
    1140         lstrcpynA (wineItem->pszText, tvItem->pszText,len);
    1141                 } else {
    1142                         if (wineItem->cchTextMax) {
    1143                                 COMCTL32_Free (wineItem->pszText);
    1144                                 wineItem->cchTextMax=0;
    1145                         }
    1146                 wineItem->pszText=LPSTR_TEXTCALLBACKA;
    1147                 }
     1077        lstrcpynW(wineItem->pszText,tvItem->pszText,len);
     1078      } else
     1079      {
     1080        if (wineItem->cchTextMax)
     1081        {
     1082          COMCTL32_Free (wineItem->pszText);
     1083          wineItem->cchTextMax = 0;
     1084        }
     1085        wineItem->pszText = LPSTR_TEXTCALLBACKW;
     1086      }
     1087    } else
     1088    {
     1089      LPTVITEMEXA tvItem;
     1090
     1091      tvItem = (LPTVITEMEXA)lParam;
     1092
     1093      if (tvItem->pszText != LPSTR_TEXTCALLBACKA)
     1094      {
     1095        len = lstrlenA (tvItem->pszText) + 1;
     1096        if (len > wineItem->cchTextMax)
     1097        {
     1098          wineItem->pszText = COMCTL32_ReAlloc(wineItem->pszText,len*sizeof(WCHAR));
     1099          wineItem->cchTextMax = len;
     1100        }
     1101        lstrcpynAtoW(wineItem->pszText,tvItem->pszText,len);
     1102      } else
     1103      {
     1104        if (wineItem->cchTextMax)
     1105        {
     1106          COMCTL32_Free (wineItem->pszText);
     1107          wineItem->cchTextMax = 0;
     1108        }
     1109        wineItem->pszText = LPSTR_TEXTCALLBACKW;
     1110      }
     1111    }
    11481112  }
    11491113
    11501114  wineItem->mask |= tvItem->mask;
     1115  wineItem->calculated = FALSE;
     1116  TREEVIEW_QueueRefresh(hwnd);
    11511117
    11521118  return TRUE;
     
    11681134static void TREEVIEW_Refresh(HWND hwnd)
    11691135{
     1136  TREEVIEW_UnqueueRefresh(hwnd,TRUE,FALSE);
     1137
    11701138  InvalidateRect(hwnd,NULL,TRUE);
    11711139}
    11721140
    1173 static void TREEVIEW_RefreshItem(HWND hwnd,TREEVIEW_ITEM *item)
     1141static void TREEVIEW_RefreshItem(HWND hwnd,TREEVIEW_ITEM *item,BOOL wholeLine)
    11741142{
    11751143  if (item && item->visible)
     
    11771145    RECT rect = item->rect;
    11781146
    1179     rect.left += TREEVIEW_LEFT_MARGIN;
    1180     if (item->iLevel != 0) rect.left += (5*item->iLevel);
    1181     rect.left += 15;
     1147    if (wholeLine)
     1148    {
     1149      RECT client;
     1150
     1151      GetClientRect(hwnd,&client);
     1152      rect.left = 0;
     1153      rect.right = client.right;
     1154    } else
     1155    {
     1156      rect.left += TREEVIEW_LEFT_MARGIN;
     1157      if (item->iLevel != 0) rect.left += (5*item->iLevel);
     1158      rect.left += 15;
     1159    }
     1160
    11821161    InvalidateRect(hwnd,&rect,TRUE);
    11831162  }
    11841163}
    11851164
    1186 //CB: HDC parameter is optional
    1187 
    1188 static void TREEVIEW_CalcItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *item)
    1189 {
     1165//HDC parameter is optional
     1166
     1167static void TREEVIEW_CalcItem(HWND hwnd,HDC hdc,DWORD dwStyle,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *item)
     1168{
     1169  RECT r;
     1170  INT center,xpos;
     1171  BOOL ownDC = FALSE;
     1172
    11901173  item->calculated = TRUE;
    1191   //CB: todo: move calc code from TREEVIEW_DrawItem
    1192 }
    1193 
    1194 //CB: HDC parameter is optional
    1195 
    1196 static void TREEVIEW_CalcItems(HWND hwnd,HDC hdc,TREEVIEW_INFO *infoPtr)
     1174
     1175  r      = item->rect;               /* this item rectangle */
     1176  center = (r.top+r.bottom)/2;           /* this item vertical center */
     1177  xpos   = r.left + TREEVIEW_LEFT_MARGIN;/* horizontal starting point */
     1178
     1179  if (item->iLevel != 0)/*  update position only for non root node */
     1180    xpos += 5*item->iLevel;
     1181
     1182  if ((dwStyle & TVS_HASBUTTONS) && (dwStyle & TVS_HASLINES))
     1183  {
     1184    if (TREEVIEW_HasChildren(hwnd,item))
     1185    {
     1186      /* Setup expand box coordinate to facilitate the LMBClick handling */
     1187      item->expandBox.left   = xpos-4;
     1188      item->expandBox.top    = center-4;
     1189      item->expandBox.right  = xpos+5;
     1190      item->expandBox.bottom = center+5;
     1191    } else SetRectEmpty(&item->expandBox);
     1192  } else SetRectEmpty(&item->expandBox);
     1193
     1194  xpos += 13; /* update position */
     1195
     1196  if (item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE))
     1197  {
     1198    INT        imageIndex,cx,cy;
     1199    HIMAGELIST *himlp = NULL;
     1200
     1201    /* State images are displayed to the left of the Normal image
     1202     * image number is in state; zero should be `display no image'.
     1203     * FIXME: that last sentence looks like it needs some checking.
     1204     */
     1205    if (infoPtr->himlState)
     1206      himlp = &infoPtr->himlState;
     1207    imageIndex = item->state >> 12;
     1208
     1209    if (himlp && imageIndex)
     1210    {
     1211      if (!hdc)
     1212      {
     1213        ownDC = TRUE;
     1214        hdc = GetDC(hwnd);
     1215      }
     1216
     1217      imageIndex--;       /* see FIXME */
     1218      ImageList_GetIconSize(*himlp,&cx,&cy);
     1219      item->statebitmap.left = xpos-2;
     1220      item->statebitmap.right = xpos-2+cx;
     1221      item->statebitmap.top = r.top+1;
     1222      item->statebitmap.bottom = r.top+1+cy;
     1223      xpos += cx;
     1224    } else SetRectEmpty(&item->statebitmap);
     1225
     1226    /* Now, draw the normal image; can be either selected or
     1227     * non-selected image.
     1228     */
     1229
     1230    himlp = NULL;
     1231    if (infoPtr->himlNormal)
     1232      himlp = &infoPtr->himlNormal; /* get the image list */
     1233
     1234    if (himlp)
     1235    {
     1236      int ovlIdx = 0;
     1237
     1238      if(item->stateMask & TVIS_OVERLAYMASK)
     1239        ovlIdx = item->state & TVIS_OVERLAYMASK;
     1240
     1241      if (!hdc)
     1242      {
     1243        ownDC = TRUE;
     1244        hdc = GetDC(hwnd);
     1245      }
     1246
     1247      ImageList_GetIconSize(*himlp,&cx,&cy);
     1248      item->bitmap.left = xpos-2;
     1249      item->bitmap.right = xpos-2+cx;
     1250      item->bitmap.top = r.top+1;
     1251      item->bitmap.bottom = r.top+1+cy;
     1252      xpos += cx;
     1253    } else SetRectEmpty(&item->bitmap);
     1254  } else
     1255  {
     1256    SetRectEmpty(&item->statebitmap);
     1257    SetRectEmpty(&item->bitmap);
     1258  }
     1259
     1260  r.left = xpos;
     1261  if ((item->mask & TVIF_TEXT) && (item->pszText))
     1262  {
     1263    UINT  uTextJustify = DT_LEFT;
     1264    HFONT hOldFont;
     1265
     1266    r.left += 3;
     1267    r.right -= 3;
     1268
     1269    item->text.left  = r.left;
     1270    item->text.right = r.right;
     1271    item->text.top   = r.top;
     1272    item->text.bottom= r.bottom;
     1273
     1274    if (item->pszText== LPSTR_TEXTCALLBACKW)
     1275    {
     1276      //TRACE("LPSTR_TEXTCALLBACK\n");
     1277      TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT);
     1278    }
     1279
     1280    if (!hdc)
     1281    {
     1282      ownDC = TRUE;
     1283      hdc = GetDC(hwnd);
     1284    }
     1285
     1286    if (item->state & TVIS_BOLD)
     1287      hOldFont = SelectObject (hdc, infoPtr->hBoldFont);
     1288    else
     1289      hOldFont = SelectObject (hdc, infoPtr->hFont);
     1290
     1291    /* Obtain the text coordinate */
     1292    DrawTextW (
     1293            hdc,
     1294            item->pszText,
     1295            lstrlenW(item->pszText),
     1296            &item->text,
     1297            uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT | DT_NOPREFIX);
     1298
     1299    SelectObject(hdc,hOldFont);
     1300
     1301    /* We need to reset it to items height */
     1302    item->text.top = r.top;
     1303    item->text.bottom = r.bottom;
     1304    item->text.right += 4; /* This is extra for focus rectangle */
     1305
     1306    xpos = item->text.right;
     1307  } else SetRectEmpty(&item->text);
     1308
     1309  item->rect.right = xpos;
     1310
     1311  if (ownDC) ReleaseDC(hwnd,hdc);
     1312}
     1313
     1314//HDC parameter is optional
     1315
     1316static BOOL TREEVIEW_CalcItems(HWND hwnd,HDC hdc,TREEVIEW_INFO *infoPtr)
    11971317{
    11981318  TREEVIEW_ITEM *item;
    1199   INT iItem, indent,x,y,height,itemHeight,itemWidth;
     1319  INT iItem, indent,x,y,height,itemHeight;
    12001320  TEXTMETRICA tm;
    12011321  RECT rect,view;
    1202   BOOL ownDC = FALSE;
     1322  BOOL ownDC = FALSE,changedLeftTop = FALSE;
    12031323  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    12041324
     
    12221342  itemHeight = MAX(tm.tmHeight+tm.tmExternalLeading,itemHeight);
    12231343  infoPtr->uRealItemHeight = itemHeight;
     1344  infoPtr->uTotalWidth = 0;
    12241345
    12251346  iItem = (INT)infoPtr->TopRootItem;
     
    12351356    height = itemHeight * item->iIntegral +1;
    12361357
    1237     item->rect.top    = y-infoPtr->cy;
    1238     item->rect.bottom = item->rect.top+height;
    1239     item->rect.left   = x-infoPtr->cx;
    1240     item->rect.right  = rect.right;
    1241 
    12421358    //calculate size and fill rects
    12431359    if ((infoPtr->uInternalStatus & TV_CALCALL) || !item->calculated)
    1244       TREEVIEW_CalcItem(hwnd,hdc,item);
    1245 
    1246     itemWidth = MAX(itemWidth,item->rect.right-item->rect.left);
    1247 
    1248     if ((((y >= view.top) && (y <= view.bottom)) || ((y+height >= view.top) && (y+height <= view.bottom))) &&
    1249         (x >= view.left) && (x <= view.right))
     1360    {
     1361      item->rect.top    = y-infoPtr->cy;
     1362      item->rect.bottom = item->rect.top+height;
     1363      item->rect.left   = x-infoPtr->cx;
     1364      item->rect.right  = rect.right;
     1365      TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,item);
     1366    } else
     1367    {
     1368      INT xOffset,yOffset;
     1369
     1370      xOffset = (x-infoPtr->cx)-item->rect.left;
     1371      yOffset = (y-infoPtr->cy)-item->rect.top;
     1372      OffsetRect(&item->rect,xOffset,yOffset);
     1373      OffsetRect(&item->text,xOffset,yOffset);
     1374      OffsetRect(&item->expandBox,xOffset,yOffset);
     1375      OffsetRect(&item->bitmap,xOffset,yOffset);
     1376      OffsetRect(&item->statebitmap,xOffset,yOffset);
     1377    }
     1378    infoPtr->uTotalWidth = MAX(infoPtr->uTotalWidth,item->rect.right+infoPtr->cx);
     1379
     1380    if (((y >= view.top) && (y <= view.bottom)) || ((y+height >= view.top) && (y+height <= view.bottom)))
    12501381    {
    12511382      item->visible = TRUE;
     
    12611392      indent++;
    12621393      x += infoPtr->uIndent;
    1263       infoPtr->uTotalWidth = MAX(infoPtr->uTotalWidth,itemWidth+x);
    12641394    } else
    12651395    {
     
    12731403      }
    12741404    }
    1275     y +=height;
     1405    y += height;
    12761406  } /* while */
    12771407
     
    12791409
    12801410  infoPtr->uInternalStatus &= ~TV_CALCALL;
    1281 
    12821411  infoPtr->uTotalHeight = y;
    1283 infoPtr->uTotalWidth = 0; //CB: not yet ready
     1412
     1413  if (item && item->visible)
     1414  {
     1415    INT xDiff = 0,yDiff = 0;
     1416
     1417    //check cx and cy
     1418#if 0  //CB: next step
     1419    if ((infoPtr->cy > 0) && (item->rect.bottom < infoPtr->uVisibleHeight))
     1420    {
     1421      INT oldCY = infoPtr->cy;
     1422
     1423      infoPtr->cy = infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
     1424      if (infoPtr->cy < 0) infoPtr->cy = 0;
     1425      yDiff = infoPtr->cy-oldCY;
     1426    }
     1427
     1428    changedLeftTop = xDiff || yDiff;
     1429    if (changedLeftTop)
     1430    {
     1431      iItem = (INT)infoPtr->TopRootItem;
     1432      item = NULL;
     1433      indent = 0;
     1434MessageBeep(MB_OK);
     1435      while (iItem)
     1436      {
     1437        item = &infoPtr->items[iItem];
     1438        OffsetRect(&item->rect,xDiff,yDiff);
     1439        OffsetRect(&item->text,xDiff,yDiff);
     1440        OffsetRect(&item->expandBox,xDiff,yDiff);
     1441        OffsetRect(&item->bitmap,xDiff,yDiff);
     1442        OffsetRect(&item->statebitmap,xDiff,yDiff);
     1443
     1444
     1445        if ((item->firstChild) && (item->state & TVIS_EXPANDED))
     1446        {
     1447          iItem = (INT)item->firstChild;
     1448          indent++;
     1449        } else
     1450        {
     1451          iItem = (INT)item->sibling;
     1452          while ((!iItem) && (indent > 0))
     1453          {
     1454            indent--;
     1455            item = &infoPtr->items[(INT)item->parent];
     1456            iItem = (INT)item->sibling;
     1457          }
     1458        }
     1459      } /* while */
     1460    }
     1461#endif
     1462  }
    12841463
    12851464  if (!(dwStyle & TVS_NOSCROLL))
    12861465  {
    1287     if (infoPtr->uTotalHeight >= infoPtr->uVisibleHeight)
     1466    if (infoPtr->uTotalHeight > infoPtr->uVisibleHeight)
    12881467    {
    12891468      SCROLLINFO info;
     
    13031482      infoPtr->uInternalStatus &= ~TV_VSCROLL;
    13041483    }
    1305     if (!(dwStyle & TVS_NOHSCROLL) && (infoPtr->uTotalWidth >= infoPtr->uVisibleWidth))
     1484    if (!(dwStyle & TVS_NOHSCROLL) && (infoPtr->uTotalWidth > infoPtr->uVisibleWidth))
    13061485    {
    13071486      SCROLLINFO info;
     
    13271506    infoPtr->uInternalStatus &= ~(TV_VSCROLL | TV_HSCROLL);
    13281507  }
     1508
     1509  return changedLeftTop;
    13291510}
    13301511
     
    13331514{
    13341515    TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     1516    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    13351517    HBRUSH hbrBk;
    13361518    RECT rect;
     
    13691551        if (updateRect && IntersectRect(NULL,&item->rect,updateRect))
    13701552        {
    1371           TREEVIEW_DrawItem(hwnd,hdc,item);
     1553          TREEVIEW_DrawItem(hwnd,hdc,item,dwStyle,infoPtr);
    13721554          visFound = TRUE;
    13731555        }
    13741556      } else if (visFound) break;
    1375       if (!visFound)
     1557      if (!visFound && (dwStyle & TVS_HASLINES) && (dwStyle & TVS_LINESATROOT))
    13761558      {
    13771559        //draw vertical connections
     
    13801562        SelectObject(hdc,hOldPen);
    13811563      }
    1382       if ((item->firstChild) && (item->state & TVIS_EXPANDED))
     1564      if (item->firstChild && (item->state & TVIS_EXPANDED))
    13831565      {
    13841566        iItem = (INT)item->firstChild;
     
    13871569      {
    13881570        iItem = (INT)item->sibling;
    1389         while ((!iItem) && (indent > 0))
     1571        while (!iItem && (indent > 0))
    13901572        {
    13911573          item = &infoPtr->items[(INT)item->parent];
     
    14401622                infoPtr->Timer &= ~TV_EDIT_TIMER_SET;
    14411623                if (infoPtr->editItem)
    1442                    TREEVIEW_EditLabelA(hwnd, infoPtr->editItem);
     1624                   TREEVIEW_EditLabel(hwnd,infoPtr->editItem,TRUE);
    14431625                return 0;
    14441626        default:
     
    14691651}
    14701652
    1471 static void TREEVIEW_UnqueueRefresh(HWND hwnd,BOOL calc,BOOL refresh)
     1653static BOOL TREEVIEW_UnqueueRefresh(HWND hwnd,BOOL calc,BOOL refresh)
    14721654{
    14731655  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    14791661    if (calc) TREEVIEW_CalcItems(hwnd,0,infoPtr);
    14801662    if (refresh) TREEVIEW_Refresh(hwnd);
    1481   }
    1482 }
    1483 
    1484 static LRESULT
    1485 TREEVIEW_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1486 {
    1487   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    1488   LPTVITEMEXA    tvItem;
     1663
     1664    return TRUE;
     1665  }
     1666
     1667  return FALSE;
     1668}
     1669
     1670static LRESULT
     1671TREEVIEW_GetItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
     1672{
     1673  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     1674  LPTVITEMEXW    tvItem;
    14891675  TREEVIEW_ITEM *wineItem;
    14901676  INT         iItem;
    14911677
    1492   tvItem=(LPTVITEMEXA) lParam;
    1493   iItem=(INT)tvItem->hItem;
     1678  tvItem = (LPTVITEMEXW)lParam;
     1679  iItem = (INT)tvItem->hItem;
    14941680
    14951681  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
    14961682  if (!wineItem) return FALSE;
    14971683
    1498    if (tvItem->mask & TVIF_CHILDREN) {
    1499       tvItem->cChildren = TREEVIEW_HasChildren(hwnd, wineItem);
    1500    }
    1501 
    1502    if (tvItem->mask & TVIF_HANDLE) {
    1503         tvItem->hItem=wineItem->hItem;
    1504    }
    1505 
    1506    if (tvItem->mask & TVIF_IMAGE) {
    1507         tvItem->iImage=wineItem->iImage;
    1508    }
    1509 
    1510    if (tvItem->mask & TVIF_INTEGRAL) {
    1511         tvItem->iIntegral=wineItem->iIntegral;
    1512    }
    1513 
    1514    // undocumented: windows ignores TVIF_PARAM and
    1515    // always sets lParam
    1516    tvItem->lParam=wineItem->lParam;
    1517 
    1518    if (tvItem->mask & TVIF_SELECTEDIMAGE) {
    1519         tvItem->iSelectedImage=wineItem->iSelectedImage;
    1520    }
    1521 
    1522    if (tvItem->mask & TVIF_STATE) {
    1523         tvItem->state=wineItem->state & tvItem->stateMask;
    1524    }
    1525 
    1526    if (tvItem->mask & TVIF_TEXT) {
    1527         if (wineItem->pszText == LPSTR_TEXTCALLBACKA) {
    1528             tvItem->pszText = LPSTR_TEXTCALLBACKA;  /* FIXME:send notification? */
    1529 //              ERR (treeview," GetItem called with LPSTR_TEXTCALLBACK\n");
    1530         }
    1531         else if (wineItem->pszText) {
    1532             lstrcpynA (tvItem->pszText, wineItem->pszText,tvItem->cchTextMax);
    1533         }
    1534    }
    1535 
    1536 //  TRACE(treeview,"item %d<%p>, txt %p, img %p, action %x\n",
    1537 //    iItem,
    1538 //    tvItem,
    1539 //    tvItem->pszText,
    1540 //    & tvItem->iImage,
    1541 //    tvItem->mask);
     1684  if (tvItem->mask & TVIF_CHILDREN)
     1685    tvItem->cChildren = TREEVIEW_HasChildren(hwnd, wineItem);
     1686
     1687  if (tvItem->mask & TVIF_HANDLE)
     1688    tvItem->hItem=wineItem->hItem;
     1689
     1690  if (tvItem->mask & TVIF_IMAGE)
     1691    tvItem->iImage=wineItem->iImage;
     1692
     1693  if (tvItem->mask & TVIF_INTEGRAL)
     1694    tvItem->iIntegral=wineItem->iIntegral;
     1695
     1696  // undocumented: windows ignores TVIF_PARAM and
     1697  // always sets lParam
     1698  tvItem->lParam = wineItem->lParam;
     1699
     1700  if (tvItem->mask & TVIF_SELECTEDIMAGE)
     1701    tvItem->iSelectedImage=wineItem->iSelectedImage;
     1702
     1703  if (tvItem->mask & TVIF_STATE)
     1704    tvItem->state=wineItem->state & tvItem->stateMask;
     1705
     1706  if (tvItem->mask & TVIF_TEXT)
     1707  {
     1708    if (wineItem->pszText == LPSTR_TEXTCALLBACKW)
     1709      TREEVIEW_SendDispInfoNotify(hwnd,wineItem,TVN_GETDISPINFO,TVIF_TEXT);
     1710    if (unicode)
     1711    {
     1712      if (wineItem->pszText == LPSTR_TEXTCALLBACKW)
     1713        tvItem->pszText = LPSTR_TEXTCALLBACKW;
     1714      else if (wineItem->pszText)
     1715        lstrcpynW(tvItem->pszText,wineItem->pszText,tvItem->cchTextMax);
     1716    } else
     1717    {
     1718      LPTVITEMEXA tvItem = (LPTVITEMEXA)lParam;
     1719
     1720      if (wineItem->pszText == LPSTR_TEXTCALLBACKW)
     1721        tvItem->pszText = LPSTR_TEXTCALLBACKA;
     1722      else if (wineItem->pszText)
     1723        lstrcpynWtoA(tvItem->pszText, wineItem->pszText,tvItem->cchTextMax);
     1724    }
     1725  }
    15421726
    15431727  return TRUE;
     
    15581742  flag  = (INT) wParam;
    15591743  iItem = (INT) lParam;
    1560   retval=0;
    1561   switch (flag) {
    1562         case TVGN_CHILD: /* Special case: child of 0 is root */
    1563             if (iItem) break;
    1564         case TVGN_ROOT: retval=(INT)infoPtr->TopRootItem;
    1565                                         break;
    1566         case TVGN_CARET:retval=(INT)infoPtr->selectedItem;
    1567                                         break;
    1568         case TVGN_FIRSTVISIBLE:
    1569                                         TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE);
    1570                                         retval = (INT)infoPtr->firstVisible;
    1571                                         break;
    1572         case TVGN_DROPHILITE:
    1573                                         retval=(INT)infoPtr->dropItem;
    1574                                         break;
    1575         }
    1576   if (retval) {
    1577 //              TRACE (treeview,"flags:%x, returns %u\n", flag, retval);
    1578                 return retval;
    1579   }
     1744  retval = 0;
     1745  switch (flag)
     1746  {
     1747    case TVGN_CHILD: /* Special case: child of 0 is root */
     1748      if (iItem) break;
     1749
     1750    case TVGN_ROOT:
     1751      retval = (INT)infoPtr->TopRootItem;
     1752      break;
     1753
     1754    case TVGN_CARET:
     1755      retval = (INT)infoPtr->selectedItem;
     1756      break;
     1757
     1758    case TVGN_FIRSTVISIBLE:
     1759      TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE);
     1760      retval = (INT)infoPtr->firstVisible;
     1761      break;
     1762
     1763    case TVGN_DROPHILITE:
     1764      retval = (INT)infoPtr->dropItem;
     1765      break;
     1766  }
     1767
     1768  if (retval) return retval;
    15801769
    15811770  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
     
    15831772  if (!wineItem) return FALSE;
    15841773
    1585   switch (flag) {
    1586         case TVGN_NEXT: retval=(INT)wineItem->sibling;
    1587                                         break;
    1588         case TVGN_PREVIOUS:
    1589                                         retval=(INT)wineItem->upsibling;
    1590                                         break;
    1591         case TVGN_PARENT:
    1592                                         retval=(INT)wineItem->parent;
    1593                                         break;
    1594         case TVGN_CHILD:
    1595                                         retval=(INT)wineItem->firstChild;
    1596                                         break;
    1597         case TVGN_LASTVISIBLE:
    1598                                         returnItem=TREEVIEW_GetLastListItem (hwnd,infoPtr,wineItem);
    1599                                         break;
    1600         case TVGN_NEXTVISIBLE:
    1601                                         returnItem=TREEVIEW_GetNextListItem (hwnd,infoPtr,wineItem);
    1602                                         break;
    1603         case TVGN_PREVIOUSVISIBLE:
    1604                                         returnItem=TREEVIEW_GetPrevListItem (hwnd,infoPtr, wineItem);
    1605                                         break;
    1606         default:        //      FIXME (treeview,"Unknown msg %x,item %x\n", flag,iItem);
    1607                                         break;
    1608         }
    1609 
    1610   if (returnItem) {
    1611 //                TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem,
    1612 //                                                      (INT)returnItem->hItem);
    1613                   return (INT)returnItem->hItem;
    1614   }
    1615 
    1616 //  TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem,retval);
     1774  switch (flag)
     1775  {
     1776    case TVGN_NEXT:
     1777      retval = (INT)wineItem->sibling;
     1778      break;
     1779
     1780    case TVGN_PREVIOUS:
     1781      retval = (INT)wineItem->upsibling;
     1782      break;
     1783
     1784    case TVGN_PARENT:
     1785      retval = (INT)wineItem->parent;
     1786      break;
     1787
     1788    case TVGN_CHILD:
     1789      retval = (INT)wineItem->firstChild;
     1790      break;
     1791
     1792    case TVGN_LASTVISIBLE:
     1793      returnItem = TREEVIEW_GetLastListItem (hwnd,infoPtr,wineItem);
     1794      break;
     1795
     1796    case TVGN_NEXTVISIBLE:
     1797      returnItem = TREEVIEW_GetNextListItem (hwnd,infoPtr,wineItem);
     1798      break;
     1799
     1800    case TVGN_PREVIOUSVISIBLE:
     1801      returnItem = TREEVIEW_GetPrevListItem (hwnd,infoPtr, wineItem);
     1802      break;
     1803
     1804    default:
     1805      break;
     1806  }
     1807
     1808  if (returnItem) return (INT)returnItem->hItem;
     1809
    16171810  return retval;
    16181811}
     
    16221815TREEVIEW_GetCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
    16231816{
    1624  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    1625 
    1626 // TRACE (treeview," %d\n",infoPtr->uNumItems);
    1627  return (LRESULT) infoPtr->uNumItems;
     1817  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     1818
     1819  return (LRESULT) infoPtr->uNumItems;
    16281820}
    16291821
     
    17541946{
    17551947  HWND hwnd=(HWND) tvInfoPtr;
    1756   char *txt1, *txt2;
     1948  WCHAR *txt1, *txt2;
    17571949  TREEVIEW_ITEM *item;
    17581950
    17591951
    17601952  item=(TREEVIEW_ITEM *) first;
    1761   if (item->pszText==LPSTR_TEXTCALLBACKA)  {
     1953  if (item->pszText == LPSTR_TEXTCALLBACKW)  {
    17621954         TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT);
    17631955        }
     
    17651957
    17661958  item=(TREEVIEW_ITEM *) second;
    1767   if (item->pszText==LPSTR_TEXTCALLBACKA)  {
     1959  if (item->pszText == LPSTR_TEXTCALLBACKW)  {
    17681960         TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT);
    17691961        }
    17701962  txt2=item->pszText;
    17711963
    1772   return -strcmp (txt1,txt2);
     1964  return -lstrcmpW(txt1,txt2);
    17731965}
    17741966
     
    17991991  infoPtr->pCallBackSort = pSort;
    18001992
    1801         /* undocumented feature: TVI_ROOT means `sort the whole tree' */
     1993  /* undocumented feature: TVI_ROOT means `sort the whole tree' */
    18021994
    18031995  if (parent==TVI_ROOT)
     
    19052097  )
    19062098{
    1907  LPTVSORTCB pSort=(LPTVSORTCB) lParam;
    1908 
    1909  return TREEVIEW_Sort (hwnd, wParam, pSort->hParent, pSort);
     2099  LPTVSORTCB pSort=(LPTVSORTCB) lParam;
     2100
     2101  return TREEVIEW_Sort (hwnd, wParam, pSort->hParent, pSort);
    19102102}
    19112103
     
    19192111  LPARAM lParam)
    19202112{
    1921  return TREEVIEW_Sort (hwnd, (BOOL) wParam, (HTREEITEM) lParam, NULL);
     2113  return TREEVIEW_Sort (hwnd, (BOOL) wParam, (HTREEITEM) lParam, NULL);
    19222114}
    19232115
     
    19402132
    19412133static LRESULT
    1942 TREEVIEW_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1943 
    1944 {
    1945   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    1946   TVINSERTSTRUCTA *ptdi;
    1947   TVITEMEXA     *tvItem;
     2134TREEVIEW_InsertItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
     2135
     2136{
     2137  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2138  TVINSERTSTRUCTW *ptdi;
     2139  TVITEMEXW     *tvItem;
    19482140  TREEVIEW_ITEM *wineItem, *parentItem, *prevsib, *sibItem;
    19492141  INT           iItem,i,len;
    19502142
     2143  if (infoPtr->hwndEdit) SetFocus(hwnd);
     2144
    19512145  /* Item to insert */
    1952   ptdi = (LPTVINSERTSTRUCTA) lParam;
    1953 
    1954         /* check if memory is available */
     2146  ptdi = (LPTVINSERTSTRUCTW)lParam;
     2147
     2148  /* check if memory is available */
    19552149
    19562150  if (infoPtr->uNumPtrsAlloced==0) {
     
    20382232     * when the insertion are ordered
    20392233     */
    2040     if (tvItem->pszText!=LPSTR_TEXTCALLBACKA)
    2041     {
    2042       //TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText);
    2043       len = lstrlenA (tvItem->pszText)+1;
    2044       wineItem->pszText= COMCTL32_Alloc (len);
    2045       lstrcpyA (wineItem->pszText, tvItem->pszText);
    2046       wineItem->cchTextMax=len;
    2047     }
    2048     else
    2049     {
    2050       //TRACE (treeview,"LPSTR_TEXTCALLBACK\n");
    2051       wineItem->pszText = LPSTR_TEXTCALLBACKA;
    2052       wineItem->cchTextMax = 0;
     2234    if (unicode)
     2235    {
     2236      if (tvItem->pszText != LPSTR_TEXTCALLBACKW)
     2237      {
     2238        //TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText);
     2239        len = lstrlenW(tvItem->pszText)+1;
     2240        wineItem->pszText = COMCTL32_Alloc(len*sizeof(WCHAR));
     2241        lstrcpyW (wineItem->pszText, tvItem->pszText);
     2242        wineItem->cchTextMax = len;
     2243      } else
     2244      {
     2245        //TRACE (treeview,"LPSTR_TEXTCALLBACK\n");
     2246        wineItem->pszText = LPSTR_TEXTCALLBACKW;
     2247        wineItem->cchTextMax = 0;
     2248      }
     2249    } else
     2250    {
     2251      TVITEMEXA *tvItemA = (LPTVITEMEXA)tvItem;
     2252
     2253      if (tvItemA->pszText != LPSTR_TEXTCALLBACKA)
     2254      {
     2255        //TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText);
     2256        len = lstrlenA(tvItemA->pszText)+1;
     2257        wineItem->pszText= COMCTL32_Alloc (len*sizeof(WCHAR));
     2258        lstrcpyAtoW (wineItem->pszText, tvItemA->pszText);
     2259        wineItem->cchTextMax = len;
     2260      } else
     2261      {
     2262        //TRACE (treeview,"LPSTR_TEXTCALLBACK\n");
     2263        wineItem->pszText = LPSTR_TEXTCALLBACKW;
     2264        wineItem->cchTextMax = 0;
     2265      }
    20532266    }
    20542267  }
     
    20912304
    20922305        /* lookup the text if using LPSTR_TEXTCALLBACKs */
    2093         if (wineItem->pszText==LPSTR_TEXTCALLBACKA) {
     2306        if (wineItem->pszText==LPSTR_TEXTCALLBACKW) {
    20942307          TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT);
    20952308        }
     
    21012314
    21022315          /* lookup the text if using LPSTR_TEXTCALLBACKs */
    2103           if (aChild->pszText==LPSTR_TEXTCALLBACKA) {
     2316          if (aChild->pszText==LPSTR_TEXTCALLBACKW) {
    21042317            TREEVIEW_SendDispInfoNotify (hwnd, aChild, TVN_GETDISPINFO, TVIF_TEXT);
    21052318          }
    21062319
    2107           comp = strcmp(wineItem->pszText, aChild->pszText);
     2320          comp = lstrcmpW(wineItem->pszText, aChild->pszText);
    21082321          if ( comp < 0 )  /* we are smaller than the current one */
    21092322          {
     
    22152428
    22162429static LRESULT
    2217 TREEVIEW_InsertItemW(HWND hwnd, WPARAM wParam, LPARAM lParam)
    2218 {
    2219     TVINSERTSTRUCTW *tvisW;
    2220     TVINSERTSTRUCTA tvisA;
    2221     LRESULT lRes;
    2222 
    2223     tvisW = (LPTVINSERTSTRUCTW)lParam;
    2224 
    2225     tvisA.hParent = tvisW->hParent;
    2226     tvisA.hInsertAfter = tvisW->hInsertAfter;
    2227 
    2228     tvisA.DUMMYUNIONNAME.item.mask           = tvisW->DUMMYUNIONNAME.item.mask;
    2229     tvisA.DUMMYUNIONNAME.item.hItem          = tvisW->DUMMYUNIONNAME.item.hItem;
    2230     tvisA.DUMMYUNIONNAME.item.state          = tvisW->DUMMYUNIONNAME.item.state;
    2231     tvisA.DUMMYUNIONNAME.item.stateMask      = tvisW->DUMMYUNIONNAME.item.stateMask;
    2232     tvisA.DUMMYUNIONNAME.item.cchTextMax     = tvisW->DUMMYUNIONNAME.item.cchTextMax;
    2233 
    2234     if(tvisW->DUMMYUNIONNAME.item.pszText)
    2235     {
    2236         if (tvisW->DUMMYUNIONNAME.item.pszText!=LPSTR_TEXTCALLBACKW)
    2237         {
    2238             int len = lstrlenW (tvisW->DUMMYUNIONNAME.item.pszText)+1;
    2239             tvisA.DUMMYUNIONNAME.item.pszText = COMCTL32_Alloc (len);
    2240             lstrcpyWtoA (tvisA.DUMMYUNIONNAME.item.pszText,
    2241                          tvisW->DUMMYUNIONNAME.item.pszText );
    2242         }
    2243         else
    2244         {
    2245             tvisA.DUMMYUNIONNAME.item.pszText = LPSTR_TEXTCALLBACKA;
    2246             tvisA.DUMMYUNIONNAME.item.cchTextMax = 0;
    2247         }
    2248     }
    2249 
    2250     tvisA.DUMMYUNIONNAME.item.iImage         = tvisW->DUMMYUNIONNAME.item.iImage;
    2251     tvisA.DUMMYUNIONNAME.item.iSelectedImage = tvisW->DUMMYUNIONNAME.item.iSelectedImage;
    2252     tvisA.DUMMYUNIONNAME.item.cChildren      = tvisW->DUMMYUNIONNAME.item.cChildren;
    2253     tvisA.DUMMYUNIONNAME.item.lParam         = tvisW->DUMMYUNIONNAME.item.lParam;
    2254 
    2255     lRes = TREEVIEW_InsertItemA(hwnd,wParam,(LPARAM)&tvisA);
    2256 
    2257     if (tvisA.DUMMYUNIONNAME.item.pszText!=LPSTR_TEXTCALLBACKA)
    2258     {
    2259         COMCTL32_Free(tvisA.DUMMYUNIONNAME.item.pszText);
    2260     }
    2261 
    2262     return lRes;
    2263 
    2264 }
    2265 
    2266 
    2267 static LRESULT
    22682430TREEVIEW_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    22692431{
     
    22722434  TREEVIEW_ITEM *wineItem;
    22732435
    2274 //  TRACE (treeview,"\n");
    2275 
    2276   if (lParam == (INT)TVI_ROOT) {
    2277         TREEVIEW_RemoveTree (hwnd);
    2278   } else {
    2279         iItem= (INT) lParam;
    2280         wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
    2281         if (!wineItem) return FALSE;
    2282 //    TRACE (treeview,"%s\n",wineItem->pszText);
    2283         TREEVIEW_RemoveItem (hwnd, wineItem);
     2436  if (lParam == (INT)TVI_ROOT)
     2437  {
     2438    TREEVIEW_RemoveTree (hwnd);
     2439  } else
     2440  {
     2441    iItem = (INT)lParam;
     2442    wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
     2443    if (!wineItem) return FALSE;
     2444
     2445    TREEVIEW_RemoveItem (hwnd, wineItem);
    22842446  }
    22852447
     
    22942456TREEVIEW_GetIndent (HWND hwnd)
    22952457{
     2458  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2459
     2460  return infoPtr->uIndent;
     2461}
     2462
     2463static LRESULT
     2464TREEVIEW_SetIndent (HWND hwnd, WPARAM wParam)
     2465{
     2466  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2467  INT newIndent;
     2468
     2469  newIndent = (INT)wParam;
     2470  if (newIndent < MINIMUM_INDENT) newIndent = MINIMUM_INDENT;
     2471  if (newIndent != infoPtr->uIndent)
     2472  {
     2473    infoPtr->uIndent=newIndent;
     2474    infoPtr->uInternalStatus |= TV_CALCALL;
     2475    TREEVIEW_QueueRefresh(hwnd);
     2476  }
     2477
     2478  return 0;
     2479}
     2480
     2481static LRESULT
     2482TREEVIEW_GetToolTips (HWND hwnd)
     2483
     2484{
    22962485 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    22972486
    2298 // TRACE (treeview,"\n");
    2299  return infoPtr->uIndent;
    2300 }
    2301 
    2302 static LRESULT
    2303 TREEVIEW_SetIndent (HWND hwnd, WPARAM wParam)
    2304 {
    2305   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2306   INT newIndent;
    2307 
    2308 //  TRACE (treeview,"\n");
    2309   newIndent=(INT) wParam;
    2310   if (newIndent < MINIMUM_INDENT) newIndent=MINIMUM_INDENT;
    2311   infoPtr->uIndent=newIndent;
    2312 
    2313   return 0;
    2314 }
    2315 
    2316 static LRESULT
    2317 TREEVIEW_GetToolTips (HWND hwnd)
    2318 
    2319 {
    2320  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2321 
    2322 // TRACE (treeview,"\n");
    23232487 return infoPtr->hwndToolTip;
    23242488}
     
    23322496 HWND prevToolTip;
    23332497
    2334 // TRACE (treeview,"\n");
    23352498 prevToolTip=infoPtr->hwndToolTip;
    23362499 infoPtr->hwndToolTip= (HWND) wParam;
     
    23422505static LRESULT CALLBACK
    23432506TREEVIEW_GetEditControl (HWND hwnd)
    2344 
    2345 {
    2346  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2347 
    2348  return infoPtr->hwndEdit;
     2507{
     2508  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2509
     2510  return infoPtr->hwndEdit;
    23492511}
    23502512
     
    23662528          LRESULT rc;
    23672529          TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(GetParent(hwnd));
    2368           TRACE("WM_PAINT start\n");
     2530          //TRACE("WM_PAINT start\n");
    23692531          rc = CallWindowProcA( infoPtr->wpEditOrig, hwnd, uMsg, wParam, lParam);
    2370           TRACE("WM_PAINT done\n");
     2532          //TRACE("WM_PAINT done\n");
    23712533          return rc;
    23722534        }
     
    24792641static LRESULT
    24802642TREEVIEW_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2481 
    2482 {
    2483   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2484 
    2485   if (infoPtr->bAutoSize)
    2486   {
    2487     infoPtr->bAutoSize = FALSE;
    2488     return 0;
    2489   }
    2490   infoPtr->bAutoSize = TRUE;
     2643{
     2644  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    24912645
    24922646  if (wParam == SIZE_RESTORED)
    24932647  {
    2494     TREEVIEW_UnqueueRefresh(hwnd,FALSE,FALSE);
    2495     TREEVIEW_CalcItems(hwnd,0,infoPtr);
    2496     TREEVIEW_Refresh(hwnd);
     2648    if (TREEVIEW_CalcItems(hwnd,0,infoPtr))
     2649      TREEVIEW_Refresh(hwnd);
    24972650  }
    24982651
     
    25422695
    25432696    /* set default settings */
    2544     infoPtr->uInternalStatus=0;
     2697    infoPtr->uInternalStatus = 0;
    25452698    infoPtr->uNumItems=0;
    25462699    infoPtr->clrBk   = GetSysColor (COLOR_WINDOW);
     
    26692822{
    26702823  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2824  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    26712825
    26722826  TREEVIEW_SendSimpleNotify (hwnd, NM_SETFOCUS);
    26732827
    2674   if (infoPtr->selectedItem) TREEVIEW_RefreshItem(hwnd,TREEVIEW_ValidItem(infoPtr,infoPtr->selectedItem));
     2828  if (!(dwStyle & TVS_SHOWSELALWAYS) && infoPtr->selectedItem)
     2829    TREEVIEW_RefreshItem(hwnd,TREEVIEW_ValidItem(infoPtr,infoPtr->selectedItem),FALSE);
    26752830
    26762831  return 0;
     
    26812836{
    26822837  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2838  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    26832839
    26842840  TREEVIEW_SendSimpleNotify (hwnd, NM_KILLFOCUS);
    26852841
    2686   if (infoPtr->selectedItem) TREEVIEW_RefreshItem(hwnd,TREEVIEW_ValidItem(infoPtr,infoPtr->selectedItem));
     2842  if (!(dwStyle & TVS_SHOWSELALWAYS) && infoPtr->selectedItem)
     2843    TREEVIEW_RefreshItem(hwnd,TREEVIEW_ValidItem(infoPtr,infoPtr->selectedItem),FALSE);
    26872844
    26882845  return 0;
     
    27102867    NMHDR nmhdr;
    27112868
    2712 //    TRACE (treeview, "%x\n",code);
    27132869    nmhdr.hwndFrom = hwnd;
    27142870    nmhdr.idFrom   =  GetWindowLongA( hwnd, GWL_ID);
     
    27252881{
    27262882  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2727   NMTREEVIEWA nmhdr;
     2883  NMTREEVIEWW nmhdr;
    27282884  TREEVIEW_ITEM  *wineItem;
     2885  HWND parent = GetParent(hwnd);
     2886  BOOL unicode = IsWindowUnicode(parent),rc;
     2887  CHAR *oldText = NULL,*newText = NULL;
    27292888
    27302889//  TRACE (treeview,"code:%x action:%x olditem:%x newitem:%x\n",
    27312890//                code,action,(INT)oldItem,(INT)newItem);
    27322891
    2733   ZeroMemory(&nmhdr, sizeof(NMTREEVIEWA));
     2892  ZeroMemory(&nmhdr,sizeof(NMTREEVIEWW));
    27342893
    27352894  nmhdr.hdr.hwndFrom = hwnd;
    2736   nmhdr.hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
     2895  nmhdr.hdr.idFrom =  GetWindowLongW( hwnd, GWL_ID);
    27372896  nmhdr.hdr.code = code;
    27382897  nmhdr.action = action;
    2739   if (oldItem) {
    2740         wineItem=& infoPtr->items[(INT)oldItem];
    2741         nmhdr.itemOld.mask              = wineItem->mask;
    2742         nmhdr.itemOld.hItem             = wineItem->hItem;
    2743         nmhdr.itemOld.state             = wineItem->state;
    2744         nmhdr.itemOld.stateMask = wineItem->stateMask;
    2745         nmhdr.itemOld.iImage    = wineItem->iImage;
    2746         nmhdr.itemOld.pszText   = wineItem->pszText;
    2747         nmhdr.itemOld.cchTextMax= wineItem->cchTextMax;
    2748         nmhdr.itemOld.iImage    = wineItem->iImage;
    2749         nmhdr.itemOld.iSelectedImage    = wineItem->iSelectedImage;
    2750         nmhdr.itemOld.cChildren = wineItem->cChildren;
    2751         nmhdr.itemOld.lParam    = wineItem->lParam;
    2752   }
    2753 
    2754   if (newItem) {
    2755         wineItem=& infoPtr->items[(INT)newItem];
    2756         nmhdr.itemNew.mask              = wineItem->mask;
    2757         nmhdr.itemNew.hItem             = wineItem->hItem;
    2758         nmhdr.itemNew.state             = wineItem->state;
    2759         nmhdr.itemNew.stateMask = wineItem->stateMask;
    2760         nmhdr.itemNew.iImage    = wineItem->iImage;
    2761         nmhdr.itemNew.pszText   = wineItem->pszText;
    2762         nmhdr.itemNew.cchTextMax= wineItem->cchTextMax;
    2763         nmhdr.itemNew.iImage    = wineItem->iImage;
    2764         nmhdr.itemNew.iSelectedImage    = wineItem->iSelectedImage;
    2765         nmhdr.itemNew.cChildren = wineItem->cChildren;
    2766         nmhdr.itemNew.lParam    = wineItem->lParam;
     2898  if (oldItem)
     2899  {
     2900    wineItem=& infoPtr->items[(INT)oldItem];
     2901    nmhdr.itemOld.mask              = wineItem->mask;
     2902    nmhdr.itemOld.hItem             = wineItem->hItem;
     2903    nmhdr.itemOld.state             = wineItem->state;
     2904    nmhdr.itemOld.stateMask = wineItem->stateMask;
     2905    nmhdr.itemOld.iImage    = wineItem->iImage;
     2906    if (!unicode)
     2907    {
     2908      if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else
     2909      {
     2910        INT len = lstrlenW(wineItem->pszText)+1;
     2911
     2912        oldText = COMCTL32_Alloc(len);
     2913        lstrcpyWtoA(oldText,wineItem->pszText);
     2914        nmhdr.itemOld.pszText = (WCHAR*)oldText;
     2915      }
     2916    } else nmhdr.itemOld.pszText   = wineItem->pszText;
     2917    nmhdr.itemOld.cchTextMax= wineItem->cchTextMax;
     2918    nmhdr.itemOld.iImage    = wineItem->iImage;
     2919    nmhdr.itemOld.iSelectedImage    = wineItem->iSelectedImage;
     2920    nmhdr.itemOld.cChildren = wineItem->cChildren;
     2921    nmhdr.itemOld.lParam    = wineItem->lParam;
     2922  }
     2923
     2924  if (newItem)
     2925  {
     2926    wineItem=& infoPtr->items[(INT)newItem];
     2927    nmhdr.itemNew.mask              = wineItem->mask;
     2928    nmhdr.itemNew.hItem             = wineItem->hItem;
     2929    nmhdr.itemNew.state             = wineItem->state;
     2930    nmhdr.itemNew.stateMask = wineItem->stateMask;
     2931    nmhdr.itemNew.iImage    = wineItem->iImage;
     2932    if (!unicode)
     2933    {
     2934      if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else
     2935      {
     2936        INT len = lstrlenW(wineItem->pszText)+1;
     2937
     2938        newText = COMCTL32_Alloc(len);
     2939        lstrcpyWtoA(newText,wineItem->pszText);
     2940        nmhdr.itemOld.pszText = (WCHAR*)newText;
     2941      }
     2942    } else nmhdr.itemNew.pszText   = wineItem->pszText;
     2943    nmhdr.itemNew.cchTextMax= wineItem->cchTextMax;
     2944    nmhdr.itemNew.iImage    = wineItem->iImage;
     2945    nmhdr.itemNew.iSelectedImage    = wineItem->iSelectedImage;
     2946    nmhdr.itemNew.cChildren = wineItem->cChildren;
     2947    nmhdr.itemNew.lParam    = wineItem->lParam;
    27672948  }
    27682949
     
    27702951  nmhdr.ptDrag.y = 0;
    27712952
    2772   return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
    2773                                    (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmhdr);
    2774 
     2953  if (unicode)
     2954    rc = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)GetWindowLongW(hwnd,GWL_ID),(LPARAM)&nmhdr);
     2955  else
     2956    rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)GetWindowLongA(hwnd,GWL_ID),(LPARAM)&nmhdr);
     2957
     2958  if (oldText) COMCTL32_Free(oldText);
     2959  if (newText) COMCTL32_Free(newText);
     2960
     2961  return rc;
    27752962}
    27762963
     
    28032990}
    28042991
    2805 
    2806 
    28072992static BOOL
    28082993TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, UINT code, UINT what)
    28092994{
    2810   NMTVDISPINFOA tvdi;
     2995  NMTVDISPINFOW tvdi;
    28112996  BOOL retval;
    2812   char *buf;
    2813 
    2814 //  TRACE (treeview,"item %d, action %x, state %d\n",
    2815 //    (INT)wineItem->hItem,
    2816 //    what,
    2817 //    (INT)wineItem->state);
     2997  WCHAR *buf;
     2998  HWND parent = GetParent(hwnd);
     2999  BOOL unicode = IsWindowUnicode(parent);
    28183000
    28193001  tvdi.hdr.hwndFrom     = hwnd;
    2820   tvdi.hdr.idFrom       =  GetWindowLongA( hwnd, GWL_ID);
     3002  tvdi.hdr.idFrom       = GetWindowLongA( hwnd, GWL_ID);
    28213003  tvdi.hdr.code         = code;
    28223004  tvdi.item.mask        = what;
     
    28243006  tvdi.item.state       = wineItem->state;
    28253007  tvdi.item.lParam      = wineItem->lParam;
    2826   tvdi.item.pszText = COMCTL32_Alloc (128*sizeof(char));
     3008  tvdi.item.pszText     = COMCTL32_Alloc(128*(unicode? sizeof(WCHAR):sizeof(char)));
    28273009  tvdi.item.cchTextMax = 128;
    28283010  buf = tvdi.item.pszText;
    28293011
    2830   retval=(BOOL)SendMessageA (
    2831                   GetParent(hwnd),
    2832                   WM_NOTIFY,
    2833                   (WPARAM)tvdi.hdr.idFrom,
    2834                   (LPARAM)&tvdi);
     3012  if (unicode)
     3013    retval = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
     3014  else
     3015    retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    28353016
    28363017  /* Ignore posible changes */
     
    28383019      return retval;
    28393020
    2840   if (what & TVIF_TEXT) {
    2841                 wineItem->pszText        = tvdi.item.pszText;
    2842                 if (buf==tvdi.item.pszText) {
    2843                         wineItem->cchTextMax = 128;
    2844                 } else {
    2845 //                      TRACE (treeview,"user-supplied buffer\n");
    2846                         COMCTL32_Free (buf);
    2847                         wineItem->cchTextMax = 0;
    2848                 }
    2849         }
     3021  if (what & TVIF_TEXT)
     3022  {
     3023    if (unicode)
     3024    {
     3025      wineItem->pszText = tvdi.item.pszText;
     3026      if (buf == tvdi.item.pszText)
     3027      {
     3028        wineItem->cchTextMax = 128;
     3029      } else
     3030      {
     3031        //TRACE (treeview,"user-supplied buffer\n");
     3032        COMCTL32_Free(buf);
     3033        wineItem->cchTextMax = 0;
     3034      }
     3035    } else
     3036    {
     3037      if (buf == tvdi.item.pszText)
     3038      {
     3039        COMCTL32_Free(wineItem->pszText);
     3040        wineItem->cchTextMax = 128;
     3041        wineItem->pszText = COMCTL32_Alloc(128*sizeof(WCHAR));
     3042        lstrcpynAtoW(wineItem->pszText,(CHAR*)tvdi.item.pszText,wineItem->cchTextMax);
     3043        COMCTL32_Free(buf);
     3044      } else
     3045      {
     3046        //TRACE (treeview,"user-supplied buffer\n");
     3047        COMCTL32_Free(buf);
     3048        wineItem->cchTextMax = 0;
     3049      }
     3050    }
     3051  }
     3052
    28503053  if (what & TVIF_SELECTEDIMAGE)
    28513054                wineItem->iSelectedImage = tvdi.item.iSelectedImage;
     
    28573060 return retval;
    28583061}
    2859 
    2860 
    28613062
    28623063static BOOL
     
    28893090  return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
    28903091                               (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmcdhdr);
    2891 
    2892 }
    2893 
    2894 
     3092}
    28953093
    28963094/* FIXME: need to find out when the flags in uItemState need to be set */
     
    29473145}
    29483146
    2949 
     3147static VOID TREEVIEW_SendKeyDownNotify(HWND hwnd,UINT code,WORD wVKey)
     3148{
     3149  NMTVKEYDOWN nmkdhdr;
     3150
     3151  nmkdhdr.hdr.hwndFrom = hwnd;
     3152  nmkdhdr.hdr.idFrom   =  GetWindowLongA( hwnd, GWL_ID);
     3153  nmkdhdr.hdr.code     = code;
     3154  nmkdhdr.wVKey = wVKey;
     3155  nmkdhdr.flags = 0;
     3156
     3157  SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmkdhdr.hdr.idFrom,(LPARAM)&nmkdhdr);
     3158}
    29503159
    29513160/* Note:If the specified item is the child of a collapsed parent item,
     
    29633172  INT expand;
    29643173
    2965   flag = (UINT) wParam;
    2966   expand = (INT) lParam;
     3174  flag = (UINT)wParam;
     3175  expand = (INT)lParam;
    29673176
    29683177  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand);
     
    29743183    return 0;
    29753184
    2976 //  TRACE (treeview,"For (%s) flags:%x item:%d state:%d\n",
    2977 //    wineItem->pszText,
    2978 //    flag,
    2979 //    expand,
    2980 //    wineItem->state);
    2981 
    2982   if (flag == TVE_TOGGLE) {    /* FIXME: check exact behaviour here */
    2983    flag &= ~TVE_TOGGLE;    /* ie: bitwise ops or 'case' ops */
    2984    if (wineItem->state & TVIS_EXPANDED)
    2985      flag |= TVE_COLLAPSE;
    2986    else
    2987      flag |= TVE_EXPAND;
    2988   }
    2989 
    2990   switch (flag)
    2991   {
    2992     case TVE_COLLAPSERESET:
    2993       if (!wineItem->state & TVIS_EXPANDED)
    2994         return 0;
    2995 
    2996        wineItem->state &= ~(TVIS_EXPANDEDONCE | TVIS_EXPANDED);
    2997        TREEVIEW_RemoveAllChildren (hwnd, wineItem);
    2998        break;
    2999 
     3185  if ((flag & 0xF) == TVE_TOGGLE)
     3186  {
     3187    if (wineItem->state & TVIS_EXPANDED)
     3188      flag = (flag & ~0xF)+TVE_COLLAPSE;
     3189    else
     3190      flag = (flag & ~0xF)+TVE_EXPAND;
     3191  }
     3192
     3193  switch (flag & 0xF)
     3194  {
    30003195    case TVE_COLLAPSE:
    30013196      if (!wineItem->state & TVIS_EXPANDED)
    30023197        return 0;
    30033198
    3004       wineItem->state &= ~TVIS_EXPANDED;
     3199      if (flag & TVE_COLLAPSERESET)
     3200      {
     3201        wineItem->state &= ~(TVIS_EXPANDEDONCE | TVIS_EXPANDED);
     3202        TREEVIEW_RemoveAllChildren (hwnd, wineItem);
     3203      } else wineItem->state &= ~TVIS_EXPANDED;
    30053204      break;
    30063205
     
    30093208        return 0;
    30103209
     3210      if (flag & TVE_EXPANDPARTIAL)
     3211      {
     3212        //TRACE(treeview, "  case TVE_EXPANDPARTIAL\n");
     3213        //FIXME (treeview, "TVE_EXPANDPARTIAL not implemented\n");
     3214return FALSE; //CB: to check
     3215        wineItem->state ^=TVIS_EXPANDED;
     3216        wineItem->state |=TVIS_EXPANDEDONCE;
     3217        break;
     3218      }
     3219
    30113220      if (!(wineItem->state & TVIS_EXPANDEDONCE))
    30123221      {
     
    30153224
    30163225        /* this item has never been expanded */
    3017         if (TREEVIEW_SendTreeviewNotify (
    3018               hwnd,
    3019               TVN_ITEMEXPANDING,
    3020               TVE_EXPAND,
    3021               0,
    3022               (HTREEITEM)expand))
    3023         {
    3024           //TRACE(treeview, "  TVN_ITEMEXPANDING returned TRUE, exiting...\n");
     3226        if (TREEVIEW_SendTreeviewNotify(hwnd,TVN_ITEMEXPANDING,TVE_EXPAND,0,(HTREEITEM)expand))
    30253227          return FALSE;
    3026         }
     3228
    30273229
    30283230        /* FIXME
     
    30353237         */
    30363238        wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand);
    3037         if (! wineItem)
     3239        if (!wineItem)
    30383240        {
    30393241          //ERR(treeview,
     
    30553257        //TRACE(treeview, "  TVN_ITEMEXPANDED sent...\n");
    30563258
    3057       }
    3058       else
     3259      } else
    30593260      {
    30603261        /* this item has already been expanded */
     
    30623263      }
    30633264      break;
    3064 
    3065     case TVE_EXPANDPARTIAL:
    3066       //TRACE(treeview, "  case TVE_EXPANDPARTIAL\n");
    3067       //FIXME (treeview, "TVE_EXPANDPARTIAL not implemented\n");
    3068       wineItem->state ^=TVIS_EXPANDED;
    3069       wineItem->state |=TVIS_EXPANDEDONCE;
    3070       break;
    3071   }
    3072 
    3073   //TRACE(treeview, "Exiting, Item %d state is now %d...\n",
    3074   //  expand,
    3075   //  wineItem->state);
     3265    default:
     3266      return FALSE;
     3267  }
    30763268
    30773269  //CB: todo: optimize!
     
    30813273  TREEVIEW_CalcItems(hwnd,0,infoPtr);
    30823274  TREEVIEW_Refresh(hwnd);
     3275  //CB: todo: check cx and cy to fit ranges!
    30833276
    30843277  return TRUE;
    30853278}
    30863279
    3087 
    3088 
    3089 static TREEVIEW_ITEM *
    3090 TREEVIEW_HitTestPoint (HWND hwnd, POINT pt)
    3091 {
    3092  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    3093  TREEVIEW_ITEM *wineItem;
    3094  RECT rect;
    3095 
    3096  GetClientRect (hwnd, &rect);
    3097 
    3098  if (!infoPtr->firstVisible) return NULL;
    3099 
    3100  wineItem=&infoPtr->items [(INT)infoPtr->firstVisible];
    3101 
    3102  while ((wineItem!=NULL) && (pt.y > wineItem->rect.bottom))
    3103        wineItem=TREEVIEW_GetNextListItem (hwnd,infoPtr,wineItem);
    3104 
    3105  if (!wineItem)
    3106         return NULL;
    3107 
    3108  return wineItem;
    3109 }
    3110 
    3111 static LRESULT
    3112 TREEVIEW_HitTest (HWND hwnd, LPARAM lParam)
    3113 {
    3114   LPTVHITTESTINFO lpht=(LPTVHITTESTINFO) lParam;
     3280static LRESULT TREEVIEW_HitTest(HWND hwnd,LPTVHITTESTINFO lpht)
     3281{
     3282  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    31153283  TREEVIEW_ITEM *wineItem;
    31163284  RECT rect;
    31173285  UINT status,x,y;
    31183286
    3119   lpht->hItem = 0;
     3287  if (!lpht) return 0;
    31203288  GetClientRect (hwnd, &rect);
    3121   status=0;
    3122   x=lpht->pt.x;
    3123   y=lpht->pt.y;
    3124   if (x < rect.left)  status|=TVHT_TOLEFT;
    3125   if (x > rect.right) status|=TVHT_TORIGHT;
    3126   if (y < rect.top )  status|=TVHT_ABOVE;
    3127   if (y > rect.bottom) status|=TVHT_BELOW;
    3128 
    3129   if (status) {
    3130     lpht->flags=status;
     3289  status = 0;
     3290  x = lpht->pt.x;
     3291  y = lpht->pt.y;
     3292  if (x < rect.left)  status |= TVHT_TOLEFT;
     3293  if (x > rect.right) status |= TVHT_TORIGHT;
     3294  if (y < rect.top )  status |= TVHT_ABOVE;
     3295  if (y > rect.bottom) status |= TVHT_BELOW;
     3296
     3297  if (status)
     3298  {
     3299    lpht->flags = status;
     3300    lpht->hItem = 0;
     3301
    31313302    return 0;
    31323303  }
    31333304
    3134   wineItem=TREEVIEW_HitTestPoint (hwnd, lpht->pt);
    3135   if (!wineItem) {
    3136     lpht->flags=TVHT_NOWHERE;
     3305  if (infoPtr->firstVisible)
     3306  {
     3307   wineItem = &infoPtr->items [(INT)infoPtr->firstVisible];
     3308
     3309   while ((wineItem != NULL) && (y > wineItem->rect.bottom))
     3310     wineItem = TREEVIEW_GetNextListItem(hwnd,infoPtr,wineItem);
     3311  } else wineItem = NULL;
     3312
     3313  if (!wineItem)
     3314  {
     3315    lpht->flags = TVHT_NOWHERE;
     3316    lpht->hItem = 0;
     3317
    31373318    return 0;
    31383319  }
     
    31653346
    31663347done:
    3167   lpht->hItem=wineItem->hItem;
     3348  lpht->hItem = wineItem->hItem;
    31683349  //TRACE ("(%ld,%ld):result %x\n",lpht->pt.x,lpht->pt.y,lpht->flags);
    31693350
     
    31713352}
    31723353
    3173 HWND TREEVIEW_EditLabelA(HWND hwnd, HTREEITEM hItem)
     3354HWND TREEVIEW_EditLabel(HWND hwnd,HTREEITEM hItem,BOOL unicode)
    31743355{
    31753356  SIZE sz;
     
    31773358  TREEVIEW_ITEM *editItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)hItem);
    31783359  HINSTANCE hinst = GetWindowLongA(hwnd, GWL_HINSTANCE);
    3179 
    31803360  HDC hdc;
    3181   HFONT hOldFont=0;
     3361  HFONT hOldFont = 0;
    31823362  TEXTMETRICA textMetric;
    31833363
    31843364  //TRACE("%d %d\n",(INT)hwnd, (INT)hItem);
    3185         if (!editItem)
    3186                 return FALSE;
     3365  if (!editItem)
     3366    return FALSE;
    31873367
    31883368  if(infoPtr->hwndEdit)
     
    31903370
    31913371        /* Make shure that edit item is selected */
     3372
    31923373  TREEVIEW_DoSelectItem ( hwnd, TVGN_CARET, hItem, TVC_UNKNOWN);
    3193   //CB: todo: necessary?
    3194   TREEVIEW_Refresh(hwnd);
    3195 
    3196   if (editItem->pszText== LPSTR_TEXTCALLBACKA)
     3374
     3375  if (editItem->pszText == LPSTR_TEXTCALLBACKW)
    31973376                TREEVIEW_SendDispInfoNotify (hwnd, editItem, TVN_GETDISPINFO, TVIF_TEXT);
    31983377
     
    32053384
    32063385  /*Get String Lenght in pixels */
    3207   GetTextExtentPoint32A(hdc, editItem->pszText, strlen(editItem->pszText), &sz);
     3386  GetTextExtentPoint32W(hdc, editItem->pszText, lstrlenW(editItem->pszText), &sz);
    32083387
    32093388  /*Add Extra spacing for the next character */
     
    32393418     DestroyWindow(infoPtr->hwndEdit);
    32403419     infoPtr->hwndEdit = 0;
     3420
    32413421     return (HWND)0;
    32423422  }
    32433423
    32443424  infoPtr->editItem = hItem;
    3245   SetWindowTextA(infoPtr->hwndEdit, editItem->pszText);
     3425  SetWindowTextW(infoPtr->hwndEdit, editItem->pszText);
    32463426  SetFocus(infoPtr->hwndEdit);
    32473427  SendMessageA(infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     
    32573437  TREEVIEW_INFO *infoPtr    = TREEVIEW_GetInfoPtr(hwnd);
    32583438  TREEVIEW_ITEM *editedItem = TREEVIEW_ValidItem (infoPtr, infoPtr->editItem);
    3259   NMTVDISPINFOA tvdi;
     3439  NMTVDISPINFOW tvdi;
     3440  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     3441  HWND parent = GetParent(hwnd);
     3442  BOOL unicode = IsWindowUnicode(parent);
    32603443  BOOL bCommit;
    3261   char tmpText[1024] = { '\0' };
     3444  WCHAR *textW = NULL;
     3445  CHAR *textA = NULL;
    32623446  int  iLength = 0;
    32633447
     
    32753459  if (!bCancel)
    32763460  {
    3277     iLength = GetWindowTextA(infoPtr->hwndEdit, tmpText, 1023);
     3461    textW = COMCTL32_Alloc(1024*sizeof(WCHAR));
     3462    iLength = GetWindowTextW(infoPtr->hwndEdit,textW,1023);
    32783463
    32793464    //if (iLength >= 1023)
     
    32823467    //}
    32833468
    3284     tvdi.item.pszText = tmpText;
     3469    if (unicode) tvdi.item.pszText = textW; else
     3470    {
     3471      INT len = iLength+1;
     3472
     3473      textA = COMCTL32_Alloc(len);
     3474      lstrcpynWtoA(textA,textW,len);
     3475      tvdi.item.pszText = (WCHAR*)textA;
     3476    }
    32853477    tvdi.item.cchTextMax  = iLength + 1;
    32863478  }
     
    32913483  }
    32923484
    3293   bCommit=(BOOL)SendMessageA (
    3294                   GetParent(hwnd),
    3295                   WM_NOTIFY,
    3296                   (WPARAM)tvdi.hdr.idFrom,
    3297                   (LPARAM)&tvdi);
     3485  if (unicode)
     3486    bCommit=(BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
     3487  else
     3488    bCommit=(BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    32983489
    32993490  if (!bCancel && bCommit) /* Apply the changes */
    33003491  {
    3301       if (strcmp( tmpText, editedItem->pszText ) != 0)
    3302       {
    3303         if(NULL == COMCTL32_ReAlloc(editedItem->pszText, iLength+1 ))
    3304         {
    3305           //ERR("OutOfMemory, cannot allocate space for label");
    3306           DestroyWindow(infoPtr->hwndEdit);
    3307           infoPtr->hwndEdit = 0;
    3308           return FALSE;
    3309         }
    3310         else
    3311         {
    3312            editedItem->cchTextMax = iLength + 1;
    3313            lstrcpyA( editedItem->pszText, tmpText);
    3314         }
     3492    if (!unicode)
     3493      lstrcpynAtoW(textW,textA,iLength+1);
     3494    if (lstrcmpW(textW,editedItem->pszText) != 0)
     3495    {
     3496      if(NULL == COMCTL32_ReAlloc(editedItem->pszText,(iLength+1)*sizeof(WCHAR)))
     3497      {
     3498        //ERR("OutOfMemory, cannot allocate space for label");
     3499        DestroyWindow(infoPtr->hwndEdit);
     3500        infoPtr->hwndEdit = 0;
     3501        if (textA) COMCTL32_Free(textA);
     3502        if (textW) COMCTL32_Free(textW);
     3503
     3504        return FALSE;
    33153505      }
     3506      else
     3507      {
     3508        editedItem->cchTextMax = iLength + 1;
     3509        lstrcpyW( editedItem->pszText,textW);
     3510      }
     3511    }
    33163512  }
    33173513
     
    33203516  infoPtr->hwndEdit = 0;
    33213517  infoPtr->editItem = 0;
     3518  if (textA) COMCTL32_Free(textA);
     3519  if (textW) COMCTL32_Free(textW);
     3520
     3521  editedItem->calculated = FALSE;
     3522  TREEVIEW_CalcItem(hwnd,0,dwStyle,infoPtr,editedItem);
     3523  TREEVIEW_RefreshItem(hwnd,editedItem,TRUE);
    33223524
    33233525  return TRUE;
     
    33813583  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    33823584  TREEVIEW_ITEM *wineItem;
    3383   POINT pt;
    3384 
    3385   pt.x = (INT)LOWORD(lParam);
    3386   pt.y = (INT)HIWORD(lParam);
     3585  TV_HITTESTINFO hitinfo;
     3586
     3587  hitinfo.pt.x = (INT)LOWORD(lParam);
     3588  hitinfo.pt.y = (INT)HIWORD(lParam);
    33873589  SetFocus (hwnd);
    33883590
     
    33943596  }
    33953597
    3396   wineItem=TREEVIEW_HitTestPoint (hwnd, pt);
    3397   if (!wineItem) return 0;
     3598  if (!TREEVIEW_HitTest(hwnd,&hitinfo) || !(hitinfo.flags & TVHT_ONITEM)) return FALSE;
     3599  wineItem = &infoPtr->items [(INT)hitinfo.hItem];
    33983600
    33993601  if (TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK)!=TRUE) {     /* FIXME!*/
     
    34263628  ht.pt.y = (INT)HIWORD(lParam);
    34273629
    3428   TREEVIEW_HitTest (hwnd, (LPARAM) &ht);
     3630  TREEVIEW_HitTest (hwnd,&ht);
    34293631  //TRACE("item %d \n", (INT)ht.hItem);
    34303632
     
    35133715   ht.pt.y = (INT)HIWORD(lParam);
    35143716
    3515    TREEVIEW_HitTest (hwnd, (LPARAM) &ht);
     3717   TREEVIEW_HitTest(hwnd,&ht);
    35163718
    35173719   if (TREEVIEW_TrackMouse(hwnd, ht.pt))
     
    35443746 RECT  rc;
    35453747 HFONT hOldFont;
    3546  char    *itemtxt;
     3748 WCHAR    *itemtxt;
    35473749
    35483750// TRACE (treeview,"\n");
     
    35523754 if (!dragItem) return 0;
    35533755
    3554  if (dragItem->pszText==LPSTR_TEXTCALLBACKA) {
     3756 if (dragItem->pszText==LPSTR_TEXTCALLBACKW) {
    35553757     TREEVIEW_SendDispInfoNotify (hwnd, dragItem, TVN_GETDISPINFO, TVIF_TEXT);
    35563758 }
     
    35623764
    35633765 hOldFont=SelectObject (hdc, infoPtr->hFont);
    3564  GetTextExtentPoint32A (hdc, itemtxt, lstrlenA (itemtxt), &size);
     3766 GetTextExtentPoint32W (hdc, itemtxt, lstrlenW (itemtxt), &size);
    35653767// TRACE (treeview,"%d %d %s %d\n",size.cx,size.cy,itemtxt,lstrlenA(itemtxt));
    35663768 hbmp=CreateCompatibleBitmap (htopdc, size.cx, size.cy);
     
    35823784
    35833785 SetRect (&rc, cx, 0, size.cx,size.cy);
    3584  DrawTextA (hdc, itemtxt, lstrlenA (itemtxt), &rc, DT_LEFT);
     3786 DrawTextW (hdc, itemtxt, lstrlenW (itemtxt), &rc, DT_LEFT);
    35853787 SelectObject (hdc, hOldFont);
    35863788 SelectObject (hdc, hOldbmp);
     
    35983800static LRESULT
    35993801TREEVIEW_DoSelectItem (HWND hwnd, INT action, HTREEITEM newSelect, INT cause)
    3600 
    36013802{
    36023803  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    36063807  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)newSelect);
    36073808
    3608 //  TRACE (treeview,"Entering item %d, flag %x, cause %x, state %d\n",
    3609 //    (INT)newSelect,
    3610 //    action,
    3611 //    cause,
    3612 //    wineItem->state);
    3613 
    3614   if ( (wineItem) && (wineItem->parent))
    3615   {
     3809  if (wineItem && wineItem->parent)
     3810  {
     3811    TREEVIEW_ITEM *parent = TREEVIEW_ValidItem(infoPtr,wineItem->parent);
     3812
    36163813    /*
    36173814     * If the item has a collapse parent expand the parent so he
    36183815     * can expose the item
    36193816     */
    3620     TREEVIEW_ITEM *parentItem = TREEVIEW_ValidItem (infoPtr, wineItem->parent);
    3621 
    3622     if (!(parentItem->state & TVIS_EXPANDED))
    3623       TREEVIEW_Expand (hwnd, TVE_EXPAND, (LPARAM) wineItem->parent);
     3817    while (parent && !(parent->state & TVIS_EXPANDED))
     3818    {
     3819      TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent);
     3820      parent = TREEVIEW_ValidItem(infoPtr,parent->parent);
     3821    }
    36243822  }
    36253823
     
    36273825  {
    36283826    case TVGN_CARET:
    3629       prevSelect=(INT)infoPtr->selectedItem;
    3630 
    3631       if ((HTREEITEM)prevSelect==newSelect)
     3827      prevSelect = (INT)infoPtr->selectedItem;
     3828
     3829      if ((HTREEITEM)prevSelect == newSelect)
    36323830        return FALSE;
    36333831
     
    36513849
    36523850      TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE);
    3653       TREEVIEW_RefreshItem(hwnd,prevItem);
    3654       TREEVIEW_RefreshItem(hwnd,wineItem);
     3851      TREEVIEW_RefreshItem(hwnd,prevItem,FALSE);
     3852      TREEVIEW_RefreshItem(hwnd,wineItem,FALSE);
    36553853
    36563854      TREEVIEW_SendTreeviewNotify(
     
    36693867        prevItem->state &= ~TVIS_DROPHILITED;
    36703868
    3671       infoPtr->dropItem=(HTREEITEM)newSelect;
     3869      infoPtr->dropItem = (HTREEITEM)newSelect;
    36723870
    36733871      if (wineItem)
     
    36753873
    36763874      TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE);
    3677       TREEVIEW_RefreshItem(hwnd,prevItem);
    3678       TREEVIEW_RefreshItem(hwnd,wineItem);
     3875      TREEVIEW_RefreshItem(hwnd,prevItem,FALSE);
     3876      TREEVIEW_RefreshItem(hwnd,wineItem,FALSE);
    36793877
    36803878      break;
    36813879
    36823880    case TVGN_FIRSTVISIBLE:
    3683 //      FIXME (treeview, "FIRSTVISIBLE not implemented\n");
     3881    {
     3882      INT scrollY;
     3883
     3884      if (wineItem->rect.top < 0)
     3885        scrollY = wineItem->rect.top;
     3886      else
     3887      {
     3888        scrollY = MIN(wineItem->rect.top,infoPtr->uTotalHeight-infoPtr->uVisibleHeight);
     3889        if (scrollY < 0) scrollY = 0;
     3890      }
     3891
     3892      if (scrollY != 0)
     3893      {
     3894        infoPtr->cy += scrollY;
     3895        if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE))
     3896          TREEVIEW_CalcItems(hwnd,0,infoPtr);
     3897
     3898        ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE);
     3899      }
     3900
    36843901      break;
     3902    }
    36853903 }
    36863904
    3687 //  TRACE (treeview,"Leaving state %d\n", wineItem->state);
    36883905 return TRUE;
    36893906}
    36903907
    3691 /* FIXME: handle NM_KILLFocus enzo */
    36923908static LRESULT
    36933909TREEVIEW_SelectItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3694 
    36953910{
    36963911 return TREEVIEW_DoSelectItem (hwnd, wParam, (HTREEITEM) lParam, TVC_UNKNOWN);
    36973912}
    36983913
    3699 
    3700 
    3701 
    37023914static LRESULT
    37033915TREEVIEW_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3704 
    37053916{
    37063917 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    37123923static LRESULT
    37133924TREEVIEW_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3714 
    37153925{
    37163926  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    37583968  int lastPos = infoPtr->cy;
    37593969
    3760 //  TRACE (treeview,"wp %x, lp %lx\n", wParam, lParam);
    37613970  if (!infoPtr->uInternalStatus & TV_VSCROLL) return FALSE;
    37623971
     
    37974006  if (lastPos != infoPtr->cy)
    37984007  {
    3799     TREEVIEW_CalcItems(hwnd,0,infoPtr);
     4008    if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE))
     4009      TREEVIEW_CalcItems(hwnd,0,infoPtr);
    38004010    ScrollWindowEx(hwnd,0,lastPos-infoPtr->cy,NULL,NULL,0,NULL,SW_INVALIDATE);
    38014011  }
     
    38114021  int lastPos = infoPtr->cx;
    38124022
    3813 //  TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam);
     4023  //TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam);
    38144024
    38154025  if (!infoPtr->uInternalStatus & TV_HSCROLL) return FALSE;
     
    38494059  }
    38504060
    3851   TREEVIEW_CalcItems(hwnd,0,infoPtr);
    3852   ScrollWindowEx(hwnd,lastPos-infoPtr->cx,0,NULL,NULL,0,NULL,SW_INVALIDATE);
     4061  if (lastPos != infoPtr->cx)
     4062  {
     4063    if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE))
     4064      TREEVIEW_CalcItems(hwnd,0,infoPtr);
     4065    ScrollWindowEx(hwnd,lastPos-infoPtr->cx,0,NULL,NULL,0,NULL,SW_INVALIDATE);
     4066  }
    38534067
    38544068  return TRUE;
     
    38904104TREEVIEW_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    38914105{
    3892  TREEVIEW_INFO *infoPtr        = TREEVIEW_GetInfoPtr(hwnd);
    3893  HTREEITEM     hNewSelection   = 0;
    3894  INT           scrollNeeds     = -1;
    3895  INT           cyChangeNeeds   = -1;
    3896  INT           prevSelect      = (INT)infoPtr->selectedItem;
    3897 
    3898  TREEVIEW_ITEM *prevItem       =
     4106  TREEVIEW_INFO *infoPtr        = TREEVIEW_GetInfoPtr(hwnd);
     4107  HTREEITEM     hNewSelection   = 0;
     4108  INT           prevSelect      = (INT)infoPtr->selectedItem;
     4109  TREEVIEW_ITEM *prevItem       =
    38994110    (prevSelect != 0 ) ?
    39004111      TREEVIEW_ValidItem (infoPtr, (HTREEITEM)prevSelect) :
    39014112      NULL;
    3902 
    3903  TREEVIEW_ITEM *newItem        = NULL;
    3904 
    3905 // TRACE (treeview,"%x %lx\n",wParam, lParam);
    3906 
    3907  if (prevSelect == 0)
    3908    return FALSE;
    3909 
    3910  switch (wParam) {
    3911         case VK_UP:
    3912                 newItem=TREEVIEW_GetPrevListItem (hwnd,infoPtr, prevItem);
    3913 
    3914                 if (!newItem)
    3915                         newItem=& infoPtr->items[(INT)infoPtr->TopRootItem];
    3916 
    3917     hNewSelection = newItem->hItem;
    3918 
    3919     if (! newItem->visible)
    3920       scrollNeeds = SB_LINEUP;
    3921 
    3922                 break;
    3923 
    3924         case VK_DOWN:
    3925                 newItem=TREEVIEW_GetNextListItem (hwnd,infoPtr, prevItem);
    3926 
    3927                 if (!newItem)
    3928       newItem=prevItem;
    3929 
    3930     hNewSelection = newItem->hItem;
    3931 
    3932     if (! newItem->visible)
    3933       scrollNeeds = SB_LINEDOWN;
    3934 
    3935                 break;
    3936 
    3937         case VK_HOME:
    3938                 newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
    3939     hNewSelection = newItem->hItem;
    3940     cyChangeNeeds = 0;
    3941                 break;
    3942 
    3943         case VK_END:
    3944                 newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
    3945                 newItem       = TREEVIEW_GetLastListItem (hwnd,infoPtr, newItem);
    3946     hNewSelection = newItem->hItem;
    3947 
    3948     if (! newItem->visible)
    3949       cyChangeNeeds = infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    3950 
    3951                 break;
    3952 
    3953         case VK_LEFT:
    3954     if ( (prevItem->state & TVIS_EXPANDED) &&
     4113  TREEVIEW_ITEM *newItem        = NULL;
     4114
     4115  TREEVIEW_SendKeyDownNotify(hwnd,TVN_KEYDOWN,wParam);
     4116
     4117  if (prevSelect == 0)
     4118    return FALSE;
     4119
     4120  switch (wParam)
     4121  {
     4122    case VK_UP:
     4123      newItem = TREEVIEW_GetPrevListItem(hwnd,infoPtr, prevItem);
     4124
     4125      if (!newItem)
     4126        newItem = &infoPtr->items[(INT)infoPtr->TopRootItem];
     4127
     4128      hNewSelection = newItem->hItem;
     4129
     4130      break;
     4131
     4132    case VK_DOWN:
     4133      newItem = TREEVIEW_GetNextListItem (hwnd,infoPtr, prevItem);
     4134
     4135      if (!newItem)
     4136        newItem = prevItem;
     4137
     4138      hNewSelection = newItem->hItem;
     4139
     4140      break;
     4141
     4142    case VK_HOME:
     4143      newItem = &infoPtr->items[(INT)infoPtr->TopRootItem];
     4144      hNewSelection = newItem->hItem;
     4145
     4146      break;
     4147
     4148    case VK_END:
     4149      newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
     4150      newItem       = TREEVIEW_GetLastListItem (hwnd,infoPtr, newItem);
     4151      hNewSelection = newItem->hItem;
     4152
     4153      break;
     4154
     4155    case VK_LEFT:
     4156      if ( (prevItem->state & TVIS_EXPANDED) &&
    39554157         TREEVIEW_HasChildren(hwnd, prevItem))
    3956     {
    3957       TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect );
    3958     }
    3959     else if ((INT)prevItem->parent)
    3960     {
    3961       newItem = (& infoPtr->items[(INT)prevItem->parent]);
    3962       if (! newItem->visible)
    3963         /* FIXME find a way to make this item the first visible... */
    3964         newItem = NULL;
    3965 
    3966       hNewSelection = newItem->hItem;
    3967     }
    3968 
    3969     break;
    3970 
    3971         case VK_RIGHT:
    3972     if ( TREEVIEW_HasChildren(hwnd, prevItem) )
    3973     {
    3974       if (! (prevItem->state & TVIS_EXPANDED))
    3975         TREEVIEW_Expand(hwnd, TVE_EXPAND, prevSelect );
    3976       else
    3977       {
    3978         newItem = (& infoPtr->items[(INT)prevItem->firstChild]);
     4158      {
     4159        TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect );
     4160      } else if ((INT)prevItem->parent)
     4161      {
     4162        newItem = (& infoPtr->items[(INT)prevItem->parent]);
     4163
    39794164        hNewSelection = newItem->hItem;
    39804165      }
    3981     }
    3982 
    3983     break;
    3984 
    3985   case VK_ADD:
    3986     if (! (prevItem->state & TVIS_EXPANDED))
    3987       TREEVIEW_Expand(hwnd, TVE_EXPAND, prevSelect );
    3988     break;
    3989 
    3990   case VK_SUBTRACT:
    3991     if (prevItem->state & TVIS_EXPANDED)
     4166
     4167      break;
     4168    case VK_RIGHT:
     4169      if (TREEVIEW_HasChildren(hwnd, prevItem))
     4170      {
     4171        if (!(prevItem->state & TVIS_EXPANDED))
     4172          TREEVIEW_Expand(hwnd, TVE_EXPAND, prevSelect );
     4173         else
     4174         {
     4175           newItem = (& infoPtr->items[(INT)prevItem->firstChild]);
     4176          hNewSelection = newItem->hItem;
     4177         }
     4178      }
     4179
     4180      break;
     4181
     4182    case VK_ADD:
     4183      if (!(prevItem->state & TVIS_EXPANDED))
     4184        TREEVIEW_Expand(hwnd, TVE_EXPAND, prevSelect );
     4185      break;
     4186
     4187    case VK_SUBTRACT:
     4188      if (prevItem->state & TVIS_EXPANDED)
    39924189      TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect );
    39934190    break;
    39944191
    3995   case VK_PRIOR:
    3996 
    3997                 newItem=TREEVIEW_GetListItem(
     4192    case VK_PRIOR:
     4193      newItem=TREEVIEW_GetListItem(
    39984194              hwnd,
    39994195              infoPtr,
    40004196              prevItem,
    40014197              -1*(TREEVIEW_GetVisibleCount(hwnd,0,0)-3));
    4002                 if (!newItem)
    4003       newItem=prevItem;
    4004 
    4005     hNewSelection = newItem->hItem;
    4006 
    4007     if (! newItem->visible)
    4008       scrollNeeds = SB_PAGEUP;
    4009 
    4010                 break;
    4011 
    4012   case VK_NEXT:
    4013                 newItem=TREEVIEW_GetListItem(
     4198      if (!newItem)
     4199        newItem = prevItem;
     4200
     4201      hNewSelection = newItem->hItem;
     4202
     4203      break;
     4204
     4205    case VK_NEXT:
     4206      newItem=TREEVIEW_GetListItem(
    40144207              hwnd,
    40154208              infoPtr,
     
    40174210              TREEVIEW_GetVisibleCount(hwnd,0,0)-3);
    40184211
    4019                 if (!newItem)
    4020       newItem=prevItem;
    4021 
    4022     hNewSelection = newItem->hItem;
    4023 
    4024     if (! newItem->visible)
    4025       scrollNeeds = SB_PAGEDOWN;
    4026 
    4027                 break;
    4028 
    4029         case VK_BACK:
    4030 
    4031         case VK_RETURN:
    4032 
    4033   default:
    4034 //              FIXME (treeview, "%x not implemented\n", wParam);
    4035                 break;
     4212      if (!newItem)
     4213        newItem = prevItem;
     4214
     4215      hNewSelection = newItem->hItem;
     4216
     4217      break;
     4218
     4219    case VK_BACK:
     4220    case VK_RETURN:
     4221
     4222    default:
     4223      break;
    40364224 }
    40374225
    40384226  if (hNewSelection)
    40394227  {
    4040 /*
    4041     This works but does not send notification...
    4042 
    4043     prevItem->state      &= ~TVIS_SELECTED;
    4044     newItem->state       |=  TVIS_SELECTED;
    4045     infoPtr->selectedItem = hNewSelection;
    4046     TREEVIEW_QueueRefresh (hwnd);
    4047 */
    4048 
    40494228    if ( TREEVIEW_DoSelectItem(
    40504229           hwnd,
     
    40534232           TVC_BYKEYBOARD))
    40544233    {
    4055       /* If selection change is allowed for the new item, perform scrolling */
    4056       if (scrollNeeds != -1)
    4057         TREEVIEW_VScroll(hwnd, scrollNeeds, 0);
    4058 
    4059       if (cyChangeNeeds != -1)
    4060         infoPtr->cy = cyChangeNeeds;
    4061 
    4062       /* FIXME: Something happen in the load the in the two weeks before
    4063          april 1st 1999 which makes this SetFocus mandatory otherwise, the focus
    4064          is lost... However the SetFocus should not be required...*/
    4065 
    4066       SetFocus(hwnd);
     4234      TREEVIEW_EnsureVisible(hwnd,hNewSelection);
    40674235    }
    40684236  }
     
    40874255
    40884256  return uOldScrollTime;
     4257}
     4258
     4259static LRESULT TREEVIEW_EnsureVisible(HWND hwnd,HTREEITEM hItem)
     4260{
     4261  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     4262  TREEVIEW_ITEM *item;
     4263  RECT rect;
     4264  INT scrollY;
     4265
     4266  item = TREEVIEW_ValidItem(infoPtr,hItem);
     4267
     4268  if (!item) return FALSE;
     4269
     4270  if (item && item->parent)
     4271  {
     4272    TREEVIEW_ITEM *parent = TREEVIEW_ValidItem(infoPtr,item->parent);
     4273
     4274    while (parent && !(parent->state & TVIS_EXPANDED))
     4275    {
     4276      TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent);
     4277      parent = TREEVIEW_ValidItem(infoPtr,parent->parent);
     4278    }
     4279  }
     4280
     4281  TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE);
     4282  GetClientRect(hwnd,&rect);
     4283  if (item->rect.top < 0)
     4284    scrollY = item->rect.top;
     4285  else if (item->rect.bottom > rect.bottom)
     4286    scrollY = item->rect.bottom-rect.bottom;
     4287  else return FALSE;
     4288
     4289  if (scrollY != 0)
     4290  {
     4291    infoPtr->cy += scrollY;
     4292    TREEVIEW_CalcItems(hwnd,0,infoPtr);
     4293    ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE);
     4294
     4295    return TRUE;
     4296  }
     4297
     4298  return FALSE;
     4299}
     4300
     4301static LRESULT TREEVIEW_GetISearchString(HWND hwnd,LPSTR lpsz,BOOL unicode)
     4302{
     4303  //CB: todo
     4304
     4305  return 0;
    40894306}
    40904307
     
    41004317    switch (uMsg) {
    41014318        case TVM_INSERTITEMA:
    4102           return TREEVIEW_InsertItemA (hwnd, wParam, lParam);
     4319          return TREEVIEW_InsertItem(hwnd,wParam,lParam,FALSE);
    41034320
    41044321        case TVM_INSERTITEMW:
    4105           return TREEVIEW_InsertItemW(hwnd,wParam,lParam);
     4322          return TREEVIEW_InsertItem(hwnd,wParam,lParam,TRUE);
    41064323
    41074324        case TVM_DELETEITEM:
     
    41364353
    41374354        case TVM_GETITEMA:
    4138                 return TREEVIEW_GetItemA (hwnd, wParam, lParam);
     4355                return TREEVIEW_GetItem(hwnd,wParam,lParam,FALSE);
    41394356
    41404357        case TVM_GETITEMW:
    4141 //                      FIXME (treeview, "Unimplemented msg TVM_GETITEMW\n");
    4142                 return 0;
     4358                return TREEVIEW_GetItem(hwnd,wParam,lParam,TRUE);
    41434359
    41444360        case TVM_SETITEMA:
    4145                 return TREEVIEW_SetItemA (hwnd, wParam, lParam);
     4361                return TREEVIEW_SetItem(hwnd,wParam,lParam,FALSE);
    41464362
    41474363        case TVM_SETITEMW:
    4148 //                      FIXME (treeview, "Unimplemented msg TVM_SETITEMW\n");
    4149                 return 0;
     4364                return TREEVIEW_SetItem(hwnd,wParam,lParam,TRUE);
    41504365
    41514366        case TVM_EDITLABELA:
    4152                 return TREEVIEW_EditLabelA(hwnd, (HTREEITEM)lParam);
     4367                return TREEVIEW_EditLabel(hwnd,(HTREEITEM)lParam,FALSE);
    41534368
    41544369        case TVM_EDITLABELW:
    4155 //                      FIXME (treeview, "Unimplemented msg TVM_EDITLABELW \n");
    4156                 return 0;
     4370                return TREEVIEW_EditLabel(hwnd,(HTREEITEM)lParam,TRUE);
    41574371
    41584372        case TVM_GETEDITCONTROL:
     
    41634377
    41644378        case TVM_HITTEST:
    4165                 return TREEVIEW_HitTest (hwnd, lParam);
     4379                return TREEVIEW_HitTest(hwnd,(LPTVHITTESTINFO)lParam);
    41664380
    41674381        case TVM_CREATEDRAGIMAGE:
     
    41734387
    41744388        case TVM_ENSUREVISIBLE:
    4175 //                      FIXME (treeview, "Unimplemented msg TVM_ENSUREVISIBLE\n");
    4176                 return 0;
     4389                return TREEVIEW_EnsureVisible(hwnd,(HTREEITEM)lParam);
    41774390
    41784391        case TVM_SORTCHILDRENCB:
     
    41834396
    41844397        case TVM_GETISEARCHSTRINGA:
    4185 //                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRINGA\n");
    4186                 return 0;
     4398                return TREEVIEW_GetISearchString(hwnd,(LPSTR)lParam,FALSE);
    41874399
    41884400        case TVM_GETISEARCHSTRINGW:
    4189 //                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRINGW\n");
    4190                 return 0;
     4401                return TREEVIEW_GetISearchString(hwnd,(LPSTR)lParam,TRUE);
    41914402
    41924403        case TVM_GETTOOLTIPS:
Note: See TracChangeset for help on using the changeset viewer.