Solved

problem in drawing.

Posted on 2002-06-23
7
193 Views
Last Modified: 2013-11-20
how to improve draw efficient?
how OnPaint()and OnDraw()do?

how to exchange data between to class?


thank you!
                     ¡ª¡ªÐ¦¿´·çÔÆ
0
Comment
Question by:ytsjiang
  • 2
7 Comments
 
LVL 3

Expert Comment

by:Crius
ID: 7104162
Drawing is fastest done by using BitBlt. When you render an image, render it into an HBITMAP or CBitmap, and in the OnDraw, use BitBlt to quickly transfer it to the screen.

As for exchanging data between classes, that depends on the data. If it's a big chunk of data, like a state, you can create a struct or class that handles the state data (contains all the variables), and pass that to your classes.
0
 
LVL 3

Accepted Solution

by:
Melange earned 100 total points
ID: 7111279
If you're not using BitBlt, but simply standard GDI calls to the screen, then make sure you only draw what's visible.

You can use RectVisible and/or GetClipBox functions from CDC to determine whether to draw that section or not.

The fastest method (as Crius mentioned) is to draw the image in the background and then BitBlt to the screen (also making sure to only BitBlt the visible rect). But, this takes more memory overhead (as you have to manage the background bitmap) and you have to take into account resizing of your window (if necessary).

It depends on your app which is better.
0
 
LVL 3

Expert Comment

by:Crius
ID: 10870315
I recommend accepting Melange. It is a more useful, and in depth answer.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
How to create frequencies of a variable from SAS dataset? 10 115
countEvens challenge 2 58
no14 challenge 14 56
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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

20 Experts available now in Live!

Get 1:1 Help Now