Solved

Drawing control on memory device context

Posted on 1997-11-02
1
621 Views
Last Modified: 2013-11-20
I need control( for example button) to draw itself on memory device context.
I created this device context and call ::SendMessage(hwndControl, WM_PAINT,
(WPARAM)memDC.GetSafeHdc(), 0). The problem is that in this case invalid
rectangle is empty and control doesn't paint itself. If I specify
InvalidateRect(NULL) before sending message then control does paint itself
on memory DC but it also paints itself on window DC. I also tried to call
ValidateRect(NULL) just after sending message but it doesn't help. How can I
force control to draw itself on memory DC only?
            Thanks.
0
Comment
Question by:galkin
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1309223
Send WM_PRINT message instead of WM_PAINT.

WM_PRINT
The WM_PRINT message is sent to a window to request that it draw itself in the specified device context, most commonly in a printer device context.

WM_PRINT
hdc = (HDC) wParam;
uFlags = lParam;
 
Parameters
hdc
Identifies the device context to draw in.

uFlags
Specifies the drawing options. This parameter can be one or more of these flags:Value Meaning
PRF_CHECKVISIBLE Draw the window only if it is visible.
PRF_CHILDREN Draw all visible children windows.
PRF_CLIENT Draw the client area of the window.
PRF_ERASEBKGND Erase the background before drawing the window.
PRF_NONCLIENT Draw the nonclient area of the window.
PRF_OWNED Draw all owned windows.


Remarks
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 given 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.

QuickInfo
  Windows NT: Use version 4.0 and later.
  Windows: Use Windows 95 and later.
  Header: Declared in winuser.h.

See Also
Painting and Drawing Overview, Painting and Drawing Messages, DefWindowProc, WM_ERASEBKGND, WM_PRINTCLIENT

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 92
fizzArray  challenge 1 63
either24  challenge 19 90
x-bar in Google Sheets 2 26
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

16 Experts available now in Live!

Get 1:1 Help Now