[2/3] comctl32/listview: Notify parent with WM_MEASUREITEM on control creation

Nikolay Sivov bunglehead at gmail.com
Mon Jun 22 18:51:20 CDT 2009


Changelog:
    - Notify parent with WM_MEASUREITEM on control creation

>From 75738f1f462e1737cc0a878001ceee7bf7a0179e Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Mon, 22 Jun 2009 22:04:41 +0400
Subject: Notify parent with WM_MEASUREITEM on control creation

---
 dlls/comctl32/listview.c       |   27 +++++++++++++++++----------
 dlls/comctl32/tests/listview.c |    2 +-
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index f0a294e..0e22848 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -1027,6 +1027,20 @@ static inline DWORD notify_postpaint (const LISTVIEW_INFO *infoPtr, NMLVCUSTOMDR
     return notify_customdraw(infoPtr, CDDS_POSTPAINT, lpnmlvcd);
 }
 
+static void notify_measureitem(LISTVIEW_INFO *infoPtr)
+{
+    MEASUREITEMSTRUCT mis;
+    mis.CtlType = ODT_LISTVIEW;
+    mis.CtlID = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
+    mis.itemID = -1;
+    mis.itemWidth = 0;
+    mis.itemData = 0;
+    mis.itemHeight= infoPtr->nItemHeight;
+    SendMessageW(infoPtr->hwndNotify, WM_MEASUREITEM, mis.CtlID, (LPARAM)&mis);
+    if (infoPtr->nItemHeight != max(mis.itemHeight, 1))
+        infoPtr->nMeasureItemHeight = infoPtr->nItemHeight = max(mis.itemHeight, 1);
+}
+
 /******** Item iterator functions **********************************/
 
 static RANGES ranges_create(int count);
@@ -8654,6 +8668,8 @@ static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
       ShowWindow(infoPtr->hwndHeader, SW_SHOWNORMAL);
     }
     LISTVIEW_UpdateScroll(infoPtr);
+    /* send WM_MEASUREITEM notification */
+    if (infoPtr->dwStyle & LVS_OWNERDRAWFIXED) notify_measureitem(infoPtr);
   }
 
   OpenThemeData(hwnd, themeClass);
@@ -10776,16 +10792,7 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
       if ((infoPtr->dwStyle & LVS_OWNERDRAWFIXED) && (infoPtr->uView == LV_VIEW_DETAILS))
       {
-          MEASUREITEMSTRUCT mis;
-          mis.CtlType = ODT_LISTVIEW;
-          mis.CtlID = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
-          mis.itemID = -1;
-          mis.itemWidth = 0;
-          mis.itemData = 0;
-          mis.itemHeight= infoPtr->nItemHeight;
-          SendMessageW(infoPtr->hwndNotify, WM_MEASUREITEM, mis.CtlID, (LPARAM)&mis);
-          if (infoPtr->nItemHeight != max(mis.itemHeight, 1))
-              infoPtr->nMeasureItemHeight = infoPtr->nItemHeight = max(mis.itemHeight, 1);
+          notify_measureitem(infoPtr);
       }
 
 	  LISTVIEW_UpdateSize(infoPtr);
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 820acc6..38155b1 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -1405,7 +1405,7 @@ static void test_create(void)
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
     hList = create_listview_control(LVS_OWNERDRAWFIXED);
     ok_sequence(sequences, PARENT_SEQ_INDEX, create_ownerdrawfixed_parent_seq,
-                "created with LVS_OWNERDRAWFIXED - parent seq", TRUE);
+                "created with LVS_OWNERDRAWFIXED|LVS_REPORT - parent seq", FALSE);
     DestroyWindow(hList);
 }
 
-- 
1.5.6.5







More information about the wine-patches mailing list