Solved

Logic and Device coordinates

Posted on 1997-04-22
1
684 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Window placement 17 75
twoTwo  challenge 35 93
withoutTen challenge 14 100
Remove Password Protection from pdf (with password) using an command line executable 5 30
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 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