Solved

Logic and Device coordinates

Posted on 1997-04-22
1
674 Views
Last Modified: 2013-11-20

When I read Macrosoft Visual C++ Tutorials,
I found something I could not understand in the sample
"Scribble".
IF someone can help me with it I will be greatly appreciated.

There is a update() function designed, for efficience, when the user
draws a stoke in the view, this function will get the rectangle of
that stroke, and call CClienDC's LPtoDP() function, meanwhile sent
the rectangle (CRect) as the area needed to be update.
Then call InvalidateRect(..) to invalidate that rectangle.
Since the area on the screan is device context, so I understand
before invalidation the coordinates of rectangle need to be translated
from logic coordinates(read from file) to device coordinates.
The part I don't understand is that in the view's  onDraw(CDC* ),
what the program codes in tutorials do is firstly using
CDC::GetClipBox(&rectClip) to get the invalid area, then call
CDC::LPtoDP(&rectClip).
According to my understanding, before the invalid(need to be updated)
area is sent the coordinats are conversed from LP to DP, later after
calling CDC::GetClipBox(&rectClip), the coordinates
of rectClip( a rectangle) should also be device coordinates, why the
program has to call LPtoDP again to translate.
Are the coordinates changed back after the invalidation so when
the GetClipBox() is called the coordinates of that clip area still
has logic coordinates ?

Thanks a lot in advance,

Fang
0
Comment
Question by:fang041797
1 Comment
 
LVL 1

Accepted Solution

by:
rhgaracci earned 100 total points
Comment Utility
The RECT passed to Invalidate(...) is in client coordinates of the window.  Both GetUpdateRect() and GetClipBox return a RECT in logical coordinates.  Windows does the "DPtoLP" for you.  The clip box is the intersection of the update region and the visible area of the window.  The clip box may often be smaller than the invalidate region if, for instance a large part of the window is underneath another window.

The SCRIBBLE app converts logical coordinates to device coordinates in order to get pixel resolution for the IntersectRect() call.  This determines if a stroke needs to be redrawn.  The drawing, however, is still performed in logical coordinates by the CStroke objects.

I hope this answers your question.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now