comctl32: listview: set the style in WM_CREATE (fixes bug #7494)
Mikołaj Zalewski
mikolaj at zalewski.pl
Sun Feb 25 05:53:57 CST 2007
Also move all the style-related code to LISTVIEW_Create. This is needed
for an app that uses a different listview style by subclassing the
control and changing WM_CREATE lParam->style field. The attached
testcase passes under current wine as showing/hiding the header used the
lpcs->style but even this test may be useful to avoid regressions.
-------------- next part --------------
From 90f1007e214c373799466c87fc0b282f9de3925a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Sun, 25 Feb 2007 12:38:08 +0100
Subject: [PATCH] comctl32: listview: set the style in WM_CREATE (fixes bug #7494)
---
dlls/comctl32/listview.c | 11 +++++------
dlls/comctl32/tests/listview.c | 7 +++++++
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index aca548f..e9476ea 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -7702,7 +7702,6 @@ static CALLBACK VOID LISTVIEW_DelayedEditItem(HWND hwnd, UINT uMsg, UINT_PTR idE
static LRESULT LISTVIEW_NCCreate(HWND hwnd, const CREATESTRUCTW *lpcs)
{
LISTVIEW_INFO *infoPtr;
- UINT uView = lpcs->style & LVS_TYPEMASK;
LOGFONTW logFont;
TRACE("(lpcs=%p)\n", lpcs);
@@ -7714,7 +7713,7 @@ static LRESULT LISTVIEW_NCCreate(HWND hwnd, const CREATESTRUCTW *lpcs)
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
infoPtr->hwndSelf = hwnd;
- infoPtr->dwStyle = lpcs->style;
+ infoPtr->dwStyle = lpcs->style; /* Note: may be changed in WM_CREATE */
/* determine the type of structures to use */
infoPtr->hwndNotify = lpcs->hwndParent;
/* infoPtr->notifyFormat will be filled in WM_CREATE */
@@ -7752,10 +7751,6 @@ static LRESULT LISTVIEW_NCCreate(HWND hwnd, const CREATESTRUCTW *lpcs)
if (!(infoPtr->hdpaPosX = DPA_Create(10))) goto fail;
if (!(infoPtr->hdpaPosY = DPA_Create(10))) goto fail;
if (!(infoPtr->hdpaColumns = DPA_Create(10))) goto fail;
-
- /* initialize the icon sizes */
- set_icon_size(&infoPtr->iconSize, infoPtr->himlNormal, uView != LVS_ICON);
- set_icon_size(&infoPtr->iconStateSize, infoPtr->himlState, TRUE);
return TRUE;
fail:
@@ -7789,6 +7784,7 @@ static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
TRACE("(lpcs=%p)\n", lpcs);
+ infoPtr->dwStyle = lpcs->style;
infoPtr->notifyFormat = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT,
(WPARAM)infoPtr->hwndSelf, (LPARAM)NF_QUERY);
@@ -7824,6 +7820,9 @@ static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
OpenThemeData(hwnd, themeClass);
+ /* initialize the icon sizes */
+ set_icon_size(&infoPtr->iconSize, infoPtr->himlNormal, uView != LVS_ICON);
+ set_icon_size(&infoPtr->iconStateSize, infoPtr->himlState, TRUE);
return 0;
}
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 6c1a3b1..8850091 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -350,13 +350,18 @@ static HIMAGELIST test_create_imagelist;
static LRESULT CALLBACK create_test_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CREATE)
+ {
+ LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
+ lpcs->style |= LVS_REPORT;
SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)test_create_imagelist);
+ }
return CallWindowProc(listviewWndProc, hwnd, uMsg, wParam, lParam);
}
static void test_create()
{
HWND hList;
+ HWND hHeader;
WNDCLASSEX cls;
cls.cbSize = sizeof(WNDCLASSEX);
ok(GetClassInfoEx(GetModuleHandle(NULL), "SysListView32", &cls), "GetClassInfoEx failed\n");
@@ -368,6 +373,8 @@ static void test_create()
test_create_imagelist = ImageList_Create(16, 16, 0, 5, 10);
hList = CreateWindow("MyListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), 0);
ok((HIMAGELIST)SendMessage(hList, LVM_GETIMAGELIST, 0, 0) == test_create_imagelist, "Image list not obtained\n");
+ hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
+ ok(IsWindow(hHeader) && IsWindowVisible(hHeader), "Listview not in report mode\n");
DestroyWindow(hList);
}
--
1.4.4.2
More information about the wine-patches
mailing list