void FillTypeArray(
		ListBox& ListMajor, 
		ListBox& ListMinor,
		GUID *atypes, 
		int nIndex, 
		DWORD *pdwPairs
	)
{
    UINT nMajorSel = 0, nMinorSel = 0; 
		
	BOOL result = ListMajor.GetCurrentSelection(&nMajorSel);
    // If no selection ("don't care"), just exit without modifying the array
	if (!result || nMajorSel == 0)
	{
        return;
	}

    // Get GUID for major type
    const GUID *p1 = (const GUID *)ListMajor.GetItem(nMajorSel);

    // Since the FilterMapper interface requires GUIDs (instead of GUID *),
    // copy the specified GUID data into its array slot.
    if (p1)
	{
        memcpy(&atypes[nIndex], p1, sizeof(GUID));
	}
    else
	{
        memset(&atypes[nIndex], 0, sizeof(GUID));
	}

    // Increment number of type/subtype pairs
    (*pdwPairs)++;

	result = ListMinor.GetCurrentSelection(&nMinorSel);

    // If no selection ("don't care"), or uninitialized (returning -1),
    // just exit without modifying the array
    if (!result || nMinorSel == 0)
	{
        return;
	}
    
    // Get GUID for subtype
    const GUID *p2 = (const GUID *)ListMinor.GetItem(nMinorSel);

    if (p2)
	{
        memcpy(&atypes[nIndex+1], p2, sizeof(GUID));
	}
    else
	{
        memset(&atypes[nIndex+1], 0, sizeof(GUID));
	}
}
void EnableSecondTypePair(
		ListBox& ListMajor, 
        ListBox& ListMajor2, 
		ListBox& ListMinor2
	)
{
    // If there is no selection in the first major type listbox,
    // clear and disable the second major/minor type listboxes.

	UINT selection = 0;
	ListMajor.GetCurrentSelection(&selection);

    if (selection == 0)
    {
        ListMajor2.Select(0);
        FillSubType(ListMajor2, ListMinor2);

        ListMajor2.Enable(FALSE);
        ListMinor2.Enable(FALSE);
    }
    else
    {
        ListMajor2.Enable(TRUE);
        ListMinor2.Enable(TRUE);
    }
}
void FillSubType(ListBox& listboxMajor, ListBox& listboxMinor)
{
    const GUIDINFO *pSubtype;
    UINT nSelection = 0;
	
	listboxMajor.GetCurrentSelection(&nSelection);
    int nMajorType;

    // First clear the subtype list
    listboxMinor.ClearItems();

    // If the "don't care" item was selected, clear and exit
    if (nSelection == 0)
    {
        listboxMinor.AddString(L"<No subtypes>\0");
        listboxMinor.Select(0);
        return;
    }
    else
	{
        nMajorType = nSelection - 1;
	}

    // Determine how to fill the minor type list, based on the
    // currently selected major type.
    pSubtype = pSubTypes[nMajorType];

    // If there's no associated subtype, just add a default
    if (!pSubtype)
    {
        listboxMinor.AddString(L"<No subtypes>\0");
        listboxMinor.Select(0);
        return;
    }
    else
    {
        // Set a default item for "don't care"
        listboxMinor.AddString(L"<Don't care>\0");

        int i=0;

        // Fill the subtype list box.  Enter N item data to the N+1 list slot.
        while (pSubtype[i].pGUID != NULL)
        {
            listboxMinor.AddItem(pSubtype[i].szName, (void *) pSubtype[i].pGUID);
            i++;
        }

        listboxMinor.Select(0);
    }
}