title: getting IDC_LISTBOX_EXAMPLE is undefined error while trying to create listbox c++
body: <p>I've wanted to create such simple multiple selection allowed listbox and to do that, I've done the following: BTW I'm using visual studio 2013 ultimate </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Windows.h"
  #include "Strsafe.h"
  #include "Afxres.h"
  
  
  typedef struct 
  { 
      TCHAR achName[MAX_PATH]; 
      TCHAR achPosition[12]; 
      int nGamesPlayed; 
      int nGoalsScored; 
  } Player; 
  
  Player Roster[] = 
  { 
      {TEXT("Haas, Jonathan"), TEXT("Midfield"), 18, 4 }, 
      {TEXT("Pai, Jyothi"), TEXT("Forward"), 36, 12 }, 
      {TEXT("Hanif, Kerim"), TEXT("Back"), 26, 0 }, 
      {TEXT("Anderberg, Michael"), TEXT("Back"), 24, 2 }, 
      {TEXT("Jelitto, Jacek"), TEXT("Midfield"), 26, 3 }, 
      {TEXT("Raposo, Rui"), TEXT("Back"), 24, 3}, 
      {TEXT("Joseph, Brad"), TEXT("Forward"), 13, 3 }, 
      {TEXT("Bouchard, Thomas"), TEXT("Forward"), 28, 5 }, 
      {TEXT("Salmre, Ivo "), TEXT("Midfield"), 27, 7 }, 
      {TEXT("Camp, David"), TEXT("Midfield"), 22, 3 }, 
      {TEXT("Kohl, Franz"), TEXT("Goalkeeper"), 17, 0 }, 
  }; 
  
  
  INT_PTR CALLBACK ListBoxExampleProc(HWND hDlg, UINT message, 
          WPARAM wParam, LPARAM lParam)
  {
      switch (message)
      {
      case WM_INITDIALOG:
          {
              // Add items to list. 
              HWND hwndList = GetDlgItem(hDlg, IDC_LISTBOX_EXAMPLE);  
              for (int i = 0; i &lt; ARRAYSIZE(Roster); i++) 
              { 
                  int pos = (int)SendMessage(hwndList, LB_ADDSTRING, 0, 
                      (LPARAM) Roster[i].achName); 
                  // Set the array index of the player as item data.
                  // This enables us to retrieve the item from the array
                  // even after the items are sorted by the list box.
                  SendMessage(hwndList, LB_SETITEMDATA, pos, (LPARAM) i); 
              } 
              // Set input focus to the list box.
              SetFocus(hwndList); 
              return TRUE;               
          } 
  
      case WM_COMMAND:
          switch (LOWORD(wParam))
          {
          case IDOK:
          case IDCANCEL:
              EndDialog(hDlg, LOWORD(wParam));
              return TRUE;
  
          case IDC_LISTBOX_EXAMPLE:
              {
                  switch (HIWORD(wParam)) 
                  { 
                  case LBN_SELCHANGE:
                      {
                          HWND hwndList = GetDlgItem(hDlg, IDC_LISTBOX_EXAMPLE); 
  
                          // Get selected index.
                          int lbItem = (int)SendMessage(hwndList, LB_GETCURSEL, 0, 0); 
  
                          // Get item data.
                          int i = (int)SendMessage(hwndList, LB_GETITEMDATA, lbItem, 0);
  
                          // Do something with the data from Roster[i]
                          TCHAR buff[MAX_PATH];
                          StringCbPrintf (buff, ARRAYSIZE(buff),  
                              TEXT("Position: %s\nGames played: %d\nGoals: %d"), 
                              Roster[i].achPosition, Roster[i].nGamesPlayed, 
                              Roster[i].nGoalsScored);
  
                          SetDlgItemText(hDlg, IDC_STATISTICS, buff); 
                          return TRUE; 
                      } 
                  }
              }
              return TRUE;
          }
      }
      return FALSE;
  }
  </code></pre>
  
  <p>Altough I've included everything I need I get the following errors:</p>
  
  <pre><code>Error:identifer "IDC_LISTBOX_EXAMPLE" is undefined.
  </code></pre>
  
  <p>Why I'm getting such an error ? Is there anyone to help me ? </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm not using MFC template , do I have to ? </p>