Commit 0517abf1 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/treeview: Use a code set by dispinfo holder to convert data encoding…

comctl32/treeview: Use a code set by dispinfo holder to convert data encoding after TVN_GETDISPINFO.
parent b5416b02
...@@ -35,6 +35,11 @@ ...@@ -35,6 +35,11 @@
static const char *TEST_CALLBACK_TEXT = "callback_text"; static const char *TEST_CALLBACK_TEXT = "callback_text";
static TVITEMA g_item_expanding, g_item_expanded;
static BOOL g_get_from_expand;
static BOOL g_get_rect_in_expand;
static BOOL g_disp_A_to_W;
#define NUM_MSG_SEQUENCES 2 #define NUM_MSG_SEQUENCES 2
#define TREEVIEW_SEQ_INDEX 0 #define TREEVIEW_SEQ_INDEX 0
#define PARENT_SEQ_INDEX 1 #define PARENT_SEQ_INDEX 1
...@@ -338,12 +343,12 @@ static void test_callback(void) ...@@ -338,12 +343,12 @@ static void test_callback(void)
TVINSERTSTRUCTA ins; TVINSERTSTRUCTA ins;
TVITEMA tvi; TVITEMA tvi;
CHAR test_string[] = "Test_string"; CHAR test_string[] = "Test_string";
static const CHAR test2A[] = "TEST2";
CHAR buf[128]; CHAR buf[128];
LRESULT ret; LRESULT ret;
HWND hTree; HWND hTree;
hTree = create_treeview_control(); hTree = create_treeview_control();
fill_tree(hTree);
ret = TreeView_DeleteAllItems(hTree); ret = TreeView_DeleteAllItems(hTree);
ok(ret == TRUE, "ret\n"); ok(ret == TRUE, "ret\n");
...@@ -396,6 +401,16 @@ static void test_callback(void) ...@@ -396,6 +401,16 @@ static void test_callback(void)
ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Item text mismatch %s vs %s\n", ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Item text mismatch %s vs %s\n",
tvi.pszText, TEST_CALLBACK_TEXT); tvi.pszText, TEST_CALLBACK_TEXT);
/* notification handler changed A->W */
g_disp_A_to_W = TRUE;
tvi.hItem = hItem2;
memset(buf, 0, sizeof(buf));
ret = TreeView_GetItem(hTree, &tvi);
ok(ret == TRUE, "got %ld\n", ret);
ok(strcmp(tvi.pszText, test2A) == 0, "got %s, expected %s\n",
tvi.pszText, test2A);
g_disp_A_to_W = FALSE;
DestroyWindow(hTree); DestroyWindow(hTree);
} }
...@@ -854,10 +869,6 @@ static void test_get_set_unicodeformat(void) ...@@ -854,10 +869,6 @@ static void test_get_set_unicodeformat(void)
DestroyWindow(hTree); DestroyWindow(hTree);
} }
static TVITEMA g_item_expanding, g_item_expanded;
static BOOL g_get_from_expand;
static BOOL g_get_rect_in_expand;
static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
static LONG defwndproc_counter = 0; static LONG defwndproc_counter = 0;
...@@ -913,6 +924,14 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, ...@@ -913,6 +924,14 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
if (disp->item.mask & TVIF_TEXT) { if (disp->item.mask & TVIF_TEXT) {
lstrcpyn(disp->item.pszText, TEST_CALLBACK_TEXT, disp->item.cchTextMax); lstrcpyn(disp->item.pszText, TEST_CALLBACK_TEXT, disp->item.cchTextMax);
} }
if (g_disp_A_to_W && (disp->item.mask & TVIF_TEXT)) {
static const WCHAR testW[] = {'T','E','S','T','2',0};
disp->hdr.code = TVN_GETDISPINFOW;
memcpy(disp->item.pszText, testW, sizeof(testW));
}
break; break;
} }
case TVN_ENDLABELEDIT: return TRUE; case TVN_ENDLABELEDIT: return TRUE;
......
...@@ -728,6 +728,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, ...@@ -728,6 +728,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
wineItem->textWidth = 0; wineItem->textWidth = 0;
TREEVIEW_SendRealNotify(infoPtr, callback.hdr.idFrom, (LPARAM)&callback); TREEVIEW_SendRealNotify(infoPtr, callback.hdr.idFrom, (LPARAM)&callback);
TRACE("resulting code 0x%08x\n", callback.hdr.code);
/* It may have changed due to a call to SetItem. */ /* It may have changed due to a call to SetItem. */
mask &= wineItem->callbackMask; mask &= wineItem->callbackMask;
...@@ -735,7 +736,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, ...@@ -735,7 +736,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
if ((mask & TVIF_TEXT) && callback.item.pszText != wineItem->pszText) if ((mask & TVIF_TEXT) && callback.item.pszText != wineItem->pszText)
{ {
/* Instead of copying text into our buffer user specified its own */ /* Instead of copying text into our buffer user specified its own */
if (!infoPtr->bNtfUnicode) { if (!infoPtr->bNtfUnicode && (callback.hdr.code == TVN_GETDISPINFOA)) {
LPWSTR newText; LPWSTR newText;
int buflen; int buflen;
int len = MultiByteToWideChar( CP_ACP, 0, int len = MultiByteToWideChar( CP_ACP, 0,
...@@ -776,7 +777,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, ...@@ -776,7 +777,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
} }
else if (mask & TVIF_TEXT) { else if (mask & TVIF_TEXT) {
/* User put text into our buffer, that is ok unless A string */ /* User put text into our buffer, that is ok unless A string */
if (!infoPtr->bNtfUnicode) { if (!infoPtr->bNtfUnicode && (callback.hdr.code == TVN_GETDISPINFOA)) {
LPWSTR newText; LPWSTR newText;
LPWSTR oldText = NULL; LPWSTR oldText = NULL;
int buflen; int buflen;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment