?
Solved

Drawing in a window?

Posted on 2000-02-21
6
Medium Priority
?
278 Views
Last Modified: 2013-11-20
Hi there
I would like to display the contents of a matrix in a window.
if I use code like this:

CClientDC dc;
//do drawing
dc.SetPixel(...);

It works of course, but I do not want to draw directly into the window. Instead I would like to draw to a CDC (i guess) and then blt the contents into the window causing all the changes to happen at once instead of one pixel at a time.

I have tried something like this:

CCLientDC dc;
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
//do drawing
dcMem.SetPixel(...)
dc.BitBlt(0, 0, Width, Height, &dcMem, 0, 0, SRCCOPY);

but it does not work (no change in the window)

How should I do it?
(maybe creating a bitmap - how?)

Jacob
0
Comment
Question by:jacobkristensen
[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
  • 5
6 Comments
 
LVL 5

Accepted Solution

by:
Wyn earned 200 total points
ID: 2542370
The problem is you must select a bitmap into the Memory Device Context.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2542385
Use the CreateCompatibleBitmap().
Code here:
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2542394
CCLientDC dc;
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmp;
bmp.CreateCompatibleBitmap(&dc,1,1);
CBitmap* pOldBmp = dcMem.SelectObject( &bmp );
//do drawing
dcMem.SetPixel(...)
dc.BitBlt(0, 0, Width, Height, &dcMem, 0, 0, SRCCOPY);
dcMem.SelectObject( pOldBmp );
dcMem.DeleteDC();
0
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!

 
LVL 5

Expert Comment

by:Wyn
ID: 2542401
Btw: the 1,1 above is imaginary.
0
 
LVL 1

Author Comment

by:jacobkristensen
ID: 2543134
Great! Just what I needed
Thank you Wyn

Jacob
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2544486
You are welcome:)
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 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