Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 10: Characteristics of a Window's Frame


{
CExoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

CString Term = "Information Superhighway";

pDC->TextOut(20, 22, Term);
}

9.7.3 String Copy...........................................................................................


Making a copy of a string consists of providing its value to another string. If you already
have a CString initialized and you want to copy its value into another CString variable,
you can use the following constructor:

CString(const CString& stringSrc);

This constructor is used to declare a CString variable and provide it with the value of
another CString variable. Here is an example:

void CExerciseView::OnDraw(CDC* pDC)
{
CExerciseDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

CString Term = "Information Superhighway";
CString Description(Term);

pDC->TextOut(20, 22, Description);

}

9.7.4 Strings and Their Cases......................................................................


In US English, the following alphabetical letters are referred to as lowercase a, b, c, d, e,
f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z. Their equivalents in uppercase are A,
B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z. The digits 0, 1,
2, 3, 4, 5, 6, 7, 8, 9, and the other characters are considered “as is”.

To convert a lowercase CString variable to uppercase, you can call the MakeUpper()
method. Its syntax is:

void MakeUpper();

When executed, this method would examine each character of the string. If a character is
a lowercase letter, it would be converted to uppercase. If a character is already in
uppercase, it be left in uppercase. If the character is not a letter, it would be left intact. On
the other hand, to convert the characters of a string to lowercase, call the MakeLower()
method. Its syntax is:

void MakeLower();
Free download pdf