1.1 Introduction to Windows
Windows is a GUI-based multi-task operating system. The program developed for this environment has the same appearance and command structure. This makes it easy for users to learn to use Windows applications. To help develop Windows applications, Windows provides a large number of built-in functions to facilitate the use of pop-up menus, scroll bars, dialogs, icons, and other friendly user interfaces.
Windows runs applications to handle video display, keyboard, mouse, printer, serial port, and system clock in a hardware-independent manner. The most important feature of Windows is its standardized graphical user interface. The unified interface uses images or icons to represent the commands and actions of disk drives, files, sub-directories, and other operating systems. A unified user interface also benefits programmers. For example, you can easily use built-in functions of common menus and dialogs. All menus share the same style of keyboard and mouse interface, Because Windows is not a programmer implementing it.
Windows Multi-task environment allows you to run multiple applications or multiple instances of the same application at the same time. An application can be activated. An active application is an application that receives user input. Because only one program can be processed at a time, only one application can be activated at a time. However, there can be any number of parallel tasks.
1.2 Brief History of Windows
Windows was initially announced by Microsoft in November 1983, and the first public release version, version November 1985, was released in 1.01. In the next two years, version 1.01 has been modified several times to meet the needs of the international market, and some drivers for displays and printers have been added. Windows November 1987 released in 2.0 has made some improvements on the user interface. For example, the introduction of overlapping windows also enhances the keyboard and mouse interfaces, especially the menu and dialog box functions... (omitted)
1.3. User interface components
1.3.1 window
A window is a rectangular area related to an application on the screen. It is a visual interface between the user and the application that generates the window. For an application, a window is a rectangular area on the screen under application control. The application creates and controls all aspects of the window. When you start an application, a window is created. The program responds to objects in the user operation window.
1.3.2 border
Most windows have a border around it. The border is used not only as the border of the window, but also to specify the window status, that is, whether the window is an active window. When we place the mouse pointer on the border and press the mouse key and move the mouse, we can change the window size.
1.3.3 title bar
The title bar is located at the top of the window. The text displayed is used to mark the program. Generally, it is the name of the application, so that you can know which application is running. The color of the title bar reflects whether a window is an active window.
1.3.4 Control Box
The control box is a small image in the upper-left corner of each window, which is used by each application. Click the mouse button on the control icon to display the system menu in Windows. The System Menu provides standard operations such as restoration, movement, size, minimization, maximization, and shutdown.
1.3.5 minimize icon
Each Windows 98 and Windows NT application displays three icons in the upper right corner of the window. The leftmost icon is a short underline, which is the minimum icon. It can be minimized using programs.
1.3.6 maximize icon
The maximize icon is the one in the middle of the three icons and looks like two small windows. Use the maximize icon to fill the screen with an application. If this icon is selected, other application windows will be covered.
1.3.7 vertical scroll bar
If necessary, the application can display a vertical scroll bar. The vertical flow bar is displayed on the right of the application window, with two arrows in the opposite direction at both ends. It also has a coloring stick and a transparent window block. The latter is used to display the relationship between the currently displayed content and the entire document. You can use the scroll bar to select which page to display. Generally, clicking an arrow will move the display content to a row. Click the window block at the bottom of the up arrow and drag it to quickly update the screen output to any position in the application screen output.
1.3.8 horizontal scroll bar
You can also display a horizontal scroll bar. The horizontal scroll bar is displayed at the bottom of the window and has a function similar to the vertical scroll bar. You can use it to select the columns to display. Generally, clicking one on any arrow will move the display content to one column. Click the window block to the right of the left arrow and drag it to quickly update the screen output to any location of the application screen output.
1.3.9 menu bar
An optional menu bar can be displayed below the title bar. Select menus and sub-menus through menu bar. This option can be selected by clicking with the mouse or using a combination of hotkeys. The hotkey combination is often a combination of ALT and underlined letters in the command, such as "F" in the File command ".
1.3.10 user Zone
Generally, the user area occupies the largest part of the window. This is the basic Output Area of the application. Applications should be used to manage user zones in a complex manner. In addition, applications can be output to the user area.
1.4 Object-oriented Thinking Methods
For programmers, object-oriented means things that are very familiar with: think of the world as a group of entities related to and communicating with each other, that is, objects. Each object has a name to identify, this is the way people generally look at the world. For example, when you see a car, you see a car, not a lot of atoms. People can break down cars into wheels, engines, doors, fuel tanks, etc. They are all concrete objects.
Communication between objects is called sending messages, that is, one object requests another object to perform some operation. For example, the red light at the intersection "requests" the driver to stop. After receiving the message, the driver stepped down the brake pedal and sent a message to the car, after receiving the message, the car breaks down the message and sends it to the relevant object: The brake acts on the wheel and turns kinetic energy into potential energy, causing the car to quickly fall down; the taillight sends messages to drivers of other vehicles behind it. Various dashboards give feedback to drivers about the messages they send.
From the programmer's perspective, an object is a famous storage unit in memory. We usually call a variable as a data object, but the object concept is more extensive than the meaning of the variable. Generally, the object is defined as a memory area containing data and code, data represents the characteristics of an object, and the code is used to respond to messages, so that the object performs certain actions. Taking a visual window object displayed on the screen as an example, we can compare and analyze the relationship between the objects in the user's mind and the objects in the programmer's mind. Features of window objects, such as color, length, and information displayed in the window, are represented as data in the program, for example, when a window is moved or the window size is changed, a user sends a message to the window, which causes the computer (in memory) object to execute the corresponding code, the result of code execution changes the data in the object so that the corresponding object can be changed according to its location and size.
The Code executed by the Response Message is called a method. The data stored in the object constitutes the attributes of the object. The abstract definition of the object is to execute certain actions. Otherwise, there is no other way to make an object action. Sending a message to an object in a program is represented:
FunctionName (id, arg1, arg2 ,...);
The message is functionName, and id is an object name or object identifier. In Windows, some type of data is used as the object identifier, this identifier is often called the handle of an object. Arg1 is the parameter of the message.
Although sending messages is similar to standard function calls, messages do not have features in function calls. For example, a message is always executing a selection mechanism, and its parameters are different from other messages, in this way, you can tell the object what operations are completed. A function name always points to the fixed address where the code of the function is located in the memory. A message does not point to an address in the memory, but tells the message receiving object what the memory address is. The function not only describes the operation, but also describes how to complete the operation. The message only describes this operation. the method defined in the object describes how to complete this operation. When the same message is sent to different objects, the method is different.
In object-oriented programming, each object is defined by a class. A class is a program description of a group of objects of the same nature, it is composed of methods and data that summarize the common nature of a group of objects. Abstract Public methods and data from a group of objects and save them in a class is the core of object-oriented programming.
In daily life, we also define objective objects in this way. By abstracting objective objects, we classify objects of the same nature into one category to form concepts, such as humans, apple, and food. By classifying objective objects, we can also better understand objective objects. For example, when we know that Michael is a person, we do not need to describe Michael, we already know the characteristics and actions of Michael as a person, because they have been described in the "person" class.
In an object-oriented program, classes are used as samples to produce objects with the same behavior. A class is like a factory of a production object. During the production object, the object has the same data structure and method described in the class. At the same time, each data of the object obtains an initial value at the beginning of creation, form the initial state of the object. When an object sends a message to each other, the state of the object transitions from one State to another. When all related objects reach a specific State, the running result of the program is obtained.
The process of using a class to generate an object is also called to generate an instance of this class. Therefore, an object can also be defined as an instance of a class. Defining a class also means placing the public code of the class object in the public area of the memory without re-describing the code and data of each object, this reduces the labor intensity of programmers. We can put some common object definitions in a public library, and create an instance of this class when an object of this class is required in the program. Windows has predefined many classes for programmers, such as buttons, scroll bars, and dialog boxes. When programmers need objects of these classes, they only need to create instances of these classes. For different objects of the same class, their initial states are different when an object is created. Therefore, the position, size, and other attributes of these objects displayed on the screen are also different, however, operations on similar objects are the same (because they share the same method ). This is one of the reasons why different Windows applications show consistent operating characteristics to users.1.5 handle
Windows applications have many objects, such as menus, Windows, icons, memory objects, bitmaps, brushes, device objects, and program instances. In Windows, objects are identified by handles, in this way, the application can access an object by using a handle.
In Windows software development tools, a handle is defined as a new data type. In an application, the use of a handle generally only has a value (the handle can