Controls: Handle WM_PRINTCLIENT

Michael Kaufmann hallo at michael-kaufmann.ch
Sun Oct 30 09:09:57 CST 2005


WM_PRINTCLIENT can be implemented in the same manner as WM_PAINT, but 
one must not call BeginPaint and EndPaint (MSDN docs).

The message also takes a number of flags, which are the same as the 
flags for WM_PRINT. For WM_PRINTCLIENT, these flags don't make sense. 
The Windows native controls and all example code that I've found ignore 
them, including code by book author Feng Yuan ( 
http://www.fengyuan.com/article/wmprint.html ).

I've noticed that controls must not call SelectClipRgn in 
WM_PRINTCLIENT, because they would replace the clip region set by WM_PRINT.

Changelog:
  - Handle WM_PRINTCLIENT
  - Don't use SelectClipRgn in WM_PRINTCLIENT

-------------- next part --------------
Index: dlls/comctl32/animate.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/animate.c,v
retrieving revision 1.69
diff -u -r1.69 animate.c
--- dlls/comctl32/animate.c	18 Sep 2005 11:12:00 -0000	1.69
+++ dlls/comctl32/animate.c	30 Oct 2005 14:44:48 -0000
@@ -899,6 +899,7 @@
     case WM_TIMER:
         return ANIMATE_Timer(infoPtr);
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
         {
             /* the animation isn't playing, or has not decompressed
Index: dlls/comctl32/datetime.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/datetime.c,v
retrieving revision 1.61
diff -u -r1.61 datetime.c
--- dlls/comctl32/datetime.c	22 Aug 2005 09:20:36 -0000	1.61
+++ dlls/comctl32/datetime.c	30 Oct 2005 14:44:48 -0000
@@ -1284,6 +1284,7 @@
     case WM_GETDLGCODE:
         return DLGC_WANTARROWS | DLGC_WANTCHARS;
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
         return DATETIME_Paint (infoPtr, (HDC)wParam);
 
Index: dlls/comctl32/header.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/header.c,v
retrieving revision 1.85
diff -u -r1.85 header.c
--- dlls/comctl32/header.c	28 Oct 2005 10:40:27 -0000	1.85
+++ dlls/comctl32/header.c	30 Oct 2005 14:44:49 -0000
@@ -1782,6 +1782,7 @@
         case WM_THEMECHANGED:
             return HEADER_ThemeChanged (hwnd);
 
+        case WM_PRINTCLIENT:
         case WM_PAINT:
             return HEADER_Paint (hwnd, wParam);
 
Index: dlls/comctl32/hotkey.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/hotkey.c,v
retrieving revision 1.34
diff -u -r1.34 hotkey.c
--- dlls/comctl32/hotkey.c	6 May 2005 15:44:32 -0000	1.34
+++ dlls/comctl32/hotkey.c	30 Oct 2005 14:44:50 -0000
@@ -516,6 +516,7 @@
 	case WM_NCCREATE:
 	    return HOTKEY_NCCreate (hwnd, (LPCREATESTRUCTW)lParam);
 
+	case WM_PRINTCLIENT:
 	case WM_PAINT:
 	    HOTKEY_Paint(infoPtr, (HDC)wParam);
 	    return 0;
Index: dlls/comctl32/listview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/listview.c,v
retrieving revision 1.433
diff -u -r1.433 listview.c
--- dlls/comctl32/listview.c	21 Oct 2005 15:49:36 -0000	1.433
+++ dlls/comctl32/listview.c	30 Oct 2005 14:44:55 -0000
@@ -8563,35 +8563,6 @@
 
 /***
  * DESCRIPTION:
- * Paints/Repaints the listview control.
- *
- * PARAMETER(S):
- * [I] infoPtr : valid pointer to the listview structure
- * [I] hdc : device context handle
- * [I] options : drawing options
- *
- * RETURN:
- * Zero
- */
-static LRESULT LISTVIEW_PrintClient(LISTVIEW_INFO *infoPtr, HDC hdc, DWORD options)
-{
-    FIXME("Partial Stub: (hdc=%p options=0x%08lx)\n", hdc, options);
-
-    if ((options & PRF_CHECKVISIBLE) && !IsWindowVisible(infoPtr->hwndSelf))
-        return 0;
-
-    if (options & PRF_ERASEBKGND)
-        LISTVIEW_EraseBkgnd(infoPtr, hdc);
-
-    if (options & PRF_CLIENT)
-        LISTVIEW_Paint(infoPtr, hdc);
-
-    return 0;
-}
-
-
-/***
- * DESCRIPTION:
  * Processes double click messages (right mouse button).
  *
  * PARAMETER(S):
@@ -9449,8 +9420,6 @@
     return LISTVIEW_NotifyFormat(infoPtr, (HWND)wParam, (INT)lParam);
 
   case WM_PRINTCLIENT:
-    return LISTVIEW_PrintClient(infoPtr, (HDC)wParam, (DWORD)lParam);
-
   case WM_PAINT:
     return LISTVIEW_Paint(infoPtr, (HDC)wParam);
 
Index: dlls/comctl32/monthcal.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/monthcal.c,v
retrieving revision 1.60
diff -u -r1.60 monthcal.c
--- dlls/comctl32/monthcal.c	11 Aug 2005 17:05:00 -0000	1.60
+++ dlls/comctl32/monthcal.c	30 Oct 2005 14:44:56 -0000
@@ -2007,6 +2007,7 @@
   case WM_LBUTTONUP:
     return MONTHCAL_LButtonUp(infoPtr, lParam);
 
+  case WM_PRINTCLIENT:
   case WM_PAINT:
     return MONTHCAL_Paint(infoPtr, wParam);
 
Index: dlls/comctl32/pager.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/pager.c,v
retrieving revision 1.55
diff -u -r1.55 pager.c
--- dlls/comctl32/pager.c	25 Jun 2005 17:55:15 -0000	1.55
+++ dlls/comctl32/pager.c	30 Oct 2005 14:44:57 -0000
@@ -34,6 +34,8 @@
  *      PGS_DRAGNDROP
  *    Notifications:
  *      PGN_HOTITEMCHANGE
+ *    Messages:
+ *      WM_PRINT and/or WM_PRINTCLIENT
  *
  * TESTING:
  *    Tested primarily with the controlspy Pager application.
Index: dlls/comctl32/progress.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/progress.c,v
retrieving revision 1.43
diff -u -r1.43 progress.c
--- dlls/comctl32/progress.c	23 Aug 2005 10:02:25 -0000	1.43
+++ dlls/comctl32/progress.c	30 Oct 2005 14:44:57 -0000
@@ -627,6 +627,7 @@
     case WM_SETFONT:
         return (LRESULT)PROGRESS_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
         return PROGRESS_Paint (infoPtr, (HDC)wParam);
 
Index: dlls/comctl32/propsheet.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/propsheet.c,v
retrieving revision 1.136
diff -u -r1.136 propsheet.c
--- dlls/comctl32/propsheet.c	12 Sep 2005 22:07:54 -0000	1.136
+++ dlls/comctl32/propsheet.c	30 Oct 2005 14:45:00 -0000
@@ -3455,6 +3455,7 @@
       return TRUE;
     }
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
       PROPSHEET_Paint(hwnd, (HDC)wParam);
       return TRUE;
Index: dlls/comctl32/rebar.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/rebar.c,v
retrieving revision 1.112
diff -u -r1.112 rebar.c
--- dlls/comctl32/rebar.c	6 Oct 2005 11:38:45 -0000	1.112
+++ dlls/comctl32/rebar.c	30 Oct 2005 14:45:02 -0000
@@ -50,7 +50,6 @@
  *   - WM_LBUTTONDBLCLK
  *   - WM_MEASUREITEM
  *   - WM_PALETTECHANGED
- *   - WM_PRINTCLIENT
  *   - WM_QUERYNEWPALETTE
  *   - WM_RBUTTONDOWN
  *   - WM_RBUTTONUP
@@ -4768,11 +4767,11 @@
         case WM_NOTIFYFORMAT:
 	    return REBAR_NotifyFormat (infoPtr, wParam, lParam);
 
+	case WM_PRINTCLIENT:
 	case WM_PAINT:
 	    return REBAR_Paint (infoPtr, wParam, lParam);
 
 /*      case WM_PALETTECHANGED: supported according to ControlSpy */
-/*      case WM_PRINTCLIENT:    supported according to ControlSpy */
 /*      case WM_QUERYNEWPALETTE:supported according to ControlSpy */
 /*      case WM_RBUTTONDOWN:    supported according to ControlSpy */
 /*      case WM_RBUTTONUP:      supported according to ControlSpy */
Index: dlls/comctl32/status.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/status.c,v
retrieving revision 1.76
diff -u -r1.76 status.c
--- dlls/comctl32/status.c	6 Oct 2005 11:38:45 -0000	1.76
+++ dlls/comctl32/status.c	30 Oct 2005 14:45:03 -0000
@@ -1342,6 +1342,7 @@
 	case WM_NOTIFYFORMAT:
 	    return STATUSBAR_NotifyFormat(infoPtr, (HWND)wParam, (INT)lParam);
 
+	case WM_PRINTCLIENT:
 	case WM_PAINT:
 	    return STATUSBAR_WMPaint (infoPtr, (HDC)wParam);
 
Index: dlls/comctl32/syslink.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/syslink.c,v
retrieving revision 1.13
diff -u -r1.13 syslink.c
--- dlls/comctl32/syslink.c	11 Apr 2005 12:58:30 -0000	1.13
+++ dlls/comctl32/syslink.c	30 Oct 2005 14:45:04 -0000
@@ -1463,6 +1463,7 @@
         return DefWindowProcW( hwnd, message, wParam, lParam );
 
     switch(message) {
+    case WM_PRINTCLIENT:
     case WM_PAINT:
         return SYSLINK_Paint (infoPtr, (HDC)wParam);
 
Index: dlls/comctl32/tab.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/tab.c,v
retrieving revision 1.120
diff -u -r1.120 tab.c
--- dlls/comctl32/tab.c	6 Oct 2005 11:38:45 -0000	1.120
+++ dlls/comctl32/tab.c	30 Oct 2005 14:45:06 -0000
@@ -3284,6 +3284,7 @@
     case WM_MOUSEMOVE:
       return TAB_MouseMove (infoPtr, wParam, lParam);
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
       return TAB_Paint (infoPtr, (HDC)wParam);
 
Index: dlls/comctl32/toolbar.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/toolbar.c,v
retrieving revision 1.227
diff -u -r1.227 toolbar.c
--- dlls/comctl32/toolbar.c	21 Oct 2005 15:45:11 -0000	1.227
+++ dlls/comctl32/toolbar.c	30 Oct 2005 14:45:10 -0000
@@ -7234,6 +7234,7 @@
 	case WM_NOTIFYFORMAT:
 	    return TOOLBAR_NotifyFormat (infoPtr, wParam, lParam);
 
+	case WM_PRINTCLIENT:
 	case WM_PAINT:
 	    return TOOLBAR_Paint (hwnd, wParam);
 
Index: dlls/comctl32/tooltips.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/tooltips.c,v
retrieving revision 1.79
diff -u -r1.79 tooltips.c
--- dlls/comctl32/tooltips.c	30 Aug 2005 10:07:17 -0000	1.79
+++ dlls/comctl32/tooltips.c	30 Oct 2005 14:45:12 -0000
@@ -2782,6 +2782,7 @@
 	case WM_NOTIFYFORMAT:
 	    return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam);
 
+	case WM_PRINTCLIENT:
 	case WM_PAINT:
 	    return TOOLTIPS_Paint (hwnd, wParam, lParam);
 
Index: dlls/comctl32/trackbar.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/trackbar.c,v
retrieving revision 1.67
diff -u -r1.67 trackbar.c
--- dlls/comctl32/trackbar.c	15 Aug 2005 10:24:00 -0000	1.67
+++ dlls/comctl32/trackbar.c	30 Oct 2005 14:45:13 -0000
@@ -1878,6 +1878,7 @@
     case WM_MOUSEMOVE:
         return TRACKBAR_MouseMove (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
         return TRACKBAR_Paint (infoPtr, (HDC)wParam);
 
Index: dlls/comctl32/treeview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/treeview.c,v
retrieving revision 1.175
diff -u -r1.175 treeview.c
--- dlls/comctl32/treeview.c	12 Sep 2005 22:07:53 -0000	1.175
+++ dlls/comctl32/treeview.c	30 Oct 2005 14:45:16 -0000
@@ -5629,11 +5629,10 @@
     case WM_NOTIFYFORMAT:
 	return TREEVIEW_NotifyFormat(infoPtr, (HWND)wParam, (UINT)lParam);
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
 	return TREEVIEW_Paint(infoPtr, wParam);
 
-	/* WM_PRINTCLIENT */
-
     case WM_RBUTTONDOWN:
 	return TREEVIEW_RButtonDown(infoPtr, lParam);
 
Index: dlls/comctl32/updown.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/updown.c,v
retrieving revision 1.70
diff -u -r1.70 updown.c
--- dlls/comctl32/updown.c	25 Jul 2005 11:23:42 -0000	1.70
+++ dlls/comctl32/updown.c	30 Oct 2005 14:45:16 -0000
@@ -934,6 +934,7 @@
 		return UPDOWN_KeyPressed(infoPtr, (int)wParam);
 	    break;
 
+	case WM_PRINTCLIENT:
 	case WM_PAINT:
 	    return UPDOWN_Paint (infoPtr, (HDC)wParam);
 
Index: dlls/user/button.c
===================================================================
RCS file: /home/wine/wine/dlls/user/button.c,v
retrieving revision 1.10
diff -u -r1.10 button.c
--- dlls/user/button.c	19 Oct 2005 18:30:14 -0000	1.10
+++ dlls/user/button.c	30 Oct 2005 14:45:20 -0000
@@ -279,6 +279,7 @@
         }
         return 1;
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
         if (btnPaintFunc[btn_type])
         {
@@ -777,7 +778,6 @@
 {
     RECT     rc, focus_rect, r;
     UINT     dtFlags, uState;
-    HRGN     hRgn;
     HPEN     hOldPen;
     HBRUSH   hOldBrush;
     INT      oldBkMode;
@@ -834,16 +834,13 @@
     if (pushedState)
        OffsetRect(&r, 1, 1);
 
-    hRgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
-    SelectClipRgn(hDC, hRgn);
+    IntersectClipRect(hDC, rc.left, rc.top, rc.right, rc.bottom);
 
     oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
 
     BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r);
 
     SetTextColor( hDC, oldTxtColor );
-    SelectClipRgn(hDC, 0);
-    DeleteObject(hRgn);
 
     if (state & BUTTON_HASFOCUS)
     {
@@ -868,7 +865,6 @@
     HBRUSH hBrush;
     int delta;
     UINT dtFlags;
-    HRGN hRgn;
     HFONT hFont;
     LONG state = get_button_state( hwnd );
     LONG style = GetWindowLongW( hwnd, GWL_STYLE );
@@ -970,9 +966,8 @@
 
     if (dtFlags == (UINT)-1L) /* Noting to draw */
 	return;
-    hRgn = CreateRectRgn(client.left, client.top, client.right, client.bottom);
-    SelectClipRgn(hDC, hRgn);
-    DeleteObject(hRgn);
+
+    IntersectClipRect(hDC, client.left, client.top, client.right, client.bottom);
 
     if (action == ODA_DRAWENTIRE)
 	BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rtext);
@@ -986,7 +981,6 @@
 	IntersectRect(&rtext, &rtext, &client);
 	DrawFocusRect( hDC, &rtext );
     }
-    SelectClipRgn(hDC, 0);
 }
 
 
Index: dlls/user/edit.c
===================================================================
RCS file: /home/wine/wine/dlls/user/edit.c,v
retrieving revision 1.40
diff -u -r1.40 edit.c
--- dlls/user/edit.c	18 Oct 2005 12:01:38 -0000	1.40
+++ dlls/user/edit.c	30 Oct 2005 14:45:24 -0000
@@ -920,6 +920,7 @@
 		result = EDIT_WM_MouseMove(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
 		break;
 
+	case WM_PRINTCLIENT:
 	case WM_PAINT:
 	        EDIT_WM_Paint(es, (HDC)wParam);
 		break;
Index: dlls/user/listbox.c
===================================================================
RCS file: /home/wine/wine/dlls/user/listbox.c,v
retrieving revision 1.24
diff -u -r1.24 listbox.c
--- dlls/user/listbox.c	27 Oct 2005 18:28:23 -0000	1.24
+++ dlls/user/listbox.c	30 Oct 2005 14:45:26 -0000
@@ -3013,6 +3013,7 @@
     case WM_GETDLGCODE:
         return DLGC_WANTARROWS | DLGC_WANTCHARS;
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
         {
             PAINTSTRUCT ps;
Index: dlls/user/static.c
===================================================================
RCS file: /home/wine/wine/dlls/user/static.c,v
retrieving revision 1.8
diff -u -r1.8 static.c
--- dlls/user/static.c	21 Jun 2005 20:53:14 -0000	1.8
+++ dlls/user/static.c	30 Oct 2005 14:45:28 -0000
@@ -282,6 +282,7 @@
         else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
                               DefWindowProcA(hwnd, uMsg, wParam, lParam);
 
+    case WM_PRINTCLIENT:
     case WM_PAINT:
         {
             PAINTSTRUCT ps;


More information about the wine-patches mailing list