Solved

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

Posted on 2004-08-20
5
677 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
  • 2
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Help is (usually) accurate - follow what it says.  That is a message you receive.
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now