The HDM_GETITEMCOUNT message retrieves a count of the items in a header control. You can send this message explicitly or by using the Header_GetItemCount macro.
HDM_GETITEMCOUNT wParam = 0; lParam = 0;
If the operation succeeds, the return value is the number of items.
If the operation fails, the return value is - 1.