CMFCTaskPane-Highlighting/DeHighlighting task text on clicking the task

abc abc 351 Reputation points


In CMFCTaskPane, I want to change the text color of the task in blue when click on the task text.
I am able to change task color using BOOL SetTaskTextColor(int nGroup, int nTask, COLORREF color, COLORREF colorHot = (COLORREF)-1); but when I clicking another task I need to dehighlight previously selected task.I dont know how to do it. please help me

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,602 questions
0 comments No comments
{count} votes

Accepted answer
  1. RLWA32 42,161 Reputation points

    For example, using the MFC TaskPanes sample at TasksPane to set clicked task text to green

    Add to the bottom of CTaskPane class in TaskPane.h -

        BOOL CreateTreeControl();
        BOOL CreateEditControl();
        int  m_prevGroup{ -1 }; //Added by RLWA32
        int  m_prevTask{ -1 };  //Added by RLWA32
        COLORREF m_prevClr;  //Added by RLWA32
    // Implementation
        virtual ~CTaskPane();
        virtual void OnClickTask(int nGroupNumber, int nTaskNumber, UINT uiCommandID, DWORD_PTR dwUserData);  //Added by RLWA32
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

    Add OnClickTask override to TaskPane.cpp -

    void CTaskPane::OnClickTask(int nGroupNumber, int nTaskNumber, UINT uiCommandID, DWORD_PTR dwUserData)
        if (nGroupNumber != m_prevGroup || nTaskNumber != m_prevTask)
            if (m_prevGroup != -1 && m_prevTask != -1)
                SetTaskTextColor(m_prevGroup, m_prevTask, m_prevClr);
        m_prevGroup = nGroupNumber;
        m_prevTask = nTaskNumber;
        m_prevClr = GetTask(nGroupNumber, nTaskNumber)->m_clrText;
        SetTaskTextColor(nGroupNumber, nTaskNumber, RGB(0, 255, 0));
        CMFCTasksPane::OnClickTask(nGroupNumber, nTaskNumber, uiCommandID, dwUserData);
    0 comments No comments

0 additional answers

Sort by: Most helpful