Solved

problem in drawing.

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

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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 97
Generic progress indicator 6 117
Best tools for Backup and restore of Wordpress site 6 57
Line meaning 9 88
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…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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