comctl32: Make it possible to use TVM_GETITEM with item from another tree.

This commit is contained in:
Nikolay Sivov 2012-05-22 11:31:23 +04:00 committed by Alexandre Julliard
parent d7ccfef25b
commit 95a15a3482
2 changed files with 49 additions and 32 deletions

View File

@ -746,8 +746,8 @@ static void test_get_set_item(void)
TVITEMA tviRoot = {0};
int nBufferSize = 80;
char szBuffer[80] = {0};
HWND hTree, hTree2;
DWORD ret;
HWND hTree;
hTree = create_treeview_control(0);
fill_tree(hTree);
@ -791,7 +791,18 @@ static void test_get_set_item(void)
ok_sequence(sequences, TREEVIEW_SEQ_INDEX, test_get_set_item_seq,
"test get set item", FALSE);
/* get item from a different tree */
hTree2 = create_treeview_control(0);
tviRoot.hItem = hRoot;
tviRoot.mask = TVIF_STATE;
tviRoot.state = 0;
ret = SendMessage( hTree2, TVM_GETITEMA, 0, (LPARAM)&tviRoot );
expect(TRUE, ret);
ok(tviRoot.state == TVIS_FOCUSED, "got state 0x%0x\n", tviRoot.state);
DestroyWindow(hTree);
DestroyWindow(hTree2);
}
static void test_get_set_itemheight(void)

View File

@ -67,36 +67,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(treeview);
/* internal structures */
typedef struct _TREEITEM /* HTREEITEM is a _TREEINFO *. */
{
HTREEITEM parent; /* handle to parent or 0 if at root */
HTREEITEM nextSibling; /* handle to next item in list, 0 if last */
HTREEITEM firstChild; /* handle to first child or 0 if no child */
UINT callbackMask;
UINT state;
UINT stateMask;
LPWSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int iExpandedImage;
int cChildren;
LPARAM lParam;
int iIntegral; /* item height multiplier (1 is normal) */
int iLevel; /* indentation level:0=root level */
HTREEITEM lastChild;
HTREEITEM prevSibling; /* handle to prev item in list, 0 if first */
RECT rect;
LONG linesOffset;
LONG stateOffset;
LONG imageOffset;
LONG textOffset;
LONG textWidth; /* horizontal text extent for pszText */
LONG visibleOrder; /* visible ordering, 0 is first visible item */
} TREEVIEW_ITEM;
typedef struct tagTREEVIEW_INFO
{
HWND hwnd;
@ -163,6 +133,35 @@ typedef struct tagTREEVIEW_INFO
WCHAR szSearchParam[ MAX_PATH ];
} TREEVIEW_INFO;
typedef struct _TREEITEM /* HTREEITEM is a _TREEINFO *. */
{
HTREEITEM parent; /* handle to parent or 0 if at root */
HTREEITEM nextSibling; /* handle to next item in list, 0 if last */
HTREEITEM firstChild; /* handle to first child or 0 if no child */
UINT callbackMask;
UINT state;
UINT stateMask;
LPWSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int iExpandedImage;
int cChildren;
LPARAM lParam;
int iIntegral; /* item height multiplier (1 is normal) */
int iLevel; /* indentation level:0=root level */
HTREEITEM lastChild;
HTREEITEM prevSibling; /* handle to prev item in list, 0 if first */
RECT rect;
LONG linesOffset;
LONG stateOffset;
LONG imageOffset;
LONG textOffset;
LONG textWidth; /* horizontal text extent for pszText */
LONG visibleOrder; /* visible ordering, 0 is first visible item */
const TREEVIEW_INFO *infoPtr; /* tree data this item belongs to */
} TREEVIEW_ITEM;
/******** Defines that TREEVIEW_ProcessLetterKeys uses ****************/
#define KEY_DELAY 450
@ -1012,6 +1011,7 @@ TREEVIEW_AllocateItem(const TREEVIEW_INFO *infoPtr)
newItem->iImage = 0;
newItem->iSelectedImage = 0;
newItem->iExpandedImage = (WORD)I_IMAGENONE;
newItem->infoPtr = infoPtr;
if (DPA_InsertPtr(infoPtr->items, INT_MAX, newItem) == -1)
{
@ -2082,7 +2082,13 @@ TREEVIEW_GetItemT(const TREEVIEW_INFO *infoPtr, LPTVITEMEXW tvItem, BOOL isW)
TREEVIEW_ITEM *item = tvItem->hItem;
if (!TREEVIEW_ValidItem(infoPtr, item))
return FALSE;
{
if (!item) return FALSE;
TRACE("got item from different tree %p, called from %p\n", item->infoPtr, infoPtr);
infoPtr = item->infoPtr;
if (!TREEVIEW_ValidItem(infoPtr, item)) return FALSE;
}
TREEVIEW_UpdateDispInfo(infoPtr, item, tvItem->mask);