CFanatic

Go Back   CFanatic > Programming > Win32 Programming

Join CFanatic Forum Now

Repainting erases the drawing topic posted under Win32 Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2008, 12:50 AM
Junior Member
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jigar_bhatt16183 is on a distinguished road
| More
Repainting erases the drawing

Hi friends.

I m new in this forum as well as in win32

I am creating a small application for my knowledge. But i m facing problem.

When i move or minimize or maximize the window, the drawing above it erases. So plz help me to solve this matter
Thanx in adv.

Bye
Reply With Quote
  #2  
Old 02-19-2008, 05:34 AM
shabbir's Avatar
Administrator
 
Join Date: Sep 2006
Posts: 1,164
Thanks: 57
Thanked 63 Times in 44 Posts
shabbir has a spectacular aura aboutshabbir has a spectacular aura about
| More
Re: Repainting erases the drawing

Handle the paint event to draw the things again.
Reply With Quote
  #3  
Old 02-19-2008, 11:09 PM
Junior Member
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jigar_bhatt16183 is on a distinguished road
| More
Re: Repainting erases the drawing

How it is possible? All drawing work done in paint or any saving and retrieving technique is available?

Please tell me.
Reply With Quote
  #4  
Old 10-05-2008, 10:39 PM
Junior Member
 
Join Date: Oct 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
johny10151981 is on a distinguished road
| More
Re: Repainting erases the drawing

do your all Drawing under WM_PAINT message. your painting wont loose again. you can try another way. is CreateCompatibleDC() func by using this you can create a DC, which is virtual and resident in mem, than you can save it to hard disk as bitmap and restore it or directly can paint on your woindow what ever you like

Last edited by johny10151981; 10-05-2008 at 10:41 PM.
Reply With Quote
  #5  
Old 10-06-2008, 03:38 AM
Senior Member
 
Join Date: Jul 2008
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
xpi0t0s is on a distinguished road
| More
Re: Repainting erases the drawing

Alternatively (to solve the original problem directly), don't specify CS_HREDRAW or CS_VREDRAW in your window class style.

However you would still lose everything (unless you specify CS_SAVEBITS, I think; I've never used this) if some other window appeared in front of yours.

So Shabbir's answer is the best; draw everything in the WM_PAINT response function, and if you do any drawing outside that for some reason, make sure the WM_PAINT code will also draw that same stuff should it be called on.

Drawing everything in WM_PAINT is really advantageous because you can make use of Windows' clipping functionality automatically; it's more or less transparent. If you want to make a small change in the display, update the data that the drawing depends on, then InvalidateRect just the rectangle that contains the change. Then call UpdateWindow, specifying bErase=FALSE, will then invoke WM_PAINT with the invalidated rectangle specified in the clipping region, and any drawing that occurs in WM_PAINT will be clipped to that rectangle, so the update will occur really quickly.

Calling UpdateWindow with bErase=TRUE should be avoided wherever possible. Blanking everything before you start means you're guaranteed to get screen flicker. It may be valid in some cases, but instead of using bErase=TRUE use double buffering, where you draw everything to an initially blank memory bitmap, then blat that straight onto the screen.

For an example of extremely crappy erase-before-redraw, have a look at FreeCommander (a Windows Commander clone, an otherwise quite good program); go to a directory with lots of files in, then use Shift-cursor keys to select a whole bunch of files; watch it flicker like a bad 1960's B-movie. Repeat the same selection in Windows Explorer and you'll see it's stacks nicer, because they don't erase the whole rectangle first.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Crop from one bitmap into another without drawing on screen Tekri Win32 Programming 2 01-18-2009 02:45 AM
drawing mohr's circle in C++ jc23 OpenGL Programming 0 09-30-2006 12:04 PM
drawing mohr's circle in opengl jc23 OpenGL Programming 1 09-30-2006 05:57 AM
drawing mohr's circle in opengl jc23 OpenGL Programming 0 09-30-2006 05:35 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:19 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board