VC + + Knowledge Point collation

Source: Internet
Author: User
Tags access properties message queue

1. Inline functions

Definition: A member function defined within a class in which the function body of a function is placed inside the body

Features: Replace the code at the call with the inline function body to solve the program's operational efficiency problem. Be sure to define before the call, and the inline function cannot be called recursively.

2. Constructors and destructors

Constructor: Used to allocate memory space for an object, initialize member variables of the class, and perform other internal management operations. Parameters can be accepted, but cannot have a return value. and allows overloading

destructor: Used to release space allocated to memory objects. There are no parameters, no return values, and no overloads allowed. There can be only one destructor in a class.

3. function overloading and operator overloading

function overloading

Definition: The same function name can correspond to the implementation of multiple functions. Function overloading allows you to declare multiple functions of the same name within a program that perform different functions with different types, different numbers of parameters, and return values. The use of function overloading can alleviate the user's memory burden, the structure of the history procedure is simple and easy to understand.

Requirements: The number of arguments between functions or the type of parameter is different

Operator overloading

Objective: To enhance the extensibility of C + + language and give new functions to the existing operators in C + +.

4. Friends

Purpose: Allows a function or other class outside the class to have privileges to access the private part of the class, using the Friend_ class or function to represent a "friend"

Requirement: A friend class must be declared before it is defined

Access control for derived classes is determined by the Access property, which inherits the access properties of the base class as follows:

    1. 1. If the Access property is public, the public of the base class is the protected member of the derived class, and the accumulated private member is inaccessible to the derived class (unless the friend function declared in the base class is authorized to access) The protected member of the base class still retains the protected property for the derived class
    2. 2. If the Access property is protected, the public and protected members of the base class are protected members of the derived class The private member of the base class is inaccessible to the derived class (unless the friend function that is declared in the accumulation is authorized to access);
    3. 3. If the Access property is private, the public and protected members of its base class are private members of the derived class, and the accumulated private members are inaccessible to the derived class (unless access is authorized by the branch function declared in the accumulation). That is, when the Access property is private, the object of the derived class cannot access a member function that is defined in any way in the base class.
    4. 4. the base class name can be one, or multiple, and one base class, then this inheritance is called simple inheritance. , if multiple, inheritance is called multiple inheritance, and each base class is separated by commas.

5. Polymorphism and Virtual functions

Polymorphism: "One interface, multiple methods", using the same function name to define different function operations. Operator overloading and function overloading are compile-time polymorphism and static polymorphism, and runtime polymorphism is called Dynamic polymorphism, which is done through "virtual functions," and so on.

Virtual functions: In the base class, the visual description is used only once in the accumulation. Polymorphism is achieved by pointing to a pointer variable to a base class or derived class.

Unit 2

Windows into VC + + development of object-oriented applications, using the Windows API functions (process-oriented) and MFC class Library (object-oriented) two ways

6. Windows

Definition: is the basic operating unit of Windows application, the basic environment of interaction between application and user, and also the base unit of System Management application.

7. Handle

Definition: Refers to a unique pvoid data used by Windows, which is a 4-byte long value.

9. Messages in Windows consist of three parts: message number, Word parameter, and long character parameter

10. What is the function of the entry function WinMain?

    1. 1. Register window class, set up windows and perform other necessary initialization work
    2. 2. Enter the message loop to invoke the appropriate processing according to the message received from the application message queue.
    3. 3. Abort program run when message loop is retrieved to Wm_quit message

11. What function does the window function WndProc have?

Windows applications use the graphics device interface and Windows device drivers to support device-independent graphics.

Unit 4

Difference between BeginPaint and GetDC

13. Three mapping modes: Mm-text mapping, mm_anisotropic mapping and mm_isotropic mapping

14. Create a brush, paint sand, select the device environment, delete

Windows uses the macro RGB to define the color of the drawing in the form: RGB (Nred,ngreen,nblue)

invalidaterect– refreshing the invalid rectangular area

Unit 5

16. Formatting of text

1. Determine the coordinates of subsequent text in the line of text 2. To determine the coordinates of the next line of text when wrapping

TextOut function (text output function)

18. What kinds of keyboard messages are there?

Key messages and character messages;

19. What are the keys that generate character messages?

Any readable characters, BACKSPACE, enter, Esc,tab

20. Mouse messages

In Wm_mousemove

X = LoWord (iparam)---low byte Y = HIWORDC (Iparam)---high byte

The lparam parameter contains the mouse cursor position, and the wparam parameter contains an indication of various virtual key states

The Cs_dblclks property is defined in the following way:

Wndclass.style = Cs_hredraw | Cs_vredraw | Cs_dblclks

21. Read and write common resource scripts; A resource script for accelerator keys; draw the corresponding resource menu;

22. Bitmap and its bitmap use steps: (Selective use)

A: Due to the large amount of data processed, bitmap operations must be performed in memory, and the system device environment for bitmap operations is a memory device environment;

The application first requests the system to obtain the memory device environment by calling the function CreateCompatibleDC, which is compatible with the device environment HDC of the output device in the form of HDCMEN=CREATECOMPATIBLEDC (HDC);

Similar to the device environment, the memory device environment also has a device description table, after the application acquires the memory device environment, the calling function SelectObject the bitmap file contents into the memory device environment, it can manipulate the bitmap directly in the memory device environment, but only if the memory device environment needs to be initialized. Otherwise, you cannot draw directly. Use Creatcompatiblebitmap to create a vacancy map, select it into the memory device environment, and then use the BitBlt function to copy the memory device environment to the screen when the drawing is finished.

After manipulating the bitmap, the application must call DeleteDC to release the memory device environment in the form of:

DELETDC (HDCMEM);//hdcmem is a memory device environment handle

23, the main form of the dialog, the difference between the two, and the dialog box processing features; Structure dialog box processing function; (selective use)

A: The dialog box is a pop-up window that is typically used for applications that require user input or that require interaction with the user. The main forms of the dialog are: modal dialog box, non-modal dialog;

The modal dialog box does not allow the user to switch to other windows of the application before closing the dialog box, and when a modal dialog box is initialized, the message loop of the dialog box will process the message but not return it to the WinMain function.

A modeless dialog box allows the user to switch between the dialog box and the other windows of the application, that is, between the dialog box and the window of the other application. The modeless dialog box receives input from the message loop of the WinMain function. Whether you use a modal dialog box or a modeless dialog box depends on the application and its implementation.

Dialog resources have the following functions: Sending messages such as warning messages, prompt box messages, receiving input messages such as user input, and providing messages such as the common about dialog box.

The general form of the dialog message handler function:

BOOL CALLBACK Dlgproc (HWND hdlg,uint message,wparam wparam,lparam 1Param)

{

Switch (message)

{

Case Wm_initdialog;

return 1;

Case Wm_command

Switch (LOWORD (wParam))

{

Case ...

...

Break

Case ...

...

Break

}

Break

}

return 0;

}

...

24. Create a single document or multiple documents, and produce several classes;

25. Common Global member functions

4 Steps to Using MFC

1. Adding a control method to the Program Interface 2. Add a mapping message to a control 3. Using controls in an application 4. Custom control Classes

Typical controls use (buttons, scroll bar edit boxes for message responses)

(1) Create a MFC.exe project with AppWizard. (2) Set the control and its properties. (3) Adding a member variable to a control

The edit box uses: (1) to build the MFC application based on the dialog box. (2) Create the various controls in the dialog box. (3) Modify the property values for each control. (4) Add variables and message map entries for the associated control. (5) Code to write the message handler function.

Message delivery between an edit box and an application: After an application creates an edit box control, it can learn the user's request by accepting a message from the control, and can manipulate it by sending a message to the edit box. P213

    1. 1. The edit box sends a message to the application: the edit box notifies the application user of the interaction information by sending a WM_COMMAND message to its parent window. The low byte of the message self-argument (WParam) is the control identity, and the high byte is the message notification code that identifies the edit box action.
    2. 2. The application sends a message to the edit box: The application's action on the edit box is done by calling the function SendMessage or senddlgitemmessage to send various messages to it.

26. Create the application's resources in MFC. Example 10-1,p262

Add On_update_command_ui_range macros manually (to implement status updates for several menu items).

Add code to My_resview.h:

afx_msg void Onupdateopercolorchange (CCmdUI * pcmdui);

Add the following code to the My_resview.cpp:

On_update_command_ui_range (id_oper_red, Id_oper_blue, Onupdateopercolorchange)

At the end of the My_resview.cpp, add the following code to implement the function:

Void Cmy_resview::onupdateopercolorchange (CCmdUI * pcmdui)

{

Pcmdui->setradio (m_ncolorindex== (pcmdui->m_nid-id_oper_red));

}

27 Messaging process for single-document applications

DefWindowProc

Application objects

frame window Document Templates

active View Document Object

28 Document Template Classes CDocTemplate The role of this class:

The document template class CDocTemplate the original separate document, view, and frame window objects together. The CDocTemplate class provides the most basic functional implementation required for a document class, which provides methods that are generic and virtual methods that enable applications to override them to provide methods in cdoctemplate derived classes.

VC + + Knowledge Point collation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.