Hello,
Yes, sorry was changed. use DrawControlText method:
CSize CControlStatic::GetSize(CDC* pDC) { // This function is used to determine the size // of the bounding rectangle of the text. The // function returns the size of the rectangle in // a CSize object.
// Determine if the toolbar is docked horizontally or vertically. BOOL bVert = GetParent()->GetPosition() == xtpBarRight || GetParent()->GetPosition() == xtpBarLeft;
// Instantiate an empty CRect object to hold the // size of the bounding rectangle of the text. CXTPEmptyRect rcText;
// Function declaration for the DrawTextEx function: // CSize DrawTextEx( // CDC* pDC, A pointer to the current device context. // CString str, A CString object that contains the text to draw. // CRect rcText, A CRect object that is used to hold the size of the bounding rectangle of the text. // BOOL bDraw, If TRUE, then the text is drawn. If FALSE, then the function returns the size of the bounding rectangle of the text. // BOOL bVert, TRUE if the toolbar is docked in a vertical position. // BOOL bCentered, TRUE if the text is drawn centered. // BOOL bTriangled, If TRUE, then an arrow is drawn at the end of the text. // BOOL bEmbosssed = FALSE, TRUE to draw the text embossed. // );
// Do not draw the text, just get the size of the bounding rectangle of the text. CSize sz = GetPaintManager()->DrawControlText(pDC, this, &rcText, FALSE, bVert, FALSE, FALSE);
// If the toolbar is docked in a vertical position, // then the minimum width of the bounding rectangle is 22. // The height of the bounding rectangle is the length of the text. if (bVert) return CSize(max(22, sz.cx), sz.cy);
// If the toolbar is drawn in a horizontal position, then // the length of the bounding rectangle is the length of the text. // The height of the bounding rectangle is a minimum of 22. return CSize(sz.cx, max(22, sz.cy)); }
void CControlStatic::Draw(CDC* pDC) { // Determine if the toolbar is docked horizontally or vertically. BOOL bVert = GetParent()->GetPosition() == xtpBarRight || GetParent()->GetPosition() == xtpBarLeft;
// Get the bounding rectangle of the control. CRect rcText = GetRect();
// Function declaration for DrawControlEntry: // DrawControlEntry( // CDC* pDC, Pointer to a valid device context // CRect rc, Rectangle to draw. // BOOL bEnabled, TRUE if the control is enabled. // BOOL bSelected, TRUE if the control is selected. // BOOL bPressed, TRUE if the control is pushed. // BOOL bChecked, TRUE if the control is checked. // BOOL bPopuped, TRUE if the control is popuped. // XTPBarPosition barPosition, Parent's bar position. // ); // This method is called to fill the control's face. pDC->SetTextColor(GetPaintManager()->GetRectangleTextColor(FALSE, FALSE, GetEnabled(), FALSE, FALSE, GetParent()->GetType(), GetParent()->GetPosition()));
// Function declaration for the DrawTextEx function: // CSize DrawTextEx( // CDC* pDC, A pointer to the current device context. // CString str, A CString object that contains the text to draw. // CRect rcText, A CRect object that is used to hold the size of the bounding rectangle of the text. // BOOL bDraw, If TRUE, then the text is drawn. If FALSE, then the function returns the size of the bounding rectangle of the text. // BOOL bVert, TRUE if the toolbar is docked in a vertical position. // BOOL bCentered, TRUE if the text is drawn centered. // BOOL bTriangled, If TRUE, then an arrow is drawn at the end of the text. // BOOL bEmbosssed = FALSE, TRUE to draw the text embossed. // ); // GetEnabled() returns TRUE if the control is enabled; otherwise FALSE. GetPaintManager()->DrawControlText(pDC, this, &rcText, TRUE, bVert, TRUE, FALSE); }
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|