0

I am new to MFC PROGRAMMING. I use vs 2008, in a Dialog Based App. I want to call bellow function on a button click event...? When I call like SortList(listboxone); is giving an error that SortList not found...! Please help me..!!

void SortList(CListBox& templistbox)
{   
    DWORD_PTR abc;
    int a=templistbox.GetCurSel();// Select current  Item Index    
    if(a<templistbox.GetCount()-1)
    {
        abc = (DWORD_PTR )templistbox.GetItemData(a);
        a++;
        templistbox.SetItemData(a,(DWORD_PTR) templistbox.GetItemData(templistbox.GetCurSel()));
    }
}

Sorry now I changed the function to as above but still gives same error.

Dharma Cool
  • 197
  • 1
  • 2
  • 11

1 Answers1

2

You probably are calling the function above the function definition. In C/C++, you need to define the function (or it's prototype at least) before calling the function. Put this:

void SortList(CListBox& templistbox);

at the the top of the source file.

Mohammad Dehghan
  • 17,853
  • 3
  • 55
  • 72
  • Well, not entirely true. You can declare *or* define the function, before using it. You can even do both, if you want, but you must do at least one of those two. – Nik Bougalis Mar 20 '13 at 17:02