Solved

Drawing in a View window problem

Posted on 2004-05-01
6
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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

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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

729 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