Solved

Drawing in a View window problem

Posted on 2004-05-01
6
162 Views
Last Modified: 2013-11-20
Hello,

I want to draw in the View window of a MFC application. This can be done with LineTo, MoveTo, etc. Now when I want to draw a rect, that moves when my mouse moves, the old rects are still there. I can update de view window with pDoc->UpdateAllViews()  but this causes my application to crasch sometimes and the View window flickers with this 'animation'.

Is there another appraoch how  you can avoid this problem?

Herman
0
Comment
Question by:Hermy
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 25 total points
ID: 10970261
In OnMouseMove change rectangle coordinates (keep them in member variables) and invalidate window. But don't draw in OnMouseMove, all drawing code should be in OnDraw. To prevent flickering, use memory device context.
Check out MFC sample DRAWCLI.
0
 
LVL 31

Assisted Solution

by:Zoppo
Zoppo earned 25 total points
ID: 10971528
Hi Hermy,


maybe you should even check out the CRectTracker class ... it's especailly made for implementing selection rectangles
and can be moved and resized ... in MSDN it's usage is well described.


ZOPPO
0
 
LVL 7

Expert Comment

by:vijay_visana
ID: 10974851
first you store coordinates of rectangle drawn last time.
draw the rectangle with this coordinates but with background color and then draw
new rectangle with your forground color and save coordinates
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 55
move a line in eclipse 3 109
Window placement 17 94
wordappend challenge 8 220
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

685 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