In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Window
The concept of window is easy to understand, which is the interface we see when we use software. The center of Windows is the window, which is the killer mace of Windows's unified PC operation of the piecemeal market, as shown in the following figure:
\ "\"
Figure 1: notepad program
All the software we use have their own windows, such as QQ, computer, notepad and so on. These windows can include output boxes, drop-down menus, radio buttons, multi-select buttons, text areas and other controls (Controls), and some even have animation!
Windows, controls, images, audio and video are all called Resource, which can be used, created, added, modified and so on in the program.
Handle
In Windows programming, divergent windows, controls, images, etc., all correspond to a unique number (beginners can understand it as ID), called a Handle. Through the handle, the program can obtain all kinds of information about the corresponding capital, and it can also use, modify and delete the capital.
You can understand the handle as a student number, you do not need to remember the name, address, results and other information, when you need to understand this logic student, just go to the academic Affairs Office, notify the student number (handle) to the task officer (Windows) over there, and he can help you find this student.
Handles block a lot of details, and programmers don't need to understand the mechanism in front of them. For example, after creating a file with the CreateFile () function, you will go to a file handle, and then you can read, write and delete the file through this handle. There is no need to understand how Windows connects the handle to the file, and there is no need to understand what information the handle holds. Windows is closed source, and these details only need to be known by Microsoft.
The Audio Mechanism of Windows
In ordinary programming, we often misappropriate piecemeal functions through the API function, and let the operation piecemeal help us complete many tasks, such as misappropriating the CreateFile () function, and operating piecemeal functions will help us create a file without requiring us to intervene in any task, which is very convenient.
In the past, operating bits and pieces will also be "lazy", will misappropriate the functions in our program, and let us handle some work ourselves. For example, if the user hits the keyboard, the operation bits and pieces will be told at first, but it will not be disposed of, but the functions in the program will be misappropriated to inform the program that the user has tapped the keyboard, and you will dispose of it yourself; if the program is not disposed of, the operation will stop the acquiescence operation.
Of course, this can not be understood to be "lazy" in order to operate piecemeal, but it gives us an opportunity to handle some work on our own, thus making the program more sensitive and robust, and giving programmers more room to carry forward.
The user taps the keyboard, clicks the mouse, drags the window, selects the menu, outputs the text, and all the operations are called Event. This is similar to what we usually know as "things". They all show that something has happened, good or bad.
When something happens, Windows generates a Message informing the program what is going on. This is similar to what we usually know as "news", both of which represent a carrier for transmitting information.
So, how does Windows tell the user what happened through audio?
Whenever something happens, Windows generates a message and puts it in a queue protected by bits and pieces. Then, the program will withdraw the message from the queue and analyze it, misappropriate the event handling function (the code for handling the matter is in this function), and stop responding to the user's operation.
Queue is a kind of first-out data structure. If you are not clear, please Google or Baidu.
Note: Windows equally distributes audio to the queue and the message that the user program withdraws from the queue is not synchronized, Windows regardless of whether there is a message in the queue, no matter whether the use of the program has been disposed of or not, as long as something happens, the message will be thrown into the queue, when the end of the disposal is a matter of using the program.
It can be seen that audio is the link between Windows and the user program. Windows notifies the user program what happened through the audio message, and the user program knows what to do through the audio.
Audio structure
The audio message is actually a structure with the name MSG and is defined as:
Typedef struct tagMSG {HWND hwnd; UINT message; WPARAM wParam; LPARAM lParam; DWORD time; POINT pt;} MSG
When Windows sends a message to the queue, it actually throws a constructor variable of type MSG into the queue.
The member variables in the MSG construct have the following meanings:
1) hwnd shows the window to which the message belongs. Users usually stop operating under the window of the program, so a message is usually associated with a window. For example, if you press the left mouse button in a moving window, the key message is sent to that window.
2) message represents the type of audio, which is a numerical value. In Windows, audio is represented by a numerical value, and different types of audio correspond to different values. However, because the numerical value is easy to remember, Windows defines the numerical value of the audio as the WM_ XXX macro (WM is the abbreviation of Window Message), and XXX corresponds to the capitalization of the English spelling of a certain audio. For example, the left mouse button press audio is WM_LBUTTONDOWN, keyboard press audio is WM_KEYDOWN, character audio is WM_CHAR, and so on. In the program, we usually use audio in the way of WM_ XXX macros.
3) the third and fourth member variables wParam and lParam are used to specify additional information for the audio. For example, when we receive a character message, the value of the message member variable is WM_CHAR, but exactly what character the user outputs is clarified by wParam and lParam. The information expressed by wParam and lParam varies with the difference of audio.
4) the first two variables distinguish between the time when the audio transmission reaches the audio queue and the later status of the mouse.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.