Use of common MFC classes
I. array class:
Cbytearray, cdwordarray, cptrarray, cuintarray, cwordarray, cstringarray
Member functions include:
Add () adds an element at the end of the array. You can increase the array size as needed.
Elementat () gets a pointer to an array element.
Freeextra () releases unused Array Memory
Getat () gets the value at the specified position in the array
Getsize () is used to obtain the number of elements contained in the array.
Getupperbound () obtains the upper bound value of the array.
Inserat () inserts an element at the specified position of the array. The subscript of the subsequent element is added with 1.
Removeall () deletes all elements in the array.
Setat () sets the value at the specified position of the array. Because the tanning function does not increase the array size, this subscript must be valid at this time.
Setatgrow () is used to set the value at the specified position of the array. You can increase the array size as needed.
Setsize () sets the initial size of the array
First, declare an array object in the View class, as shown below:
Cuintarray array;
Initialize the array in the View class constructor and set it to contain ten elements:
Array. setsize (); The setsize () function has two parameters. The first parameter is the initial size of the array, and the second parameter is the number of added array elements each time.
Now we can use it in the application!
Ii. Use of the List class:
The constructor of the clist () clist class. The Parameters specify the basic unit for memory allocation.
Gethead () obtains the value of the first element in the list.
Gettail () obtains the value of the last element in the list.
Removehead () deletes the first element in the list.
The last element in the removetail () risk list
Addhead () adds a node to the header of the list to make the node A new header of the list.
Addtail () adds a node at the end of the list to make it the new end of the list.
Removeall () deletes all elements of a node.
Getheadposition () obtains the position of the header node in the list.
Gettailposition () obtains the position of the end node in the list.
Getnext () gets the value outside the next node at the specified position
Getprev () gets the value outside the previous node at the specified position
Getat () obtains the value of the node at the specified position.
Setat () sets the node value at the specified position
Removeat () deletes a node at a specified position
Insertbefore () inserts a node before the specified position
Insertafter () inserts a node behind the specified position
Find () searches for a given object pointer in the list order and returns a position type.
Findindex () Searches the specified subscript in the list order
Getcount () is based on the number of nodes contained in the list.
Isempty () checks whether a list contains any node
Iii. Use of ing classes:
You can use the ing Class to create a query table. Including cmapptrtoptr, cmapptrtoword, cmapstringtoob, cmapstringtoptr, cmapstringtostring, cmapwordtoob, and cmapwordtoptr.
Lookup () queries the value mapped to the specified keyword
Setat () inserts an element into the ing. If the specified keyword exists, it replaces the original element.
OPERATOR [] inserts an element into the ing, which acts the same as setat ().
Removekey () queries mappings that match the keyword. If any, delete this element.
Removeall () risk ing all elements
Getstarposition () obtains the position of the first element in the ing. The first element in the ing is unpredictable, so the first element in the ing actually has no specific meaning. Generally, this value is passed to the getnextassoc () function.
Getnextassoc () obtains the next element at the specified position in the ing.
Getcount () count
Isempty ()
Iv. Use of string classes:
Cstring ()
Getlength ()
Isempty ()
Empty ()
Getat () obtains the characters at the specified position of the string.
OPERATOR [] gets the character at the specified position of the string, which is used in the same way as getat ().
Setat () specifies the character at the specified position of the string.
Operator lpctstr returns a pointer to a character stored in a cstring class object.
Operator =
Operator + combines two strings into a new string
Operator + = add another string after a string
Compare () compares two strings
Comparenocase () ignores case-insensitive comparison of two strings
Mid ()
Left () left
Right ()
Spanincluding () extracts substrings containing characters in the specified character array from a string
Spanencluding () extracts substrings from strings that do not contain characters in the specified character array
Makeupper () Capital
Makelower () lower case
Makereverse () invert the string
Format () formats strings like sprintf () Functions
Trimleft ()
Trimright () deletes the white space at the right end of the string
Formatmessage () format the message string
Find () searches for the specified character or string in the string
Reversefind () returns the subscript of the character that matches the specified character for the last time in the string
Findoneof () Searches the string for the first character that matches the specified character
Getbuffer () gets the pointer to the characters in the cstring object
Getbuffersetlength () gets the pointer to the characters in the cstring object, but can only intercept characters of the specified length
Releasebuffer () releases the string returned by the getbuffer () function in the buffer.
Lockbuffer () copies the string and locks it into the buffer.
Unlockbuffer () locks the string that calls the lockbuffer () function into the buffer to unlock
Loadstring () loads an existing
V. Use of date and time:
Ctime () creates a cttime object
Getcurrenttime () creates a ctime object from the current time
Gettime () returns a time_t variable from the ctime object.
Getyear () gets the month represented by the ctime object
Getmonth () gets the month represented by the ctime object
Getday () gets the date represented by the ctime object
Gethour () obtains the hour represented by the ctime object.
Getminute () gets the score represented by the ctime object
Getsecond () gets the second represented by the ctime object
Getdayofweek () obtains the Sunday represented by the ctime object, 1 indicates Sunday, 2 indicates Monday, and so on.
Format () converts a string into a local time zone-based format string. Its Parameters include:
% A short Date name. For example, SAT represents Saturday.
% A Date name, not abbreviated
% B abbreviated month name, for example, Mar stands for March
% B month name, not abbreviated
% C normalized Date and Time
The number of days in % d month. The value ranges from 01 to 31.
The hour in the 24-hour format. The value ranges from 00 to 23.
% I is generally a 12-hour. The value ranges from 01 to 12.
% J the number of days in the year. The value ranges from 001 to 366
% M months, ranging from 01 to 12
% M minutes, between 00 and 59
% P indicates a. M/P. M (morning/afternoon) in 12-hour format)
% S seconds. The value ranges from 00 to 59.
% U the number of weeks in a year. The value ranges from 00 to 51. The first day of a week is Sunday.
The number of days in week % W. The value ranges from 0 to 6, and 0 indicates Sunday.
The number of weeks in the year of % W. The value ranges from 00 to 51, and the first day of the week is Monday.
% X localized date Representation
% X localized Time Representation
% Y indicates the number of years without the age prefix. The value ranges from 00 to 99.
% Y number of years with an age prefix
% Z abbreviated time zone name
% Z undefined time zone name
% Percent sign
Formatgmt () converts a string into a UTC (Universal Time)-based format string.
Ctimespan class consists of the following member functions:
Ctimespan () constructs a ctimespan Class Object
Getdays () Get the full number of days contained in the ctimespan Class Object
Gethours () obtains the hour of the current day. The value ranges from-23 to 23.
Gettotalhours () gets the complete hours in the ctimespan class
Getminutes () obtains the number of days in the current hour. The value ranges from-59 to 59.
Gettotalminutes () obtains the complete scores contained in ctimespan class objects.
Getsecond () obtains the number of seconds in the current minute. The value ranges from-59 to 59.
Format () converts a ctimespan class object into a format string