Solved

Drawing control on memory device context

Posted on 1997-11-02
1
627 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 62
mixString challenge 36 125
wait notify demo infinite loop 3 114
modThree challenge 4 92
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

825 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