CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 33 of 33
  1. #31
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Coloring header row of CListCtrl C++

    Quote Originally Posted by Beginner_MFC View Post
    Resolved..Thankyou
    Could you share your solution?
    Victor Nijegorodov

  2. #32
    Join Date
    Oct 2019
    Posts
    82

    Re: Coloring header row of CListCtrl C++

    Derive your own class from CListCtrl.
    Derive your own class from CHeaderCtrl.
    Replace the standard CListCtrl header with yours.
    Use custom drawing for the header control.
    In derived CListCtrl
    Code:
    void MyListCtrl::PreSubclassWindow()
        {
        // TODO: Add your specialized code here and/or call the base class
        CHeaderCtrl* pHeader = NULL;
        pHeader = GetHeaderCtrl();
        if (pHeader != NULL)
            {
            VERIFY(m_HeaderCtrl.SubclassWindow(pHeader->m_hWnd)); // m_HeaderCtrl is the new wrapper object
            }
    
        CListCtrl::PreSubclassWindow();
        }
    In the headerCtrl class
    Code:
    void MyHeader::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
        {
        LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
        // TODO: Add your control notification handler code here
        *pResult = CDRF_DODEFAULT;
    
        if (pNMCD->dwDrawStage == CDDS_PREPAINT)
            {
            CDC* pDC = CDC::FromHandle(pNMCD->hdc);
            CRect rect(0, 0, 0, 0);
            GetClientRect(&rect);
            pDC->FillSolidRect(&rect, RGB(255, 0, 0));
    
            *pResult = CDRF_NOTIFYITEMDRAW;
            }
        else if (pNMCD->dwDrawStage == CDDS_ITEMPREPAINT)
            {
            HDITEM hditem;
            TCHAR buffer[MAX_PATH] = { 0 };
            SecureZeroMemory(&hditem, sizeof(HDITEM));
            hditem.mask = HDI_TEXT;
            hditem.pszText = buffer;
            hditem.cchTextMax = MAX_PATH;
            GetItem(pNMCD->dwItemSpec, &hditem);
            CDC* pDC = CDC::FromHandle(pNMCD->hdc);
            pDC->SetTextColor(RGB(0, 0, 0));
            pDC->SetBkColor(RGB(255, 0, 0));
            CString str(buffer);
            pDC->DrawText(str, CRect(pNMCD->rc), DT_VCENTER | DT_LEFT);
            *pResult = CDRF_SKIPDEFAULT;
            }
        }

  3. #33
    Join Date
    Oct 2019
    Posts
    82

    Changing color of Button in ZApp

    Has anyone worked upon ZApp(third party),if yes than plz tell how to change the color of button in a dialog of ZApp.

Page 3 of 3 FirstFirst 123

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured