Solved

Drawing control on memory device context

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 862
iSeries DB2 Query 2 100
no14 challenge 14 76
Problem to event 3 120
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

742 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