Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Bạn cũng có thể được định nghĩa một chức năng thành viên trong một file cpp. Hoặc kê khai của nó trong một tập tin h. Trực tiếp bằng cách kích chuột phải vào tên của nó trong cửa sổ Xem lớp và chọn mục thích hợp từ menu ngữ cảnh xuất hiện. | Chapter 13 A declaration has been added for each of the handlers that you ve specified in the Event Handler wizard dialog box. Each of the function declarations has been prefixed with afx_msg to indicate that it is a message handler. The Event Handler wizard also automatically updates the message map in your CSketcherDoc class implementation with the new message handlers. If you take a look in the file SketcherDoc.cpp you ll see the message map as shown here BEGIN_MESSAGE_MAP CSketcherDoc CDocument ON_COMMAND ID_COLOR_BLACK OnColorBlack ON_COMMAND ID_COLOR_RED OnColorRed ON_COMMAND ID_COLOR_GREEN OnColorGreen ON_COMMAND ID_COLOR_BLUE OnColorBlue ON_COMMAND ID_ELEMENT_LINE OnElementLine ON_COMMAND ID_ELEMENT_RECTANGLE OnElementRectangle ON_COMMAND ID_ELEMENT_CIRCLE OnElementCircle ON_COMMAND ID_ELEMENT_CURVE OnElementCurve END_MESSAGE_MAP The Event Handler wizard has added an ON_COMMAND macro for each of the handlers that you have identified. This associates the handler name with the message ID so for example the member function OnColorBlack is called to service a COMMAND message for the menu item with the ID ID_COLOR_BLACK. Each of the handlers generated by the Event Handler wizard is just a skeleton. For example take a look at the code provided for OnColorBlue . This is also defined in the file SketcherDoc.cpp so you can scroll down to find it or go directly to it by switching to the Class View and double-clicking the function name after expanding the tree for the class CSketcherDoc make sure that the file is saved first void CSketcherDoc OnColorBlue TODO Add your command handler code here As you can see the handler takes no arguments and returns nothing. It also does nothing at the moment but this is hardly surprising because the Event Handler wizard has no way of knowing what you want to do with these messages Coding Menu Message Functions Now consider what you should do with the COMMAND messages for our new menu items. I said earlier that you want to record the