National Taiwan University Department of Computer Science and

  • Slides: 7
Download presentation
National Taiwan University Department of Computer Science and Information Engineering Message Mapping Mechanisms in

National Taiwan University Department of Computer Science and Information Engineering Message Mapping Mechanisms in MFC and Other Applications in Visual C++ Speaker: Yao-Ting Huang Advisor: Kun-Mao Chao National Taiwan University Department of Computer Science & Information Engineering Algorithms and Computational Biology Lab. 2021/2/20

National Taiwan University Department of Computer Science and Information Engineering Message Mapping in Writing

National Taiwan University Department of Computer Science and Information Engineering Message Mapping in Writing MFC n When using a Windows program, there are many types of messages (events) generated. u n n e. g. , mouse clicked, key pressed, or window closed. When writing a Windows program, it is essential to assign the handling function to each corresponding message. The message processing is a switch-like statement. switch(message){ case WM_MOUSEMOVE: //handle mouse movement here. break; case WM_CLOSE: //handle window close here. break; } 2

National Taiwan University Department of Computer Science and Information Engineering Message Mapping in Writing

National Taiwan University Department of Computer Science and Information Engineering Message Mapping in Writing MFC n MFC avoids the detail message processing by providing Message Map. u u n There are default handling functions assigned to common messages. You can add your own handling function to specific message. e. g. , BEGIN_MESSAGE_MAP(CTest 2 App, CWin. App) ON_COMMAND(ID_APP_ABOUT, On. App. About) ON_COMMAND(ID_FILE_NEW, CWin. App: : On. File. New) ON_COMMAND(ID_FILE_OPEN, CWin. App: : On. File. Open) ON_COMMAND(ID_FILE_PRINT_SETUP, CWin. App: : On. File. Print. Setup) END_MESSAGE_MAP() 3

National Taiwan University Department of Computer Science and Information Engineering Message Mapping in Writing

National Taiwan University Department of Computer Science and Information Engineering Message Mapping in Writing MFC n n n When you choose to open a file, the CWin. App: : On. File. Open function will be invoked, which will popup a file dialog to the user. You can use the class wizard in Visual C++ to manage the message map. 4 See an example in Visual C++.

National Taiwan University Department of Computer Science and Information Engineering Building Other Applications by

National Taiwan University Department of Computer Science and Information Engineering Building Other Applications by Visual C++ n You can create other types of applications by selecting different projects in Visual C++. Database project: Allow you to write SQL to manage a database. u Internet Server API (ISAPI) Extension Wizard: Allow you to write Windows socket, email, and other Internet applications. u MFC Active. X Control Wizard: Allow you to write Active. X control which can be embedded into dialog, VB program, or WWW pages, to offer additional functionalities. u 5

National Taiwan University Department of Computer Science and Information Engineering Remind of Homework #3

National Taiwan University Department of Computer Science and Information Engineering Remind of Homework #3 n n n Write a program that prompts the user to input the boiling point in degree Celsius. The program should output the substance corresponding to the boiling point listed in the table. The program should output the message “substance unknown” when it does not match any substance. For the details, please refer to the slide of last week. The due date is 11/4. 6

National Taiwan University Department of Computer Science and Information Engineering Outline of Lecture Today

National Taiwan University Department of Computer Science and Information Engineering Outline of Lecture Today n n Manipulate the message map in a MFC application. Demo of your Homework #2. u Please make sure your program is ready to execute. 7