Solved

Logic and Device coordinates

Posted on 1997-04-22
1
707 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
ID: 1301141
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 106
Tab names are off by one 5 54
Define unique primary key 9 95
Change owner from userA to server Local Administrators 7 71
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…
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

735 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