Solved

Drawing in a View window problem

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 108
Expand data scrubbing tool 13 32
Change to event 1 112
Problem to open Excel file 15 133
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 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