Solved

Drawing in a View window problem

Posted on 2004-05-01
6
156 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 30

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now