From 9cc12d2879905cf626bdfc91699a680519c9a1fb Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 21 Apr 2009 05:29:22 -0400 Subject: [PATCH] comctl32/listview: Header should be created when LVS_EX_HEADERDRAGDROP set. --- dlls/comctl32/listview.c | 7 ++++++- dlls/comctl32/tests/listview.c | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 8f1489f2148..a4899c61fe3 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -7268,7 +7268,12 @@ static DWORD LISTVIEW_SetExtendedListViewStyle(LISTVIEW_INFO *infoPtr, DWORD dwM if((infoPtr->dwLvExStyle ^ dwOldExStyle) & LVS_EX_HEADERDRAGDROP) { - DWORD dwStyle = GetWindowLongW(infoPtr->hwndHeader, GWL_STYLE); + DWORD dwStyle; + + /* if not already created */ + LISTVIEW_CreateHeader(infoPtr); + + dwStyle = GetWindowLongW(infoPtr->hwndHeader, GWL_STYLE); if (infoPtr->dwLvExStyle & LVS_EX_HEADERDRAGDROP) dwStyle |= HDS_DRAGDROP; else diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index b85dbfb9cb9..6f205fd897c 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -965,6 +965,17 @@ static void test_create(void) /* HDS_DRAGDROP set by default */ ok(GetWindowLongPtr(hHeader, GWL_STYLE) & HDS_DRAGDROP, "Expected header to have HDS_DRAGDROP\n"); DestroyWindow(hList); + + /* setting LVS_EX_HEADERDRAGDROP creates header */ + hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL, + GetModuleHandle(NULL), 0); + ok(!IsWindow(hHeader), "Header shouldn't be created\n"); + ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n"); + SendMessage(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_HEADERDRAGDROP); + hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0); + ok(IsWindow(hHeader), "Header should be created\n"); + ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n"); + DestroyWindow(hList); } static void test_redraw(void)