(Personal finishing, only do review with: D, reprinted with the source: http://blog.csdn.net/hcbbt/article/details/42706501)
What is the difference between the dubyte Character Set and the Unicode Character Set? What is the problem with using the Double Byte Character Set?
- The dual-byte character set (DBCS) encoding is 0-255. DBCS contains 1-byte code and 2-byte code, while Unicode is a unified 16-bit system, which allows 65536 characters. Each character in Unicode is a 16-Bit Width instead of an 8-bit width. In Unicode, the 8-bit binary indicates that a value is meaningless, while the 8-bit value is still processed in the double-byte character set.
- Not all double-byte character sets are represented by two bytes, which causes additional programming problems, such as the length calculation of strings. In addition, it is very complicated to process double-byte character sets.
What is a wide character? What are Unicode characters? What are their differences?
- The characters represented by multiple bytes are called wide characters. In C, wchar_t is used to represent the wide character data type.
- Unicode is only an implementation of wide character encoding. It stores one character in two bytes.
- Unicode is a type of wide character, and the width character is not necessarily Unicode.
The role of the _ Unicode identifier, TCHAR. h header file.
- _ UNICODE indicates whether the string processing function in the control program segment is treated according to the wide string processing function or the regular string processing function.
- TCHAR. h provides a series of alternative names for standard library functions that use strings as parameters. These general function names can point to the Unicode version of the function, or to non-Unicode version. The key to implementation is to add the _ UNICODE Recognition Word in the compilation command.
What is the role of the Resource Description file? What are the functions of the resource compiler?
- The Resource Description file records the resources used by the application or process.
- The function of the resource editor is to generate resources based on the information provided by the template in the RC file and then compile the resources into the required binary files. Therefore, the modern resource compiler essentially integrates the resource generators and compilers, this is conducive to the use of programmers.
- What is the difference between a resource file and a resource description file (. RC?
- Record the resources used by the application or process in a file, which is called a resource description file.
- In WIN32, a resource is called an object and can be divided into two types: body resource and binary resource.
Let's talk about the conventions of Hungary naming conventions. What habits should we remember?
- There are two naming conventions in Hungary:
1. The identifier starts with one or more lower-case letters. These lower-case letters indicate the Data Type of the identifier;
2. uppercase and lowercase letters are mixed to make the identifier have a certain meaning, which is easy to understand and enhances readability.
- Usage:
- When naming a structure variable, you can use the lower-case Character Sequence of the structure name as the beginning of the variable name, or use the entire structure name as the structure variable name.
Explain the principles of the event driver and compare it with procedural programs.
- Event driver
- After the initialization and application creation window ends, other activities are basically stopped, and an infinite loop is executed, waiting for the user to input messages. Once the user provides input to generate an event, windows receives the message and analyzes the event, and directs the application to work according to the importance. If the message is irrelevant to the application or meaningless, it does not respond. If many events occur, the Message Queue waits for processing.
Start> set variables, structure> enter the terms of the window class> Registration window class> Create application window> display window on the screen
Enter the message loop and get a message from the queue <--------------------------- v ^ whether the message is WM_QUIT --- non-----> | Yes window function | is the message defined by the application? ----> Process message-> | v no V | terminate execution to process the message by default ------------->
A procedural Program is executed in the order that programmers compile the program, top-down, and single-execution process pattern. Windows program execution is a process of communication between applications and the operating system, which is closely related to message events.
What is dynamic link? What is static link? What is the suffix of the dynamic link library file?
- Dynamic Link: create a dynamic link library so that only one backup is required for the same part. When the program executes this function, it is used in the dynamic link library.
- Static link: when a program calls a function, the machine code of the function is merged into the program itself during the link process.
- DLL
Explains the window class structure name and window class variables. Why do I need to fill in window class terms? What is the role of registration?
Which function is used to create a window? What are the parameters? Please explain every parameter?
CreateWindow
Function
- 7
hWnd = CreateWindow(
s
ZAppName, // window class name CW_USEDEFAULT, CW_USEDEFAULT, // The Window coordinate value is the default value CW_USEDEFAULT, CW_USEDEFAULT, // The window height and width are the default value NULL, // This window has no parent window NULL, // This window has no sub-menu hInstance, // The current handle of the application that creates this window is NULL // This value is not used)
Where can I obtain the window class name used in the application?
- SzAppName in the window class structure clause. The name of the window class in the normal application is the same as that of the application.
How do WinMain and WndProc contact the main program?
Wndclass. lpfnWndProc = WndProc; // window message handler address
- The WinProc window handler is a callback function that is used to process messages and called by Windows.
- When registering the window class, the entry address of the window processing function is specified. All messages obtained by the application are sent to the window processing function corresponding to the entry address for processing.
How many functions are involved in a message loop?
- Message loop and MSG structure:
While (GetMessage (& msg, NULL, 0, 0) {// is it! WM_QUIT TranslateMessage (& msg); // canonicalized DispatchMessage (& msg); // call}
Explain the global window class of the system, the global window class of the application, and the dedicated window class of the application.
- The system global window class is also known as the pre-defined window class. 32-bit Windows provides 7 pre-registered window classes without any registration in the code written by the developer. (Combobox edit usebox scrollbar ctatic mdiclient)
- The global window class of the application belongs to the application. Any process generated by the application can use this global window class instead of registration. It is used in multi-document programs.
- An application-specific window class is a process in which window class structure clauses and registered window classes must be filled during process execution, during the Process generation process, the registration window class starts and the process is interrupted.
Which three window classes are supported by 32-bit Windows? Describes the usage of each window class.
- System global window, application global window, and application dedicated window
Please explain the window class structure name and window class name.
Which of the following loading functions are commonly used in window class structures? How are they used?
- LoadIcon Function
Hicon winapi LoadIcon (// returns the pointer to the icon. If it fails, null hinstance hInstance is returned. // The instance in which the user-defined icon is located, NULL is the System icon (also called the label on the icon );
- LoadCursor () function
Hcursor winapi LoadCursor (// return the HINSTANCE hInstance of the newly loaded cursor handle, // The loaded cursor LPCTSTR lpCursorName) // predefined cursor Resource Name
GetStockObject (WHITE_BRUSH); // window background color
What is the customer zone in the window?
- Any part of the window information that can be written and transmitted by the application.
Which function is used to make the window customer zone an invalid region? Which function is used to obtain coordinates of invalid regions?
- InvalidateRect Function
- GetUpdateRect Function
In Windows, how do I implement device-independent output? Why must I use the GDI function?
- In Windows, a data structure is created for each device. This structure records the detailed requirements for device output, such as the color of text. This data structure is called the device description table (DC for short. In Windows, devices are abstracted as DC. This abstraction of devices is called DC, which is the key to achieving device independence. Each GDI function calls a device according to hdc, And the GDI function outputs the device through DC.
- The output must pass the GDI function because device-independent output can be obtained when the GDI function is executed.
What is the meaning of the code? What is the significance of DC?
- The hDC device description table code hDC is a pointer to the device description table. With the hDC code, programmers can freely draw in the customer zone. The application knows which window or device to output according to the hDC code.
- DC is the key to achieving device independence.
Explains how the GDI function implements device-independent output.
- In Windows, devices are abstracted as DC. This device abstraction is called DC, which is the key to achieving device independence. Each GDI function calls a device according to hdc, And the GDI function outputs the device through DC.
Which two methods can be used to obtain the hDC of the screen?
What is the difference between the redraw area determined by InvalidateRect and that determined by BeginPaint?
- When the program calls BeginPaint, in most cases, fErase is marked as FALSE (0), which means Windows has erased the background of the invalid rectangle. After BeginPaint is called, The fErase clause of the PAINTSTRUCT structure will be TRUE (non-zero ).
- When the program calls the InvalidateRect function to invalidate the rectangle in the customer zone, the last parameter of the function indicates whether to erase the background. If this parameter is set to FALSE, Windows will not erase the background when InvalidateRect is executed. Otherwise, the background will be erased.
Under what circumstances will WM_CREATE window messages be generated? Under what circumstances will WM_PAINT window messages be generated?
- Generate WM_CREATE window message: When the CreateWindow function is executed
- Generate the WM_PAINT window message:
- When the UpdateWindow function is executed
- When a user moves a window or displays a window, the area hidden before the window is visible again.
- The user changes the window size (if the window type style has CS_HREDRAW and CS_VREDRAW flag settings ).
- The program uses the ScrollWindow or ScrollDC function to scroll part of the display area.
- The program uses the InvalidateRect or InvalidateRgn function to deliberately generate the WM_PAINT message.
- Windows erasure overwrites the dialog box or message box of some Windows.
- (Possible) the menu is pulled out and then released.
- (Possible) displays a tooltip message.
Why is a WM_SIZE Message followed by a WM_PAINT message?
- Because we define the class style when defining the window class.
CS_HREDRAW|CS_VREDRAW
Describe the range and address of the scroll bar. Which function is used to set the range of the scroll bar and the address of the scroll bar?
- The so-called "range" is an integer that represents the minimum and maximum values of the rolling area, that is, the two ends of the sliding area;
- The so-called "Address" is the address of the scroll slider in this range. When the slider is at the top (or left) of the scroll area, the address of the slider is the minimum value of the range. When the slider is at the bottom (or right) of the scroll bar, the address of the scroll slider is the maximum value of the range.
- SetScrollRange (hwnd, iBar, iMin, iMax, bRedraw );
- SetScrollPos (hwnd, iBar, iPos, bRedraw );
A notification code is generated when you click the scroll bar. Which parameter is the notification code? What does it mean?
- WParam message parameters are divided into a low field and a high field. WParam's low-word group is a numerical value that specifies the operation of the mouse on the scroll bar. This value is called a notification code.
What is the current address of the scroll bar block? Is it generally an integer? What is the size of the scroll slider? What is "page size "? What is the scope?
- The current position of the slider in the sliding area, which is an integer.
- The slider size refers to the sliding length of the slider. It ranges from the starting address of the slider to the current address of the slider.
- The length of the content displayed in the "page size" display area.
- The length of the file that may be displayed in the range.
What is a GDI object?
- Some functions do not require the device description table Code. These functions are called GDI objects.
- Five types of GDI functions: Logical paint brush, paint brush, dot matrix, area, font and color palette.
- Graphics output devices are divided into bit- ing devices (lattice devices) and vector devices (vectors ).
What is the difference between the draw line function and the draw function?
- The drawing function not only draws the border box, but also draws the area to fill in the color, and the draw line program only draws the border line.
What is the function for drawing an elliptical line? What is an elliptical function?
- Arc Functions
- Ellipse function
Which of the following functions are used to create, select, and delete a paint brush?
- Create a paint brush:
HPen1 = CreatePen (PS_SOLID, 1, 0); // a black brush with a width of 1
- Select paint brush:
SelectObject (hdc, hPen1);
- Delete paint brush:
DeleteObject (hPen1);
What is the method for obtaining the device description table code?
- Use GetDC (hWnd) to obtain window hDC
- Use BeginPaint to obtain hDC during WM_PAINT message processing.
What is the function for retrieving information in the device description table?
- IValue = GetDeviceCaps (hDC, iIndex );
What is resolution? What is the difference between screen resolution and printer resolution? How to calculate resolution?
- Resolution: number of pixels per measurement unit
- Printer: points per inch
- Screen: the total number of pixels vertical and horizontal
- Calculation: pixel size divided by common measurement size
What is the color number of pixels? Which factors are related to it?
- The number of colors in a color display is equal to the number of colors that may be taken by pixels.
- The more binary digits it represents, the more colors it represents, and the more colors it will have.
What does COLORREF mean? What is "RGB color "?
- The COLORREF value is a 32-bit long integer without plus or minus signs.
- The COLORREF value specifies a color based on the brightness of red, green, and blue, which is usually called the "RGB color ".
Describes the composition of a device description table. A specific function is used to modify or retrieve a property in the device description table. Generally, under what circumstances?
- Composition: [MSDN] [community or [Chinese] [http: // 166.111.4.15/s96300/vc_dist_course/Chapter4/4.1.1.htm]
- When an application uses the GetDC or BeginPaint function to obtain a device description table handle, Windows automatically uses the default value to set all its properties. Applications can obtain and modify all attribute values through corresponding GDI function calls.
- Get the device description table:
- Use BeginPaint to obtain hDC during WM_PAINT message processing:
HDC BeginPaint(HWND, PAINTSTRUCT *)
AndEndPaint(HWND, PAINTSTURCT *)
- Obtain hDC when processing a non-WM_PAINT message:
HDC GetDC(HWND)
Andint ReleaseDC(HWMD ,HDC)
- Get the device content handle for the entire window:
HDC GetWindowDC(HWND)
Andint ReleaseDC(HWMD ,HDC)
- Get the device content handle that is not first closed with a specific window:
hdc=CreateDC(pszDriver,pszDevice,pszOutput,pData);
AndDeleteDC(hdc);
You can use CreateC to obtain the device content of a device without drawing it.
- To save the changes to the device description table:
- Add CS_OWNDC to the window class style when logging on to the window class.
- DaveDC, RestoreDC
What is device coordinates? What are logical coordinates?
- In Windows, all devices use uniform coordinates, which are called device coordinates. The device coordinate isPixelsIs the coordinate of the measurement unit.
- There is alsoLengthThe unit is called logical coordinates. The logical unit is the coordinate in the mathematical sense, and the coordinate in the abstract sense, such as the pixel. The coordinates of measurement units, such as inches and meters, are called logical coordinates.
Briefly describe the keyboard input process.
- First, you must start with the input of the keyboard. A keyboard input is called a keyboard event. When a keyboard event is sent to a Windows system, a corresponding keyboard message is sent to the Windows system.
What is a window with input focus? What is an activity window? How to identify the activity window?
- A window that receives messages from a specific keyboard is called a window with an input focus.
- The concept of the input focus is similar to that of the activity window. The window with the input focus must be a derivative window of the activity window or activity window.
- The activity window is usually a top-level window. P180
What is system message queue? What is the relationship with the application message queue?
- The system message queue is an independent message queue, which is maintained by Windows and is used to preliminarily save messages input from the keyboard and mouse.
- When a Windows application processes the previous user input message, Windows extracts the next message from the system message queue and puts it into the message sequence of the application.
Based on the generated key messages, what are the two types of keys? What are the four types of key messages? What are the features of system key messages? Where is it handled? Which are not system key messages?
- System and non-system key messages
- Four forms:
WM_KEYDOWN
WM_SYSKEYDOWN
WM_KEYUP
WM_SYSKEYUP
- Features: The system button may be a combination of several keys, and the system button may work for the Windows system.
- The default branch DefWindowProc processes system keyboard messages.
WM_KEYDOWN
WM_KEYUP
What is a scan code? What is a virtual key code? Why use a virtual key code?
- For early programmers, the real key code is generated by the keyboard hardware. In Windows files, these key codes are called scan codes.
- A virtual keyboard is a conceptual keyboard, and a virtual key code defined by a Windows designer in the WINUESR. h file.
- To achieve device independence.
How is the virtual key code defined for numbers and letters?
- The virtual key code of numbers and letters is defined by ASCII code.
In the window function, what are the differences between the third parameter wParam in the WM_KEYDOWN Message Processing Branch and the SendMessage function?
- WParam In the Message Processing Branch determines the virtual keyboard.
- In SendMessage, wParam stores the mouse notification code.
How is a character message generated? What are the four character messages? How useful? What is the structure of the character message?
- If the virtual key code of a key message is a character code, it generates a character message and puts the character message into the application message queue. (Implemented in the TranslateMessage function)
WM_CHAR
WM_SYSCHAR
WM_DEADCHAR
WM_SYSDEADCHAR
- A character message converts a virtual key to an ASCII or UNICODE character.
- The lParam parameter is the same as the lParam parameter of the key message that generates the character message. The virtual key code of the wParam parameter is the ANSI or Unicode code of the character.
The mouse is a "required device Selection". How can I use the GetSystemMetrics function to check whether the mouse exists?
fMouse = GetSystemMetrics (SM_MOUSEPRESENT);
What is a mouse cursor? Which image is it? What is the mouse hotspot?
- When a user moves the mouse, Windows moves a small image on the display, which is actually a dot matrix, called a "mouse cursor ". There is a pixel on the mouse cursor, which is called the "Hotspot" of the mouse cursor ".
How do I identify the three keys of the mouse? How many mouse messages are there? What is the difference between a mouse message and a keyboard message? What prefix are used for the mouse message and the virtual key code of the mouse?
- The three keys are left-click, middle-click, and right-click, which are marked by LBUTTON, MBUTTON, and RBUTTON.
- There are 21 mouse messages in Windows, 11 of which are irrelevant to the display area.
- Windows can only send keyboard messages to window functions with input focus. If you hover the mouse over the window or press the mouse button in a window, the window function will receive the mouse message.
- WM, MK
How are mouse messages generated? What are the meanings of wparam and lparam in the mouse message?
- The mouse hardware and the mouse driver transform the mouse event (or mouse action) into a scan code, and then the scan code is transformed into a virtual mouse key code by the Windows operating system.
- Wparam is the virtual key code for pressing down the mouse button, lparam is the mouse address: the low-word group is the x coordinate, and the high-word group is the y coordinate.
How is the WM_MOUSEMOVE message generated? What are its features?
- When you move the mouse over the display area of the window, the message WM_MOUSEMOVE is generated.
- As long as you hover the mouse over a window or press the mouse button in a window, the window function receives the mouse message, regardless of whether the window is active or has the input focus.
How can I combine the mouse and Shift Ctrl?
- You can use the virtual key code VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_SHIFT, and VK_CONTROL to return the status of the mouse and Shift keys.
What are the wParam and lParam parameters in the show area mouse message?
- The wParam parameter of the displayed area mouse message is the virtual key code of the key. The lParam parameter is the x and y addresses of the mouse in the screen coordinate.
What is a subwindow Control item?
- In Windows, subwindows are usually called control items, controls, and subwindow controls.
What is the difference between SendMessage and PostMessage?
- Different return value types
- PostMessage is asynchronous and SendMessage is synchronous.
Which seven types of pre-defined Control item window classes are available?
- Button, Edit, Scrollbar, Static, Listbox, MDI, Combobox
What is the role of the notification code? P250 test indicates the notification code generated by the cursor on the keyboard is prefixed with what? List the prefixes of the notification codes of the button, scroll, edit, and ListBox categories.
- The notification Code specifies what the window function of the parent window does.
- The notification code generated by the cursor on the keyboard is a recognized word prefixed with SB.
- Button class BN _
- Scroll class SB _
- Edit class EN _
- ListBox class LBN _
Comparison between CreateWindow function and CreateWindow function to create the main window?
- Parameters
HWND hWndParent
Is itNULL
- WS_VISIBLE must be included in the window style of the sub-window.
CreateWindow has a total of 11 parameters. What are their functions? What is the impact on the shape and performance of the created sub-window? Why does WS_VISIBLE exist in the window style of the subwindow, but not in the main window?
- CreateWindow:
HWND CreateWindow( LPCTSTR lpClassName, //pointer to register class name LPCTSTR lpWindowName, //pointer to window name DWORD dwstyle, //window style int X, //horizontal position of window int Y, //vertical positon of window int nWidth, //window width int nHeight, //window height HWND hWndParent, //handle to parent or owner window HMENU hMenu, //handle to menu or child-window identifier HANDLE hInstance, //handle to application instance LPVOID lpParam //pointer to window-creation data}
- WS_VISIBLE indicates that the created Control item is visible and the showWindow function cannot be executed.
How is WM_COMMAND generated?
- When you click the button, the button control item sends a WM_COMMAND message to its parent window.
How do I transmit messages between a subwindow and a parent window?
- Child Window> parent window:
WM_COMMAND
- LOWORD (wParam) subwindow ID
- HIWORD (wParam) button notification code
- LParam subwindow code
- Parent WINDOW> Child Window: WM _ and BM _
What is the purpose of the parent window to send messages to the Child Window?
When is the WM_CTLCOLORBTN message generated? What is the function?
- It is called the Control item coloring message, which is a message sent by the button control item to its parent window function when the button control item shows the area coloring.
- Change the color of the button.
Which two types of scroll bars are available? How to distinguish between the two scroll bars? What are the features of the scroll bar control?
- Control items of the window scroll bar and scroll bar.
- The former appears on the right and bottom of the window. The latter can appear anywhere in the display area of the parent window. You can use the lParam parameter to identify whether the window scroll bar or the scroll bar Control item is used. The value of the window scroll bar is 0, and the value of the scroll bar Control item is the code of the scroll bar Control item.
What is window subclass? Describes the purpose and method of subclass. What is the type of Window Function of the subwindow Control item?
- Generally, the button control item (window) does not have a window function. If you want to design a window function for the Control item, you must solve the problem that the address of the window function is filled in with the pre-defined window class. The technique to solve this problem is called Window subclass.
- Associate the Control item window with its window functions.
- (Using tab switching in subwindows as an example) use the SetWindowLong function to connect window functions of subwindows and subwindows. When the scroll Tab window has the input focus and the tab key is moved in the scroll Tab window, the generated keyboard information is first processed by entering the ScrollProc window function. At the end of the process, CallWindowProc is used to convert the window function WndProc to the WinMai function for processing. This technology is called "Window subclass ".
- LRESULT CALLBACK
What is a dialog box? What types of dialog boxes are there? What are the features?
- The dialog box is started by selecting items in the menu. A dialog box is a downward pop-up window, also known as a drop-down window.
- The dialog box is divided into two types: Mode dialog box and non-mode dialog box.
- The Mode dialog box means that when a dialog box appears, its parent window will temporarily expire. After the action required by the dialog box is processed, the control can be handed back to the parent window.
- The non-mode dialog box is also called the coexistence dialog box. When this dialog box appears, its parent window does not expire. You can move the input focus to the parent window and execute the work of the parent window.
What are the different message sources between the mode dialog box and the coexistence dialog box?
- The coexistence dialog box retrieves messages from the message loop in WinMain, and the message source of the mode dialog box is the dialog box manager.
What is required for a message loop of an application containing a coexistence dialog box?
What are the differences between the establishment and termination of the coexistence dialog box and the establishment and termination of the API functions used?
- The creation of the coexistence dialog box depends on the main program to start the CreateDialog function. End with the DestroyWindow function.
- In the window function of the application, when you click the button, the start function is called in the COMMAND Message Processing Branch. The start function is in the form of DialogBox (hInstance, TEXT ("AboutBox"), hwnd, AboutDlgProc); the end time of the modal dialog box is determined by the user. When the user presses the OK button, the COMMAND branch of the function is entered, 0) function end dialog box.
What are the characteristics of the non-mode dialog box? How to establish it?
- The non-modal dialog box allows you to switch between the dialog box and other programs. You can also switch between the dialog box and the window in the create dialog box. However, you cannot switch to another window of the same program, until the non-modal dialog box is cleared. Therefore, non-modal dialog boxes may be more similar to common pop-up windows in user programs.
- The non-modal dialog box is created using CreateDialog.
What are the differences between the message sources of the mode dialog box and the non-mode dialog box?
How does a non-mode Dialog Box Process messages?
What is the exact meaning of "resource" in the program?
- Resources refer to icons, cursors, strings, menus, dialogs, lattice charts, and fonts. Generally, solid components, devices, and components of a computer become hardware resources of a computer, and software components in a Windows operating system are called software resources.
Which resources are represented by the suffix. ICO,. CUR,. BMP,. FNT, And. DLG?
- . ICO icon file
- . CUR cursor file
- . BMP Image File
- . FNT font file
- . DLG digital line map
How does an application use resources?
- The original resource program file is compiled into a resource binary file through the resource compiler, and the application loads the resource binary code using a special function as needed.
Briefly describe the meanings of menus, menu items, pop-up menu items, and drop-down menus.
- Each menu consists of at least one menu item.
- Menu items are divided into two types: one is the menu items that can pop up the menu, called the pop-up menu item or the drop-down menu item, and the other is the menu items that cannot pop up the menu.
- A menu that contains a pop-up menu item becomes the "Main Menu" or "parent menu" of the drop-down menu, and the drop-down menu becomes a "sub menu" or a pop-up menu.