Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Logic and Device coordinates

Posted on 1997-04-22
1
Medium Priority
?
736 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
rhgaracci earned 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

718 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