Visual Studio C++ 2010
Proč funkce LinkListBox_Add vrací indexy které nejsou unikátní? Ukládám to do pole které má obsahovat unikátní indexy, ale oni se opakují.
int terrainIndecies[MAX_TERRAINS]; // needed to select item in sorted list/combo
int * pTerrainIndecies = terrainIndecies;
LinkListBox_Fill_keepAssociations(GetDlgItem(dialog, IDC_TR_ID),
esdata.terrains.head(), pTerrainIndecies);
int LinkListBox_Fill_keepAssociations(HWND listbox, Link *list, int * associations)
{
int index;
for (; list; list = list->next()){
index = LinkListBox_Add(listbox, list);
associations[list->id()] = index; // save for purposes of ordered list to select correct item
}
return *associations;
}
LRESULT LinkListBox_Add(HWND listbox, const Link *link)
{
WPARAM index = List_AddStringW(listbox, link->name());
LPCWSTR name = link->name();
int ID = link->id();
List_SetItemData(listbox, index, link);
return index;
}
cycle 1:
ID: 0
index: 0
name: Grass 1
cycle 2:
index: 1
ID: 1
name: Water, Shallow
cycle 3:
index: 0 (WHY???)
ID: 2
name: Beach
cycle 4:
index: 1 (WHY???)
ID: 3
name: Dirt 3
cycle 5:
index: 3 (WHY???)
ID: 4
name: Shallows
cycle 6
index: 3 (WHY???)
ID: 5
name: Leaves
List_AddStringW vrací index z SendMessageW:
inline LRESULT List_AddStringW(HWND control, LPCWSTR string)
{
return SendMessageW(control, LB_ADDSTRING, 0, (LPARAM)string);
}