A
A
Alex Serov2015-06-01 19:50:19
C++ / C#
Alex Serov, 2015-06-01 19:50:19

How to organize drawing in a persistent memory context in MFC?

I want to make a Canvas class, inherited from CWnd, which would support my drawing methods.
I want to draw in memory, and in the OnPaint () handler, just copy the picture from the memory context to the CPaintDC context.
What classes to use to store the drawing context in memory, and how to initially initialize it? All the classes I found require that CPaintDC& in their constructor, but I want to paint in a memory context not in an OnPaint() handler.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2015-06-01
@gibsonman01

CDC, initialize as CreateCompatibleDC from the final CClientDC
and CBitmap, create as CreateCompatibleBitmap from the same CClientDC and select into the created CDC.
Draw in CDC as usual, then copy from it using BitBlt.

A
AxisPod, 2015-06-02
@AxisPod

www.codeproject.com/Articles/33/Flicker-Free-Drawi... Tweak the work of CMemDC, it will probably be easier to understand on the finished code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question