[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 744
  • Last Modified:

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

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
pcommons
Asked:
pcommons
  • 2
  • 2
1 Solution
 
AndyAinscowCommented:
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
 
pcommonsAuthor Commented:
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
 
AndyAinscowCommented:
Help is (usually) accurate - follow what it says.  That is a message you receive.
0
 
AlexFMCommented:
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
 
pcommonsAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now