Click here to Skip to main content
15,884,099 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Timer not working properly. Pin
Kenneth Haugland6-Apr-13 3:06
mvaKenneth Haugland6-Apr-13 3:06 
AnswerRe: Timer not working properly. Pin
Le@rner10-Apr-13 22:07
Le@rner10-Apr-13 22:07 
QuestionRetaining selection on a ListCtrl Item Pin
Donguy19764-Apr-13 14:21
Donguy19764-Apr-13 14:21 
AnswerRe: Retaining selection on a ListCtrl Item Pin
SoMad4-Apr-13 15:07
professionalSoMad4-Apr-13 15:07 
GeneralRe: Retaining selection on a ListCtrl Item Pin
Donguy19765-Apr-13 9:27
Donguy19765-Apr-13 9:27 
GeneralRe: Retaining selection on a ListCtrl Item Pin
SoMad5-Apr-13 10:47
professionalSoMad5-Apr-13 10:47 
GeneralRe: Retaining selection on a ListCtrl Item Pin
Donguy19765-Apr-13 11:32
Donguy19765-Apr-13 11:32 
GeneralRe: Retaining selection on a ListCtrl Item Pin
SoMad5-Apr-13 21:39
professionalSoMad5-Apr-13 21:39 
Things like that are normally done by overloading the list controls OnCustomdraw(). To do this, you use your own class derived from CListCtrl. If you want more information on that, check this (or you can Google):
http://msdn.microsoft.com/en-us/library/ms364048(v=vs.80).aspx[^]

Here is an OnCustomdraw() I copied from existing code and modified to do what you want it to do (hopefully). It is untested, so I don't actually know if it will work correctly (or even compile), but go ahead and try it out.
C++
void CYourListCtrl::OnCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
{
    NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );

    // Take the default processing unless we set this to something else below.
    *pResult = 0;

    // First thing - check the draw stage. If it's the control's prepaint
    // stage, then tell Windows we want messages for every item.
    if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
    {
        *pResult = CDRF_NOTIFYITEMDRAW;
    }
    else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
    {
        // This is the prepaint stage for an item. Here's where we set the
        // item's text color. Our return value will tell Windows to draw the
        // item itself, but it will use the new color we set here.

        // Do not apply special behavior if the list control is disabled.
        if (IsWindowEnabled())
        {
            int nItem = (int)pLVCD->nmcd.dwItemSpec;

            // Always draw the selected item with the highlight color.
            if (GetItemState(nItem, LVIS_SELECTED | LVIS_FOCUSED) != 0)
            {
                // Store the color back in the NMLVCUSTOMDRAW struct.
                pLVCD->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT);

                pLVCD->clrTextBk = GetSysColor(COLOR_HIGHLIGHT);

                // Tell Windows to paint the control itself.
                *pResult = CDRF_DODEFAULT;
            }
        }
    }
}


Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty

QuestionHow to resize a dialog? Pin
Donguy19764-Apr-13 14:18
Donguy19764-Apr-13 14:18 
AnswerRe: How to resize a dialog? Pin
Garth J Lancaster4-Apr-13 15:24
professionalGarth J Lancaster4-Apr-13 15:24 
AnswerRe: How to resize a dialog? Pin
David Crow5-Apr-13 3:19
David Crow5-Apr-13 3:19 
Questionhow to calculate size for printing? Pin
VCProgrammer4-Apr-13 2:15
VCProgrammer4-Apr-13 2:15 
AnswerRe: how to calculate size for printing? Pin
Richard MacCutchan4-Apr-13 2:28
mveRichard MacCutchan4-Apr-13 2:28 
GeneralRe: how to calculate size for printing? Pin
VCProgrammer4-Apr-13 2:36
VCProgrammer4-Apr-13 2:36 
GeneralRe: how to calculate size for printing? Pin
Richard MacCutchan4-Apr-13 3:13
mveRichard MacCutchan4-Apr-13 3:13 
QuestionHow to create manifest file for private assembly Pin
Naveen3-Apr-13 16:33
Naveen3-Apr-13 16:33 
QuestionSimple chat across internet without server Pin
jeff63-Apr-13 2:42
jeff63-Apr-13 2:42 
AnswerRe: Simple chat across internet without server Pin
Richard MacCutchan3-Apr-13 3:25
mveRichard MacCutchan3-Apr-13 3:25 
AnswerRe: Simple chat across internet without server Pin
CPallini3-Apr-13 22:22
mveCPallini3-Apr-13 22:22 
Questionsource code Pin
raj suthar2-Apr-13 7:47
raj suthar2-Apr-13 7:47 
AnswerRe: source code PinPopular
Chris Losinger2-Apr-13 7:48
professionalChris Losinger2-Apr-13 7:48 
GeneralRe: source code Pin
raj suthar2-Apr-13 7:54
raj suthar2-Apr-13 7:54 
GeneralRe: source code Pin
Chris Losinger2-Apr-13 7:55
professionalChris Losinger2-Apr-13 7:55 
AnswerRe: source code Pin
Richard MacCutchan2-Apr-13 9:19
mveRichard MacCutchan2-Apr-13 9:19 
GeneralRe: source code Pin
Captain Price2-Apr-13 17:02
professionalCaptain Price2-Apr-13 17:02 

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.