void CleanToolbars()
{
	IAcadMenuGroup *mnuGrp = NULL;
	if (!getAcadMenuGroup(&mnuGrp))
		return ;

	IAcadToolbars  *tlbrs = NULL;
	HRESULT hr = S_OK;

	hr = mnuGrp->get_Toolbars(&tlbrs);
	mnuGrp->Release();

	long cnt = 0;
	hr = tlbrs->get_Count(&cnt);

	IAcadToolbar *polyTlbr = NULL;
	BSTR  tempName;

	VARIANT vtName;
	for (long i = cnt-1; i >0 ; i--)
	{
		vtName.vt = VT_I4;
		vtName.lVal = i;
		hr = tlbrs->Item(vtName, &polyTlbr);
		hr = polyTlbr->get_Name(&tempName);
		CString tlbrName(tempName);
		SysFreeString(tempName);

		OutputDebugString(tlbrName);

		BOOL bFind = FALSE;
		for (int j = 0; j < Glb_toolbarArray.GetSize(); j++)
		{
			if (tlbrName.CompareNoCase(Glb_toolbarArray.GetAt(j))==0)
			{
				bFind = TRUE;
				polyTlbr->Delete();
				break;
			}
		}
	
		if (!bFind)
			polyTlbr->Release();
	}

	tlbrs->Release();
	Glb_toolbarArray.RemoveAll();

	return;
}
Ejemplo n.º 2
0
void CleanUpToolbars()
{
    IAcadMenuGroup *mnuGrp = NULL;
    if (!getAcadMenuGroup(&mnuGrp))
        return ;


    IAcadToolbars  *tlbrs = NULL;
    HRESULT hr = S_OK;

    hr = mnuGrp->get_Toolbars(&tlbrs);
    mnuGrp->Release();

    long cnt = 0;
    hr = tlbrs->get_Count(&cnt);

    IAcadToolbar *polyTlbr = NULL;
    BSTR  tempName;

    VARIANT vtName;
    for ( long i=0; i < cnt; i++)
    {
        vtName.vt = VT_I4;
        vtName.lVal = i;
        hr = tlbrs->Item(vtName, &polyTlbr);
        hr = polyTlbr->get_Name(&tempName);
        CString tlbrName(tempName);
        SysFreeString(tempName);
        if(tlbrName.CompareNoCase("POLYSAMP APPLICATION")==0)
        {

            polyTlbr->Delete();
            //can not call following because delete has already removed it.
            //	polyTlbr->Release();
            break;
        }
        else
            polyTlbr->Release();

    }

    tlbrs->Release();
    return;
}