Click here to Skip to main content
15,868,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ formatting into a buffer - why so elephanting difficult? Pin
CPallini23-Nov-17 22:29
mveCPallini23-Nov-17 22:29 
GeneralRe: C++ formatting into a buffer - why so elephanting difficult? Pin
charlieg29-Nov-17 11:19
charlieg29-Nov-17 11:19 
GeneralRe: C++ formatting into a buffer - why so elephanting difficult? Pin
CPallini29-Nov-17 11:42
mveCPallini29-Nov-17 11:42 
AnswerRe: C++ formatting into a buffer - why so elephanting difficult? Pin
Rick York25-Nov-17 19:53
mveRick York25-Nov-17 19:53 
QuestionCStatic::Drawitem gets called repeatledly Pin
ForNow15-Nov-17 16:35
ForNow15-Nov-17 16:35 
AnswerRe: CStatic::Drawitem gets called repeatledly Pin
Jochen Arndt15-Nov-17 21:15
professionalJochen Arndt15-Nov-17 21:15 
GeneralRe: CStatic::Drawitem gets called repeatledly Pin
ForNow17-Nov-17 3:42
ForNow17-Nov-17 3:42 
AnswerRe: CStatic::Drawitem gets called repeatledly Pin
Jochen Arndt17-Nov-17 4:01
professionalJochen Arndt17-Nov-17 4:01 
SetWindowText() sets the text and initiates drawing which must be implemented in your DrawItem function!

Example (copied & pasted, unchecked, unthemed classic method):
void CMyStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    ASSERT(lpDrawItemStruct->CtlType == ODT_STATIC);
    CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
    ASSERT(pDC != NULL);
    pDC->FillSolidRect(&lpDrawItemStruct->rcItem, m_clrBkGnd);
    
    CString str;
    GetWindowText(str);
    if (!str.IsEmpty())
    {
        // Get text format options.
        UINT nFormat = m_nFormat;
        // get actual settings in case they has been changed
        DWORD dwStyle = GetStyle(); 
        // Don't process '&' prefix sequences
        if (dwStyle & SS_NOPREFIX) 
            nFormat |= DT_NOPREFIX;
        // vertically centered text and no new line
        if ((dwStyle & SS_CENTERIMAGE) && str.Find(_T('\n')) < 0)
        {
            nFormat &= ~DT_WORDBREAK;
            nFormat |= DT_VCENTER | DT_SINGLELINE;	// must set both!
        }
        if (dwStyle & SS_ELLIPSISMASK)
        {
            nFormat &= ~DT_EXPANDTABS; // not supported with ellipsis
            switch (dwStyle & SS_ELLIPSISMASK)
            {
                case SS_ENDELLIPSIS : 
                    nFormat |= DT_END_ELLIPSIS | DT_MODIFYSTRING; break;
                case SS_PATHELLIPSIS : 
                    nFormat |= DT_PATH_ELLIPSIS | DT_MODIFYSTRING; break;
                case SS_WORDELLIPSIS : 
                    nFormat |= DT_WORD_ELLIPSIS; break;
            }
        }
        // The complete background has just been filled.
        // So use transparent mode for faster text drawing.
        // Saving and restoring of colors and mode is not necessary (drawing only performed here).
        pDC->SetBkMode(TRANSPARENT);
        pDC->SetTextColor(bDisabled ? ::GetSysColor(COLOR_GRAYTEXT) : m_clrText);
        
        // The text string may be modified if DT_MODIFYSTRING is set!
        LPTSTR lpszText = str.GetBuffer();
        pDC->DrawText(lpszText, -1, &lpDrawItemStruct->rcItem, nFormat);
        str.ReleaseBuffer();
    }
}

GeneralRe: CStatic::Drawitem gets called repeatledly Pin
ForNow17-Nov-17 4:10
ForNow17-Nov-17 4:10 
GeneralRe: CStatic::Drawitem gets called repeatledly Pin
ForNow19-Nov-17 3:30
ForNow19-Nov-17 3:30 
GeneralRe: CStatic::Drawitem gets called repeatledly Pin
Jochen Arndt19-Nov-17 7:35
professionalJochen Arndt19-Nov-17 7:35 
GeneralRe: CStatic::Drawitem gets called repeatledly Pin
ForNow19-Nov-17 8:38
ForNow19-Nov-17 8:38 
GeneralRe: CStatic::Drawitem gets called repeatledly Pin
Jochen Arndt19-Nov-17 21:27
professionalJochen Arndt19-Nov-17 21:27 
GeneralRe: CStatic::Drawitem gets called repeatledly Pin
ForNow20-Nov-17 1:28
ForNow20-Nov-17 1:28 
QuestionHiding tab control for CPropertySheet Pin
Joe Woodbury14-Nov-17 15:13
professionalJoe Woodbury14-Nov-17 15:13 
AnswerRe: Hiding tab control for CPropertySheet Pin
David Crow15-Nov-17 2:38
David Crow15-Nov-17 2:38 
AnswerRe: Hiding tab control for CPropertySheet Pin
Victor Nijegorodov15-Nov-17 5:30
Victor Nijegorodov15-Nov-17 5:30 
GeneralRe: Hiding tab control for CPropertySheet Pin
Joe Woodbury15-Nov-17 7:14
professionalJoe Woodbury15-Nov-17 7:14 
GeneralRe: Hiding tab control for CPropertySheet Pin
Victor Nijegorodov15-Nov-17 10:13
Victor Nijegorodov15-Nov-17 10:13 
QuestionDumping Derived CStatic Object Pin
ForNow9-Nov-17 13:02
ForNow9-Nov-17 13:02 
QuestionRe: Dumping Derived CStatic Object Pin
David Crow9-Nov-17 16:13
David Crow9-Nov-17 16:13 
AnswerRe: Dumping Derived CStatic Object Pin
ForNow10-Nov-17 3:04
ForNow10-Nov-17 3:04 
GeneralRe: Dumping Derived CStatic Object Pin
leon de boer12-Nov-17 6:00
leon de boer12-Nov-17 6:00 
QuestionQuantum Computing sim ? Pin
bluatigro7-Nov-17 22:42
bluatigro7-Nov-17 22:42 
AnswerRe: Quantum Computing sim ? Pin
CPallini7-Nov-17 22:58
mveCPallini7-Nov-17 22:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.