TAILIEUCHUNG - Microsoft Visual C++ Windows Applications by Example phần 4

Một số hợp lý có thể được giao một số khác như lớp học quá tải toán tử gán. Nhà điều hành hoạt động trong một cách tương tự như các nhà xây dựng bản sao. Một sự khác biệt, tuy nhiên, rằng trong khi các nhà xây dựng không trả lại một giá trị, các nhà điều hành chuyển nhượng phải trở về đối tượng riêng của mình. | Ring A Demonstration Example void CRingView OnInitialUpdate CScrollView OnInitialUpdate CSize sizeTotal TODO calculate the total size of this view 100 SetScrollSizes MM_TEXT sizeTotal The function SetScrollSizes sets the scroll bars to reflect the chosen coordinate system. Let us chose the metric system with high resolution MM_HIMETRIC one logical unit is a hundredth of a millimeter. We set the page to correspond to a letter with a width of 216 millimetres and a height of 279 millimetres we set the height of a line to 5 millimeters and the height of a page to 50 millimeters. void CRingView OnInitialUpdate CScrollView OnInitialUpdate CSize sizeTotal CSize sizeLine 500 500 CSize sizePage 5000 5000 CSize sizeTotal 216000 27900 SetScrollSizes MM_HIMETRIC sizeTotal sizePage sizeLine We have now two problems the first one is that the mouse handler function OnLButtonDown receives its position in physical coordinates. It must be transformed into logical coordinates. In order to do so we first need to create and prepare our own device context. That is an object of the class CClientDC and call the function DPtoLP Device Point at Logical Point . void CRingView OnLButtonDown UINT nFlags CPoint point CRingDoc pDoc GetDocument ASSERT_VALID pDoc CClientDC dc this OnPrepareDC dc point pDoc- MouseDown point CScrollView OnLButtonDown nFlags point 114 Chapter 4 The second problem is that we have still specified the radius of the circles to 10 units. Those units are now hundredths of millimeters which means that the circles are hardly visible. We need to increase the radius in onDraw. Let us define a constant for that purpose. static const int RADIUS 500 class CRingDoc public CDocument . void CRingView OnDraw CDC pDC CRingDoc pDoc GetDocument ASSERT_VALID pDoc if pDoc return PointArray pointArray pDoc- GetPointArray ColorArray colorArray pDoc- GetColorArray int iSize int .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.