?
Solved

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

Posted on 2004-08-20
5
Medium Priority
?
723 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 375 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

Technology Partners: 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

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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

765 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