Solved

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

Posted on 2004-08-20
5
697 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 101
Host to IP 7 80
lucky13 challenge 11 155
JQuery serialize and unserialize 8 138
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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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