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);
					}
				}

Please learn to format your code better so we can read it. Pay attention to the Indentation section.

Look at the parameter types in the function call you're having trouble with. What are the variable types the function expects, and what are the variable types you are passing?

Refined...

//~

int *buf = GlobalAlloc(GPTR, sizeof(int) * count);

//~

Ok, maybe I am asking the wrong question.
What confuses me, is that "buf" is not declared before the "*buf" pointer. How can that be?
I am using MSVC, when you hover over *buf it says it is declared right there.

This question has already been answered. Start a new discussion instead.