Solved

problem in drawing.

Posted on 2002-06-23
7
213 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 78
sum13 challenge 24 107
wait notify demo infinite loop 3 114
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 591
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

831 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