Introduction to common classes, macros and functions in MFC

Source: Internet
Author: User
Common classes

Crect: A class used to represent a rectangle. It has four member variables: Top left bottom right. The tables are the coordinates in the upper left corner and lower right corner. You can construct it using the following methods:

Crect (int l, int T, int R, int B); Specify four coordinates

Crect (const rect & srcrect); constructed by rect Structure

Crect (lpcrect lpsrcrect); constructed by rect Structure

Crect (point, size); coordinate and Size Structure in the upper left corner

Crect (point topleft, point bottomright); two-point coordinate structure

 

The following describes several member functions:

Int width () const; returns the width.

Int height () const; get the height

Csize size () const; obtain the size

Cpoint & topleft ();

Cpoint & bottomright ();

Cpoint centerpoint () const; proper Central Coordinates

In addition, the rectangle can be added to the cpoint for displacement, and the rectangle after the "and" operation is obtained by adding the rectangle to the other.

Cpoint: used to represent the coordinates of a point. There are two member variables: x y. It can be added to another vertex.

Cstring: a variable-length string. Use cstring to specify the memory size. cstring will be allocated as needed. The following describes several member functions:

Get the string length by getlength

Get the character at the specified position by getat.

Operator + is equivalent to strcat

Void format (lpctstr lpszformat,...); equivalent to sprintf

Find to find the specified character, string

Compare comparison

Comparenocase case-insensitive comparison

Change makeupper to lower case

Change makelower to uppercase

Cstringarray: a variable-length string array. Each element in the array is an instance of the cstring object.

 

The following describes several member functions:

Add cstring

Removeat deletes the cstring object at the specified position

Removeall deletes all cstring objects in the array.

Get the cstring object at the specified position through getat.

Setat: modifies the cstring object at the specified position.

Insertat inserts a cstring object at a certain position

 

Common macros

RGB

Trace

Assert

Verify

 

Common functions

Cwindapp * afxgetapp ();

Hinstance AfxGetInstanceHandle ();

Hinstance afxgetresourcehandle ();

Int afxmessagebox (lpctstr lpsztext, uint ntype = mb_ OK, uint nidhelp = 0); used to pop up a message box

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.