Visual C ++ (including Windows API and MFC) Answers

xiaoxiao2021-03-06  41

1. Briefly describe how the program is debugged under VC6.

In the main menu "build", there is a START BUILD sub-menu, which contains the GO menu (F5), after selecting, the program will enter the debugging from the current statement until the breakpoint or program is encountered.

Move the mouse to the code row to be debugged, click the right mouse button to select "Insert / Remove Breakpoint", or press F9, you can add a breakpoint on that line, at which point the breakpoint code line appears a brown circle, once again Select will clear the breakpoint. After entering the debug state, the Debug menu will replace the build menu in the menu bar, which contains common debugging operations, such as Step over, single-step running does not track the inside of the call to the call; other include Step Into, Step Out, Stop Debugging and other debugging methods.

2. What is the role of a file in the engineering suffix. H, .rc, .dsp, .dsws in a brief description of the project established in VC6.

.CPP is the source code C file

.h is a header that contains a function declaration and variable definition

.rc is a resource script file for defining resources

.dsp is an engineering document, record information about current project

.dsw is a work area file, a work area may contain one or more projects

3, known a dialog, there is an editing box control, ID is IDC_EDIT1, which is associated with the CEDIT type variable m_edit1, using two methods, explains how to change the text inside the edit box "Hello", write the program code Piece.

The first method: m_edit1.setsel (0, -1);

m_edit1.replasel ("Hello");

Second method: setWindowText ("Hello");

4. Briefly describe the structure of a basic Windows application framework written in the Windows API.

The Basic Application Framework written by the Windows API should contain at least the program portable function WinMain and window functions WndProc. In the main function WinMain, the definition and registration of the window class, the creation and display of the window, and the message loop.

5. What is the data type in Windows? What are the members variables?

The data type of the message is MSG. It is a structure that mainly includes hWnd, indicating a window handle of the message; Message represents the type of message; WPAram and LPARAM include additional information of the message, varying messages.

6. Long parameters for Windows Mouse Messages LPARAM and Word Parameters WPARAM meaning

The long parameter of the mouse message contains the X coordinate value of the mouse cursor position. The high byte of the LParam contains the y coordinate value of the mouse cursor position; the word parameter wparam contains the currently pressed virtual key. The value of the state.

7. Describe the attention problem and use of the Windows API function using a non-modular dialog

Using a non-modular dialog should be aware of whether to include WS_Visible in the style to display properly; create a dialog using the CREATEDIALOG function; the message loop section should use the isDialogMessage filter message; close the dialog uses the function destroyWindow.

8. Briefly describe the role of Updatedata functions in the MFC application and its parameters.

Updatedata has only one BOOL type parameter, Updatedata (false) is typically used for variable value refresh screen displays for dialog control connections; Updatedata (TRUE) is used to obtain the variables of the screen data to the dialog control connection.

9, list the three message types that the list box control can be accepted, and explain its role

LB_addstring is used to join a string in the list box; LB_DIR is used to list the specified file in the list box; LB_GETTEXT is used to obtain the text of the specified item. 10. Add three radio buttons on a dialog to automatically implement mutual exclusion, what questions should be paid, how to operate in the VC environment?

To implement a set of automatic mutual exclusion of a set of radio buttons, they should let their control ID values ​​continuous, and set the Group properties of the first radio button, other no.

11. Briefly describe a document class by a document class, and how to achieve documentation.

First, a corresponding document class is derived from cDocument from cDocument; then adds a member variable to save the data; finally overloads the Serialize member function to realize serialization of document data.

12, list three subclasses of the view class (CVIEW) and briefly explain its role.

The CScrollView class provides scrolling display of the view; the CeditView class supports the text editing operation in the view; the ChtmlView class supports displaying and operating an HTML file in the view.

13. How Visual C 6.0 enters the debug state, which debug windows can be displayed in debugging states, listed in three, what is the role?

After starting debugging, you can open some auxiliary debugging window under the Debug WINDOW submenu of the View menu.

Watch: Display the window to view the variable value in the current statement and the previous statement

Call Stack: Shows the window to see the call to the stack

Memory: Displays the window to view the contents of the memory

14. To explain the steps of the creation of bitmap resources and the procedure, and give the corresponding Windows API function name.

First define bitmap handle hbitmap hbitmap; second step using loadbitmap load bitmap; Step 3, call CreateCompaTibleDC to apply for a memory device environment handle to the system, and call the function SelectObject to select the bitmap to the memory device environment; fourth step, call Bitblt The function outputs the bitmap from the memory device environment to the specified window device environment, which implements the display bitmap.

15. How to get the font handle to implement the output of the font, and give the corresponding Windows API function name.

First define the font handle variable HFONT HF; then call the function getStockObject to get the font handle of the system, or call CREATEFON to get a custom font handle; finally call SelectObject to select the font handle to the device environment.

16, list three types of buttons, and explain the differences between its roles and creation methods.

Common buttons have normal buttons, radio buttons, check boxes, and group boxes. The normal button effect is to help users trigger a specified action; the radio button is generally mousse between options; the checkbox is used to display a set of options for user selection, and there is no mutual exclusion between options; Divide the control into a different group and explain it.

17. To make a static control display a bitmap and accept user input, you should pay attention to something.

To make the static control display bitmap, you must set the style containing SS_bitmap, and specify and load the bitmap when creating a static control window, that is, calling CREATEWINDOW; to make the static control to receive user input, you must set its style to include SS_NOTIFY.

18, list the four types of action identity of the scroll bar control, and explain the occasions of it.

The action identifier of the commonly used scroll strip control includes (for a vertical scroll bar): SB_LineUp indicates the rolling row; SB_Linedown indicates a row down; SB_PAGEUP indicates the upward scroll; SB_PageDown means scrolling one page down.

19. Note that the method of using the system timer message (WM_TIMER) and its use of the Windows API function using the timer message is: first call the setTimer function definition timer message, including the time interval generated by the message; then in the corresponding The timer message response code is added to the WM_TIMER message processing; finally calls KillTimer to release the timer.

20. The MFC Application Wizard can create several types of application frameworks that use document / view structures.

The MFC application wizard can establish a single document (SDI), multi-Document (MDI), and dialog-based frameworks. The first two use document / view structures.

21, list five controls, explain the role and the class name corresponding to the MFC

CSTATIC is a static text control window for other controls in labels, separated dialogs, or windows. CButton is a header control window, providing a total class for buttons, radio buttons, and multi-selection buttons, or the like; CScrollBar is a scroll bar control window that provides a function of the scroll bar. It is used in a control in the dialog or window. It is located within a range; CListbox is a list box control window, the list box is used to display a set of list items The user can perform observation and selection; CProgressCtrl is a progress bar control window for indicating the progress of an operation.

22. How does the MFC document / view structure explain how the map class accesses the document class, how the document class notifies the view class to update, give the member method name?

In the document / view structure of the MFC, the view class obtains the corresponding document class by its member method getDocument, thereby accessing the document class data; document classes notify all views through their membership updateAllViews, the document has been modified, the view should be redrawn .

23. Briefly describe an editing box in a dialog-based MFC application frame (edit the control ID is IDC_EDIT1, which has been connected to the variable m_edit1), requires that the current display shows the current time, time format " HH: mm: ss ", such as" 15:20:16 ", refresh every second, how to implement, give the code snippet. (Tip: Using Timer SetTimer)

Implementation method: Implement the timer, issue the WM_TIMER message every other second, and add the code update edit box in the corresponding function.

Step 1: Add code to the message response function on the WM_INITDIALOG of the dialog: Settimer (1,100, null);

Step 2: Add a WM_TIMER message corresponding to the dialog, and add code in it:

CTime TNOW;

TNOW = CTIME :: getcurrenttime ();

CString Snow = TNOW.Format ("% i:% m:% s");

m_edit1.setsel (0, -1);

m_edit1.replasel (snow);

Step 2: Add code killtimer (1) to the message response function on the WM_DESTRYOY of the dialog, (personal original, please specify the source, thank you .yanqlv)

转载请注明原文地址:https://www.9cbs.com/read-70709.html

New Post(0)