TAILIEUCHUNG - Teach Yourself Visual C++ 6 in 21 Days phần 4

Những gì bạn có thể muốn làm vào thời điểm này, để củng cố sự hiểu biết của bạn về cách bạn có thể sử dụng những yếu tố này trong các ứng dụng của riêng bạn, là cố gắng thiết kế và xây dựng một vài ứng dụng đơn giản của riêng bạn. Bạn có thể sử dụng một loạt các điều khiển và thêm một số hộp thoại bổ sung | Creating Single Document Interface Applications 221 I Listing . The modified OnNewDocument FUNCTION. 1 BOOL CDay10Doc OnNewDocument 2 3 if CDocument OnNewDocument 4 return FALSE 5 6 TODO add reinitialization code here 7 SDI documents will reuse this document 8 9 10 MY CODE STARTS HERE 11 12 13 Initialize the color to black 14 m_nColor ID_COLOR_BLACK - ID_COLOR_BLACK 15 16 17 MY CODE ENDS HERE 18 19 20 return TRUE 21 10 7. Scroll down to the AddLine function and modify it as in Listing . Listing . The modified AddLine FUNCTION. 1 CLine CDay10Doc AddLine CPoint ptFrom CPoint ptTo 2 3 Create a new CLine object 4 CLine pLine new CLine ptFrom ptTo m_crColors m_nColor 5 try 6 7 Add the new line to the object array 8 pLine 9 Mark the document as dirty 10 SetModifiedFlag 11 12 Did we run into a memory exception 13 catch CMemoryException perr 14 15 Display a message for the user giving him or her the 16 bad news 17 AfxMessageBox Out of memory MB_ICONSTOP i MB_OK 18 Did we create a line object 19 if pLine continues I 222 Day 10 Listing . CONTINUED 20 21 22 23 24 25 26 27 28 29 Delete it delete pLine pLine null Delete the exception object perr- Delete return pLine 8. Add a new member function to the CDayl0Doc class. Specify the function type as UINT the declaration as GetColor and the access as public. 9. Edit the GetColor function adding the code in Listing . Listing . The GetColor FUNCTION. 1 UINT CDay10Doc GetColor 2 3 Return the current color 4 return ID_COLOR_BLACK m_nColor 5 In the OnNewDocument and the GetColor functions the color is added and subtracted from ID_COLOR_BLACK. This is the lowest numbered color menu ID when you add the menu entries. These calculations maintain the variable as a number between 0 and 7 but when working with the menus they allow comparison with the actual menu IDs. Modifying the Menu Now comes the fun part. You need to add a new pull-down menu to the main menu. You need to add menu entries for all

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.