Listbox.Clear .Add Methods
Much like in VB, I figured I would need to create some fancy listbox functions for C++.
Here is one I cannot seem to get to work properly.
PHP Code:
//------------------
//Add an item to the list
//------------------
void ListBox::AddItem(char* Item)
{
//add string
SendMessage(m_hwnd, LB_ADDSTRING, 0, (LPARAM)Item);
SendMessage(m_hwnd, LB_SETITEMDATA, m_IndexCount, (LPARAM)m_IndexCount);
m_IndexCount++;
}
//------------------
//Clear the entire list
//------------------
void ListBox::Clear()
{
LRESULT lRet;
for (int Index = 0; Index < m_IndexCount+1; Index++)
{
lRet = SendMessage(m_hwnd, LB_DELETESTRING, Index,0);
}
m_IndexCount = 0;
}
So I add a bunch of strings using the Add function, then I try and clear it all.
Well now and then it clears all but one, sometimes all but two depending on how many I add. If it clears all but 1 or 2, or more..then I can just keep pressing it and it gets rid of everything one at a time.
What is going on????