There are many rect records on the progress bar. Each rect shows an operation name. When the name is too long to display all records, you need to process the string. My method is to directly display the string in the middle of the rect when the length of the string is smaller than the width of the rect. When the value is greater than the rect width, the rect width must be used as the reference. Specific implementation of C ++CodeAs follows:
csize size = dc. gettextextent (STR);
If (size. CX <= m_parrrects [I]. height () // when rect. weigth <= Currently rect. height, direct showing;
{< br> DC. textout (m_parrrects [I]. centerpoint (). X + size. cy/2, m_parrrects [I]. centerpoint (). y-size.cx/2, STR);
}< br> else // when rect. weigth> currently rect. height, delete the end character to adapt the rect
{< br> int strlength = (m_parrrects [I]. height ()-40)/10;
If (strlength % 2 = 1) // use for Jap, and Chinese
{< br> strlength = strlength + 1;
}< br> cstring stradd = "... ";
cstring strshort;
strshort = Str. left (strlength);
strshort + = stradd;
DC. textout (m_parrrects [I]. centerpoint (). X + size. cy/2, m_parrrects [I]. top, strshort);
}