Click here to Skip to main content
15,909,590 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all ,
actually , I am developing a paint brush like App , now I draw a figure on the view , now when I draw another figure (i am drawing free hand using mouse drag )the first figure disappers . so how can I protect that i dont loose the one figure at the cost of another...?
Posted

1 solution

i suppose you are handling all your drawing logics in OnMouseMove(), OnLButtonDown(),OnLButtonUp() etc.
You need move all your drawings to OnDraw() function of your view class.
from OnMouseMove(), OnLButtonDown(),OnLButtonUp() etc, you need to update the data members and call Invalidate() function.
you need to keep all drawing information of previuos drawing as data member of your document class.
means
suppose you are drawing
line 1 with blue brush. coordinates are (3,2)->(50,5)
now drawing line 2 with red brush.coordinates are (6,7)->(70,75)
you need to keep all these information such as blue brsuh, red brush, cooridates value etc in document object.
draw line 1. save its details to document.
and when it is time to draw line 2
get line 1 details from document class, draw line 1, then draw line 2, store line 2 details to document class.like that
otherwsie previuos drawings will be lost in window repainting.
this is just an idea of how to do it
You need to design the classes and structures well and start doing.
otherwsie you may face a lot of problmes in between and have to start doing from beginning.
 
Share this answer
 
Comments
iampradeepsharma 8-Jun-11 23:15pm    
now how to take that code in the ondraw method ....?
Resmi Anna 10-Jun-11 7:23am    
Call Invalidate().this will invokde your OnDraw()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900