Midterm Exam 2 1 Sun Moon Lake Marathon
- Slides: 43
Midterm Exam (2) 1
Sun Moon Lake Marathon p October 29, 2017 (Sunday) p http: //www. eventpal. com. tw/sml 2017 english. html Race Events: 42 km or 29 km p Enrollment Deadline: 5 pm, June 15, 2017 p 3
Chapter 12 Windows Programming with the Microsoft Foundation Classes 5
Elements of a Window (P. 581) p Let us go through them to be sure we have a common understanding of what the terms mean. n n n parent window, child window border, size grip title bar, title bar icon, status bar p system menu § click the title bar icon, § or right-click the title bar n client area p p n x increasing from left to right, y increasing from top to bottom minimize, maximize, close buttons 6
The Microsoft Foundation Classes (P. 605) p MFC are a set of predefined classes. n These classes provides an object-oriented approach to Windows programming that encapsulates the Windows API. Easy to use p Data Members & Member Functions p n You will apply techniques you learned from the previous chapters, particularly those involving class inheritance and virtual functions. 7
MFC Notation (P. 605) p p All the classes in MFC have names beginning with C n CDocument n CView Data members of an MFC class are prefixed with m_ n m_lp. Cmd. Line p Explicitly showing the type of a variable in its name was important in the C environment, because of the lack of type checking § Hungarian notation (P. 813, P. 836) p p However, C++ has strong type checking, so this kind of notation isn’t essential, and will not be used heavily in this book. However, the p prefix for pointers will be retained because this helps the code more readable. 8
The Document/View Concept in MFC p Document n p (P. 614) – the collection of data A document is not limited to text. It could be the data for a game, or the distribution of orange trees in California. View – how the data is to be displayed in a window, and how the user can interact with it. n A document object can have as many view objects associated with it as you want. 9
A Document with Two Views (P. 615) 10
Document Interfaces p SDI – Single Document Interface n p Your application only open one document at a time. MDI – Multiple Document Interface. n n Multiple documents can be opened in your application. Each document is displayed in a child window of the application window. 11
Document Template Classes p MFC has two classes for defining document templates: n n CSingle. Doc. Template for SDI CMulti. Doc. Tempalte for MDI 12
Linking a Document and Its Views p MFC incorporates a mechanism for integrating n a document with its views a document object automatically maintains a list of pointers to its associated views p a view object has a pointer to the document p n a frame window with a view p a frame window has a pointer to the currently active view object 13
Document Templates (P. 616) p A document template object creates document objects and frame window objects n p p If you have two or more documents of the same type, you need only one document template to manage them. View of a document are created by a frame window object. The application object creates the document template object. 14
Your Application and MFC (P. 617) p Four basic classes that will appear in almost all your MFC -based Windows applications: n n The application class The document class The view class The frame window class 15
Document / View Classes p Your document class is derived from the CDocument class in the MFC library n n p You will add your own data members to store items that your application requires, and member functions to support processing of that data. Your view class is derived from the CView class. n You define how data in your document will be displayed in a window. 16
The Application Class The class CWin. App is fundamental to any Windows program written using MFC. p An object of this class includes everything necessary for starting, initializing, running and closing the application. p class CMy. App: public CWin. App { public: virtual BOOL Init. Instance(); }; 17
The Window Class p The CFrame. Wnd class provides everything for creating and managing a window for your application n All you need to add to the derived window class is a constructor. class CMy. Wnd: public CFrame. Wnd { public: // Constructor CMy. Wnd() { Create(0, L”Our Dumb MFC Application”); } }; 18
Creating MFC Applications You don’t need to worry about which classes you need to have in your program. p Visual C++ 2013 will take care of that for you. p 19
Installing Visual C++ 2013 p p You will receive a DVD-ROM. Circulate that between your classmates and install Visual Studio 2013 to your PC. The Visual Studio purchased by NCNU only covers the license for computers in classrooms and laboratories. It does not cover students’ computers at home/dormitory. Department of CSIE purchases an additional license, so that CSIE students can install and use Visual Studio 2013 on their own computer at home, even after graduated. Please do not disseminate the software to your friends arbitrarily. If Microsoft detects that we violate the license, our license may be terminated totally. 20
Run the Installation Program 21
You Need Not Sign-in. 22
Choose Visual C++ 23
Start Visual Studio 24
Create a New MFC Project p Create a new project n n p File > New > Project Crtl + Shift + N Choose MFC as the project type and MFC Application as the template. 25
Creating an SDI Application The appearance of an SDI application 26
Share DLL (Dynamic Link Library) p Share DLL n n n p (Chapter 20) Your program links to MFC library routines at run-time. This reduces the size of the executable file. When several programs are running simultaneously, they share a single copy of the library in memory. Statically linked n n The library is included in the executable program you built. This runs slightly faster, with the cost that the file size is larger. 27
User Interface Features 28
Advanced Features p The File menu will has the following items n n n p Page Setup Print Preview Print The Application wizard also provides code to support these functions. 29
Generated Classes 30
Choose CEdit. View as the Base class 31
Code Generated by the MFC Application Wizard p All the files are stored in the Text. Editor project folder n p p Class definitions are in. h files. Resource files are in the res sub-folder to the project folder. n p which is a sub-folder to the solution folder with the same name. Bitmaps, icons, menus, and dialog boxes. Member functions are defined in. cpp files. 32
Viewing Classes p You see four basic classes: n n p CMain. Frame CText. Editor. App CText. Editor. Doc CText. Editor. View Global Functions and Variables contains two definitions: n n the. App – the application object indicators – an array of indicators recording the status of caps lock, num lock and scroll lock. 33
Project Property p Right-click Text. Editor project in the Solution Explorer pane, and select Property from the pop-up menu: 34
Creating an Executable Module p To compile and link the program Build > Build Solution n Ctrl + Shift + B n <F 7> n n Click the Build icon in the Toolbar p In case you did not see them, choose VIEW – Toolbars - Build 35
Precompiled Header Files (P. 637, P. 37) p p The first time you compile and link a program, it will take some time. The second and subsequent times it should be faster. A feature of Visual C++ 2013 called precompiled headers will save the output from compiling header files in a special file with the extension. pch. On subsequent builds, this file is reused if the source in the headers has not changed, thus saving the compilation time for the headers. n This is another advantage for you to define your classes 36 in different. h files.
Running the Program p Ctrl + F 5 p This is a fully functioning, simple text editor. n All the items under all menus are fully operational p p p Save / Open files Cut / Paste text Print Toolbar Tool tip System menu 37
Floating/Dockable Solution Explorer 38
Adding Debug code p Solution Configurations n n p Debug Release #ifdef _DEBUG //Debug code #endif
Solution Configurations 40
Debug Mode vs. Release Mode #include <iostream> using std: : cin; using std: : cout; using std: : endl; int main() { int sum = 0; int i; for (i=1; i<=10; i++) { sum += i; #ifdef _DEBUG cout << "i = " << i << endl; #endif } cout << sum << endl; return 0; } 41
Same Trick on STU p clang++ -D_DEBUG a. cpp n p Debug mode clang++ a. cpp n Release mode 42
Exercises p P. 635 n Ex 4: Create the simple text editor program. Build both debug and release versions, and examine the types and sizes of the files produced in each case. p p n Q: Where is the EXE file? Note that debug and release versions are located under different directories. Q: What is the function of the ilk files? Ex 5: Generate the text editor application several times, trying different window styles from the User Interface Features in Application wizard. p p Minimize/Maximize box Printing and print preview 45
- Sun moon lake marathon
- Database systems midterm exam
- Introduction to computer science midterm exam test
- Exam midterm
- Data mining midterm exam with solutions
- Midterm exam format
- Homework app
- Research methodology midterm exam
- Apes midterm practice test
- Ap english language and composition midterm exam
- Ap chemistry midterm exam
- Html midterm exam
- World history semester 2 final exam review
- American literature midterm exam
- Operating systems midterm
- English 9 midterm exam
- What is a midterm
- Algebra 2 midterm exam
- Mid term test english 10
- Algebra 1 midterm review
- English 11 midterm exam
- Xiao team comp
- Introduction to computer science midterm exam
- Bisexts
- Nlp midterm exam
- Grva midterm exam
- Business law midterm answers
- Midterm exam announcement
- Which moon phase occurs directly before a new moon
- Home.hiwaay.net/ krcool/astro/moon/moon tides/
- What phase is this
- Which moon phase occurs directly before a new moon
- Moon sister moon calendar
- Lake powell and lake mead
- Oligotrophic vs eutrophic
- Lake powell and lake mead
- Dangdang ay cordillera
- Spider web tessellation
- How does the sun moon and earth work together
- How do the sun moon and earth interact
- Sun earth
- 14 rajlok in gujarati
- How the sun moon and earth work together
- What is personification