|
-
July 21st, 2005, 06:18 AM
#5
Re: Drawing Line
I think u r selecting the co-ordinate when user press left mouse button and when user moves pointer, u r drawing & erasing line. You need not frequently call the Invalidate(), ( You may call InvalidateRect()).
Supposing we have two CPoint object to denote the begin and end of line.
CPoint begin,end;
When user press left button, we initialize both (begin and end) with current value of co-oridantes.
And, whenver user move mouse, we write the code in OnMouseMove() to
1. Set the drawing mode R2_NOT using CDC::SetROP2.
2. Draw the line with previous co-ordinate to erase the previous line
3. Store the new co-ordinate in the end variable.
4. Draw the line.
And user release the mouse, we call InvalidateRect(). Rect area will determined by begin and end variables. and In OnDraw()/OnPaint() , we draw the line after setting the drawing mode R2_COPYPEN.
In OnPaint(), don't use CClientDC, use instead CPaintDC to draw.
Life is what u make it and u can make it more simple..........and woderful.
Rate is what give and it give me pleasure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|