Nikolay Sivov : comctl32: Make it possible to use TVM_GETITEM with item from another tree.
Alexandre Julliard
julliard at winehq.org
Tue May 22 14:21:29 CDT 2012
Module: wine
Branch: master
Commit: 95a15a3482ba47c1b84fd77a63f95d5cd784a97a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=95a15a3482ba47c1b84fd77a63f95d5cd784a97a
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue May 22 11:31:23 2012 +0400
comctl32: Make it possible to use TVM_GETITEM with item from another tree.
---
dlls/comctl32/tests/treeview.c | 13 +++++++-
dlls/comctl32/treeview.c | 68 +++++++++++++++++++++------------------
2 files changed, 49 insertions(+), 32 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 2246c79..a669df9 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -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)
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 3f4fdc6..63e3507 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -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);
More information about the wine-cvs
mailing list