Solved

Drawing control on memory device context

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

13 Experts available now in Live!

Get 1:1 Help Now