[PATCH v2 5/7] comctl32/button: Implement NM_CUSTOMDRAW for BS_USERBUTTON

Gabriel Ivăncescu gabrielopcode at gmail.com
Tue Mar 5 07:13:27 CST 2019


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

The behavior seems odd but it's needed to pass the tests just like Windows
does.

 dlls/comctl32/button.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index 1637e05..16b36d4 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -37,7 +37,6 @@
  *  - BN_PAINT
  *  + BN_SETFOCUS: is it OK?
  *  - BN_UNPUSHED/BN_UNHILITE
- *  - NM_CUSTOMDRAW
  *
  *  Structures/Macros/Definitions
  *  - NMBCHOTITEM
@@ -1864,7 +1863,9 @@ static void UB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
 {
     RECT rc;
     HBRUSH hBrush;
+    LRESULT cdrf;
     HFONT hFont;
+    NMCUSTOMDRAW nmcd;
     LONG state = infoPtr->state;
     HWND parent;
 
@@ -1878,10 +1879,39 @@ static void UB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
     if (!hBrush) /* did the app forget to call defwindowproc ? */
         hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
 
+    if (action == ODA_FOCUS || (state & BST_FOCUS))
+    {
+        init_custom_draw(&nmcd, infoPtr, hDC, &rc);
+
+        /* Send erase notifications */
+        cdrf = SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+        if (cdrf & CDRF_SKIPDEFAULT) goto notify;
+    }
+
     FillRect( hDC, &rc, hBrush );
     if (action == ODA_FOCUS || (state & BST_FOCUS))
-        DrawFocusRect( hDC, &rc );
+    {
+        if (cdrf & CDRF_NOTIFYPOSTERASE)
+        {
+            nmcd.dwDrawStage = CDDS_POSTERASE;
+            SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+        }
+
+        /* Send paint notifications */
+        nmcd.dwDrawStage = CDDS_PREPAINT;
+        cdrf = SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+        if (cdrf & CDRF_SKIPDEFAULT) goto notify;
+        if (cdrf & CDRF_NOTIFYPOSTPAINT)
+        {
+            nmcd.dwDrawStage = CDDS_POSTPAINT;
+            SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+        }
+
+        if (!(cdrf & CDRF_SKIPPOSTPAINT))
+            DrawFocusRect( hDC, &rc );
+    }
 
+notify:
     switch (action)
     {
     case ODA_FOCUS:
-- 
2.20.1




More information about the wine-devel mailing list