Solved

problem in drawing.

Posted on 2002-06-23
7
227 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 154
Use of condition with 'serial' in ansible 2 99
Unix Command -- Challenging  question 7 105
Notepad++ Question 11 21
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

740 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