I have been trying to figure this one out for a while, so please don't laugh.
I know it is a little messed up.
I didn't include the whole code, if necessary I will post more.
The line indicated is giving me a "cannot convert from 'HGLOBAL' to 'int *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast"
I get typecasting, just not with type HGLOBAL.
case IDC_REMOVE:
{
// When the user clicks the Remove button, we first get the number
// of selected items
HWND hList = GetDlgItem(hwnd, IDC_LIST);
int count = SendMessage(hList, LB_GETSELCOUNT, 0, 0);
if(count != LB_ERR)
{
if(count != 0)
{
// And then allocate room to store the list of selected items.
int i;
-------> int *buf = GlobalAlloc(GPTR, sizeof(int) * count);
SendMessage(hList, LB_GETSELITEMS, (WPARAM)count,
LPARAM)buf);
// Now we loop through the list and remove each item that was
// selected.
// WARNING!!!
// We loop backwards, because if we removed items
// from top to bottom, it would change the indexes of the other
// items!!!
for(i = count - 1; i >= 0; i--)
{
SendMessage(hList, LB_DELETESTRING, (WPARAM)buf[i], 0);
}
GlobalFree(buf);
}
else
{
MessageBox(hwnd, "No items selected.", "Warning", MB_OK);
}
}
else
{
MessageBox(hwnd, "Error counting items :(", "Warning", MB_OK);
}
}