Solved

problem in drawing.

Posted on 2002-06-23
7
230 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
[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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

707 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