1, roughly speaking, Windows programming has two methods: A.WindWos C mode (SDK), SDK programming is to call the Windows API for programming; B.C way: ie packaging the SDK function, such as the MFC, BCB of VC, BCB OWL, etc. MFC is closed to all of these APIs and have more than 100 classes.
2, API, full name Application Program Interface, means the application programming interface (speaking that the API does not only refer to Windows, the API WINAPI supported by Windows). WinAPI is a programming interface for communication between applications and Windows. Windows offers thousands of API functions to facilitate programmers to write applications.
3, WinsDK program design is the Windows programming of the API mode. SDK, full name Software Developers Kit, meaning software development toolbox.
4, MFC, full name Microsoft Foundation Classes, pseudo-soft put WinAPI package library. It is a collection of classes that provides an object-oriented interface for programming by overwriting WINAPI. It makes Windows programmers to program the characteristics of the C -side object object, similar to the BCB's OWL, DELPHI VCL components. It provides the most cumbersome part of the SDK program to the programmer, making it focused on the implementation of the function. You may wish to imagine it into a library that is provided by TC.
5. Like the C program under DOS, the entry under Windows is a WinMain () function.
6. The role of WinMain (): Initialization, show, destroy application, etc. The first parameter: the current instance handle of the application. Second Parameters: The previous instance handle of the application, don't worry it, for Win32, it is generally null. Third parameters: Point line line parameters for any password. PSTR represents "pointer to string". The fourth parameter: It tells how the application initializes the window, such as maximizing, minimizing state.
7. Handle: The handle in the standard C library is used to output the file input. In the Windows environment, the handle is used to identify the project, including: *. Module (Module) *. Mission (Task) *. / File (file) *. Memory block (block of memory) *. Menu *. Control * .Font *. Resource, including icon (icon), cursor, string, etc. * .GDi object (GDI Object) , Including bitmap, brush, metafile, palette, brush (PEN), regional (Device Context). In the Windows program, it is not used to identify a memory block, file, task, or dynamic load module. On the contrary, the Windows API assigns a determined handle to these items, and returns the handle to the application, and then passes through the handle. operating.
Window handle: The system is uniquely identified a window through the window handle, and a window handle must be specified when sending a message indicating that the message is received by that window. Each window will have its own window process, so the user's input will be processed correctly.
8, all naming adopts Hungarian representation. If the prefix of the message uses the MSG. The handle uses H. Function uses Fn, etc.
9, mainfrm.cpp, mainfrm.h: These two files will derive the CMAINFRAME class from the CFrameWnd (SDI application) or CMDIFrameWnd (MDI application). If the corresponding options are selected in the AppWizard's Application Options page (step 4 in steps), the CMAINFRAME class will process the creation of the toolbar buttons and status bars. The mainfrm.cpp file also contains object IDs for the default toolbar buttons provided by the MFC application - called Buttons arrays. 10. The DOS program mainly uses the order, process-driven programming method. Order, process-driven procedures have a significant beginning, obvious process and a significant end, so the program can directly control the order of program events or processes. Although there are also many methods of processing anomalies in the procedure of the order of procedure, such exception handling is still sequential, process-driven structure.
11. The driving method of Windows is that event drivers are controlled by the order of events, but controlled by events, all events are disorderless. As a programmer, when you write a program, you don't know which button first, you don't know which news will trigger the program first. Your task is to sort and manage messages that are developing applications or messages to receive. The event driver design is unfolded around the generation and processing of the message, and a message is a message about an event that occurs.
12, Windows programs are at least two main program, is a WinMain (), int WINAPI WinMain (HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // command line int nCmdShow // Show State); the other is the window process function WndProc, its function prototype: long far pascal wndproc (hwnd hwnd, word message, word wparam, long lparam);
13, window function and callback function: In Windows, the application is required to complete the specified action by requesting Windows, and the API function of this communication task is Windows's corresponding window function WNDPROC. The application does not call any window functions directly, but waiting for the Windows call window function to request a task or return information. To ensure that Windows calls this window function, this function must first register with Windows, and then callback when Windows implement the corresponding operation, so the window function is also called a callback function. WndProc is a primary return function, and Windows has at least one callback function. Typical callback functions have window processes, dialog procedures, and hook functions. In fact, there may be more than one window process. For example, each different window classes have a window process corresponding to it.
15. Instance: In Windows, you can run the same application multiple times, ie run multiple copies, each copy is called an "instance".
16, c runtime function library:
Like its name, the run type information mainly has the COJECT class and the CruntimeClass class to store the COJECT class and the derived class information, 1. Basic situation of the class: If the name of the class, the storage space Used to run the type of the class to determine .2.ms on C standard, add dynamically created class object functions, which is the dynamic creation of time, 3. Serialization process .The OS Does not know, MAIN (), SO C-Runtime Is First Called and Transfer Control To Mainit Also Provide Library for Common Usage, SUCH AS MATH FUNCTIONS17, WinMain () The call agreement is Pascal.
Here Pascal is a call agreement, because this method is earliered by PASCAL, so this is called. In the C Language Reference in MSDN, the chapter of Calling Conventions is invoified.
Again: Microsoft heavy defines a number of agreed types, which can make the code easier cross-platform or cross-compiler. In fact, the call agreement is to solve two problems, which are all for stack operations: 1. The order of parameter transmission (essentially is the order of stack) 2. Who is responsible for pining (caller or calling object) a function of a function, definition, and invoke methods in the implementation are generally consistent.
The definition of the WinAPI identifier is: #define WinAPI __stdcall, __stdcall refers to a way to access the Window call function, which is how to access function parameters in the heap. Many Windows API function calls declares that __stdcall mode.
18, "or" operation of the bits (operators | ") combine several constants to control the buttons and icons whose message window displayed.
19. In the Windows application, each window must be subordinate to a window class, the window class defines the properties of the window, such as its style, icon, mouse pointer, menu name, and window procedure name. Window types are templates that define window properties, including window style, mouse shapes, menus, etc., window species also specify window functions for all window messages in this class. You can only create Windows according to window types. One or more windows of the application. When you create a window, you can also specify the unique features of the window. Window types are referred to as window classes, window classes cannot be retrofitted. After establishing window classes, you must register with Windows. Creation window class is Define a structural variable with the WNDCLASS structure.
20. Visual C provides an Alt F8 function key to make file specifications, and correctly indent the selected code rows, according to the surrounding code rows. This button often allows the file to keep the file (Note, the ALT F8 function key to the two consecutive case statements will process errors, cannot be normalized).
21. Message: A message consists of a message name (UINT), and two parameters (WPARAM, LPARAM). The system will send a message to a window when the user has changed or the state of the window changes.
22, a typical application should be active in the "Frame Window". A frame window is a full-featured main window, and the user can change the size, minimize, maximize, and so on.
23. Message Mechanism: The system will maintain one or more messages, all generated messages are placed back or inserted into the queue. Each message will be taken in the queue, and the message is sent to the message loop of the program with the window according to the message receiving handle. Each running program has its own message loop, gets its own message in the loop and calls the corresponding window process based on the handle of the received window. When there is no message, the message loop will give the control to the system so Windows can simultaneously perform multiple tasks.
24. Preparatory head file: VC program generally included head files are more complicated, if each progressive analysis can spend a lot of time, so VC default settings are the first time to compile all header files, generate .pch files This file is very large, but you can save a lot of time every time you compile. If this file is deleted, VC will automatically generate it when compiling. STDAFX.H is the file that must be included in the class of each MFC program, which is generally generated by AppWizard, including the definition necessary to compile the MFC class. 25. Windows supports two types of dialogs: Mode and Non-Mode dialog. Once the Mode dialog box appears on the screen, only the rest of the application on the screen can respond when it exits. When the Mode dialog box appears on the screen, the rest of the program can also respond, it is like floating above.
26, single document interface (SDI), only one frame window. The MDI system allows users to view multiple documents at the same time.