Solved

Custom Rendering of the non-client area in response to a WM_PRINT message

Posted on 2004-08-20
5
705 Views
Last Modified: 2013-11-20
According to the MSDN docs on the WM_PRINT message, here's what happens when a WM_PRINT message is received and processed by the DefWindowProc function:

The DefWindowProc function processes this message based on which drawing option is specified: if PRF_CHECKVISIBLE is specified and the window is not visible, do nothing, if PRF_NONCLIENT is specified, draw the nonclient area in the specified device context, if PRF_ERASEBKGND is specified, send the window a WM_ERASEBKGND message, if PRF_PRINTCLIENT is specified, send the window a WM_PRINTCLIENT message, if PRF_PRINTCHILDREN is set, send each visible child window a WM_PRINT message, if PRF_OWNED is set, send each visible owned window a WM_PRINT message.

If I want to do custom drawing of the background or the client area, I can respond properly to the WM_ERASEBKGD and WM_PRINTCLIENT messages, but what about custom rendering of the non-client area? What message can I override/process to handle that? WM_NCPAINT is *not* called. Is there something else that is that I can hook into and add my custom NC drawing code?
0
Comment
Question by:pcommons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 125 total points
ID: 11855093
from your question
if PRF_NONCLIENT is specified, draw the nonclient area in the specified device context
acording to that you do it there and then in the supplied dc
0
 

Author Comment

by:pcommons
ID: 11855174
Yeah, I understand that I could override the handling of WM_PRINT, but DefWindowProc seems to do everything so nicely, it seems "weird" that it doesn't provide a message that I can handle to deal with the non-client drawing, when it does everything else. That's what I'm specifically looking for, if anyone knows what that message would be...
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 11855705
Help is (usually) accurate - follow what it says.  That is a message you receive.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 11857939
WM_PRINT is used to draw window into some device context. It may be used, for example, for printing or saving of window to image file. You cannot use WM_PRINT to draw window itself on the screen.
To customize drawing of non-client window area, handle WM_NCPAINT message. See also GetDCEx function.
If WM_NCPAINT is not called, possibly you try to handle it in incorrect place. Use Spy++ to see what window you need. For example, in SDI MFC application, I guess, WM_NCPAINT is not called for the view class, but it is called for the frame class.
0
 

Author Comment

by:pcommons
ID: 11888807
The focus of my question was on printing to a DC, not painting to the screen; that said, although it's funny (to me) that there isn't a separate message to PRINT the non-client area, Andy does suggest the solution that I think is best. Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 115
How to know only "File created" with EventLog 3 35
string initialization in java 11 120
sumHeights  challenge 17 82
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question