Commit 5bc1a8de authored by Duane Clark's avatar Duane Clark Committed by Alexandre Julliard

treeview: Scrolling does not cause label being edited to lose focus.

parent 909425d9
......@@ -32,7 +32,7 @@
static HWND hMainWnd;
static HWND hTree;
static HWND hTree, hEdit;
static HTREEITEM hRoot, hChild;
static int pos = 0;
......@@ -140,6 +140,37 @@ static void DoTest2(void)
ok(!strcmp(sequence, "1(nR)nR23(RC)RC45(CR)CR."), "root-child select test\n");
}
static void DoFocusTest(void)
{
TVINSERTSTRUCTA ins;
static CHAR child1[] = "Edit",
child2[] = "A really long string";
HTREEITEM hChild1, hChild2;
/* This test verifies that when a label is being edited, scrolling
* the treeview does not cause the label to lose focus. To test
* this, first some additional entries are added to generate
* scrollbars.
*/
ins.hParent = hRoot;
ins.hInsertAfter = hChild;
U(ins).item.mask = TVIF_TEXT;
U(ins).item.pszText = child1;
hChild1 = TreeView_InsertItem(hTree, &ins);
assert(hChild1);
ins.hInsertAfter = hChild1;
U(ins).item.mask = TVIF_TEXT;
U(ins).item.pszText = child2;
hChild2 = TreeView_InsertItem(hTree, &ins);
assert(hChild2);
ShowWindow(hMainWnd,SW_SHOW);
SendMessageW(hTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hChild);
hEdit = TreeView_EditLabel(hTree, hChild);
ScrollWindowEx(hTree, -10, 0, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN);
ok(GetFocus() == hEdit, "Edit control should have focus\n");
}
static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
......@@ -147,8 +178,8 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
case WM_CREATE:
{
hTree = CreateWindowExA(WS_EX_CLIENTEDGE, WC_TREEVIEWA, NULL, WS_CHILD|WS_VISIBLE|
TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS,
0, 0, 300, 50, hWnd, (HMENU)100, GetModuleHandleA(0), 0);
TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS|TVS_EDITLABELS,
0, 0, 120, 100, hWnd, (HMENU)100, GetModuleHandleA(0), 0);
SetFocus(hTree);
return 0;
......@@ -214,12 +245,13 @@ START_TEST(treeview)
hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
CW_USEDEFAULT, CW_USEDEFAULT, 130, 105, NULL, NULL, GetModuleHandleA(NULL), 0);
GetClientRect(hMainWnd, &rc);
FillRoot();
DoTest1();
DoTest2();
DoFocusTest();
PostMessageA(hMainWnd, WM_CLOSE, 0, 0);
while(GetMessageA(&msg,0,0,0)) {
......
......@@ -4654,9 +4654,6 @@ TREEVIEW_VScroll(TREEVIEW_INFO *infoPtr, WPARAM wParam)
if (!(infoPtr->uInternalStatus & TV_VSCROLL))
return 0;
if (infoPtr->hwndEdit)
SetFocus(infoPtr->hwnd);
if (!oldFirstVisible)
{
assert(infoPtr->root->firstChild == NULL);
......@@ -4727,9 +4724,6 @@ TREEVIEW_HScroll(TREEVIEW_INFO *infoPtr, WPARAM wParam)
if (!(infoPtr->uInternalStatus & TV_HSCROLL))
return FALSE;
if (infoPtr->hwndEdit)
SetFocus(infoPtr->hwnd);
maxWidth = infoPtr->treeWidth - infoPtr->clientWidth;
/* shall never occur */
if (maxWidth <= 0)
......@@ -5619,6 +5613,11 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
else
return 0;
case WM_NCLBUTTONDOWN:
if (infoPtr->hwndEdit)
SetFocus(infoPtr->hwnd);
goto def;
case WM_NCPAINT:
if (nc_paint (infoPtr, (HRGN)wParam))
return 0;
......
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