tailieunhanh - Ivor Horton’s BeginningVisual C++ 2008 phần 8

mặc dù các cửa sổ cuộn OK, nếu bạn cố gắng để thu hút nhiều hơn các yếu tố với quan điểm cuộn, mọi thứ không làm việc như họ nên. Các yếu tố xuất hiện trong một vị trí khác nhau từ nơi mà bạn vẽ chúng và họ không hiển thị đúng. Chuyện gì đang xảy ra? | Chapter 16 Creating the Document and Improving the View although the window scrolls OK if you try to draw more elements with the view scrolled things don t work as they should. The elements appear in a different position from where you draw them and they re not displayed properly. What s going on Logical Coordinates and Client Coordinates The problem is the coordinate systems that you re using and that plural is deliberate. You ve actually been using two coordinate systems in all the examples up to now although you may not have noticed. As you saw in the previous chapter when you call a function such as LineTo it assumes that the arguments passed are logical coordinates. The function is a member of the CDC class that defines a device context and the device context has its own system of logical coordinates. The mapping mode which is a property of the device context determines what the unit of measurement is for the coordinates when you draw something. The coordinate data that you receive along with the mouse messages on the other hand has nothing to do with the device context or the CDC object and outside of a device context logical coordinates don t apply. The points passed to the OnLButtonDown and OnMouseMove handlers have coordinates that are always in device units that is pixels and are measured relative to the upper-left corner of the client area. These are referred to as client coordinates. Similarly when you call lnvalidateRect the rectangle is assumed to be defined in terms of client coordinates. In MM_TEXT mode the client coordinates and the logical coordinates in the device context are both in units of pixels and so they re the same as long as you don t scroll the window. In all the previous examples there was no scrolling so everything worked without any problems. With the latest version of Sketcher it all works fine until you scroll the view whereupon the logical coordinates origin the 0 0 point is moved by the scrolling mechanism so it s no longer in .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.