Exemple #1
0
LRESULT CProfStudioPropertyGridCtrl::WindowProc( UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult =
		CExtPropertyGridCtrl::WindowProc( message, wParam, lParam );
	if( message == WM_CREATE )
	{
		PropertyStoreSet( &m_PS );
		CTypedPtrArray < CPtrArray, CExtPropertyGridWnd * > arrGrids;
		OnPgcQueryGrids( arrGrids );
		INT nGridIdx = 0;
		for( ; nGridIdx < arrGrids.GetSize(); nGridIdx ++ )
		{
			CExtPropertyGridWnd * pGrid = arrGrids[ nGridIdx ];
			ASSERT_VALID( pGrid );
			g_PaintManager->LoadWinXpTreeBox(
				pGrid->m_iconTreeBoxExpanded,
				true
				);
			g_PaintManager->LoadWinXpTreeBox(
				pGrid->m_iconTreeBoxCollapsed,
				false
				);
		} // for( ; nGridIdx < arrGrids.GetSize(); nGridIdx ++ )
		CExtPropertyGridComboBoxBar * pCBB =
			STATIC_DOWNCAST(
				CExtPropertyGridComboBoxBar,
				GetChildByRTC(
					RUNTIME_CLASS(CExtPropertyGridComboBoxBar)
					)
				);
		pCBB->PropertyStoreInsert( &m_PS );
	} // if( message == WM_CREATE )
	return lResult;
}
HTREEITEM CTreeListCtrl::getAncestorAtLevel(HTREEITEM item,int level) const
{
   HTREEITEM ancestor = NULL;
   CTypedPtrArray<CPtrArray,HTREEITEM> levels;

   while (item != NULL)
   {
      item = GetParentItem(item);

      if (item != NULL)
      {
         levels.Add(item);
      }
   }

   if (levels.GetCount() > level)
   {
      ancestor = levels.GetAt(levels.GetCount() - 1 - level);
   }

   return ancestor;
}
//////////////////////////////////////////////////////////////////////
// Update the application's ACCELs table
//
bool CAcceleratorManager::UpdateWndTable()
{
	int iLoop = 0;
	CTypedPtrArray<CPtrArray, LPACCEL> arrayACCEL;

	CCmdAccelOb*pCmdAccel;
	WORD        wKey;
	LPACCEL     pACCEL;
	CAccelsOb*  pAccelOb;
	POSITION    pos = m_mapAccelTable.GetStartPosition();
	while (pos != NULL)
	{
		m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
		POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
		while (pos != NULL)
		{
			pAccelOb = pCmdAccel->m_Accels.GetNext(pos);

			pACCEL = new ACCEL;
			ASSERT(pACCEL != NULL);
			pACCEL->fVirt = pAccelOb->m_cVirt;
			pACCEL->key   = pAccelOb->m_wKey;
			pACCEL->cmd   = pCmdAccel->m_wIDCommand;
			arrayACCEL.Add(pACCEL);
		}
	}

	int     nAccel  = arrayACCEL.GetSize();
	LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL));
	if (!lpAccel)
	{
		for (iLoop = 0; iLoop < nAccel; iLoop++)
			delete arrayACCEL.GetAt(iLoop);
		arrayACCEL.RemoveAll();

		return false;
	}

	for (iLoop = 0; iLoop < nAccel; iLoop++)
	{
		pACCEL = arrayACCEL.GetAt(iLoop);
		lpAccel[iLoop].fVirt = pACCEL->fVirt;
		lpAccel[iLoop].key   = pACCEL->key;
		lpAccel[iLoop].cmd   = pACCEL->cmd;

		delete pACCEL;
	}
	arrayACCEL.RemoveAll();

	HACCEL hNewTable = CreateAcceleratorTable(lpAccel, nAccel);
	if (!hNewTable)
	{
		::LocalFree(lpAccel);
		return false;
	}
	HACCEL hOldTable = theApp.hAccel;
	if (!::DestroyAcceleratorTable(hOldTable))
	{
		::LocalFree(lpAccel);
		return false;
	}
	theApp.hAccel = hNewTable;
	::LocalFree(lpAccel);

	UpdateMenu(GetMenu(*AfxGetApp()->m_pMainWnd));

	return true;
}