/*!
	@brief ツールバーの表示を更新する
	
	@note 他から呼べるようにOnToolbarTimer()より切り出した
	
	@date 2008.10.05 nasukoji
*/
void CMainToolBar::UpdateToolbar( void )
{
	// 印刷プレビュー中なら、何もしない。
	if( m_pOwner->IsInPreviewMode() )return;
	
	// ツールバーの状態更新
	if( m_hwndToolBar )
	{
		for( int i = 0; i < GetDllShareData().m_Common.m_sToolBar.m_nToolBarButtonNum; ++i )
		{
			TBBUTTON tbb = m_pOwner->GetMenuDrawer().getButton(
				GetDllShareData().m_Common.m_sToolBar.m_nToolBarButtonIdxArr[i]
			);

			// 機能が利用可能か調べる
			Toolbar_EnableButton(
				m_hwndToolBar,
				tbb.idCommand,
				IsFuncEnable( m_pOwner->GetDocument(), &GetDllShareData(), (EFunctionCode)tbb.idCommand )
			);

			// 機能がチェック状態か調べる
			Toolbar_CheckButton(
				m_hwndToolBar,
				tbb.idCommand,
				IsFuncChecked( m_pOwner->GetDocument(), &GetDllShareData(), (EFunctionCode)tbb.idCommand )
			);
		}
	}
}
Exemple #2
0
void Toolbar_UpdateUI(
  HWND hwnd)
  {
   HWND hwndFrame;
   HMENU hmenu;
   unsigned nCount;

   /*=======================================*/
   /* Get frame window (parent of toolbar). */
   /*=======================================*/
   
   hwndFrame = GetParent(hwnd);
   ASSERT(NULL != hwndFrame);

   /*===================================*/
   /* Get the main frame window's menu. */
   /*===================================*/
   
   hmenu = GetMenu(hwndFrame);
   //ASSERT (NULL != hmenu) ;

   if (NULL == hmenu)
     { return; }

   /*======================================*/
   /* Get count of buttons on the toolbar. */
   /*======================================*/
   
   nCount = Toolbar_ButtonCount(hwnd);

   /*===================================*/
   /* For each button on the toolbar... */
   /*===================================*/
   
   while (nCount > 0) 
     {
      BOOL bMenuEnabled, bButtonEnabled;
      TBBUTTON tbb;
      UINT uiState;

      /*===================================*/
      /* Get information about the button. */
      /*===================================*/
      
      VERIFY(Toolbar_GetButton(hwnd,--nCount,&tbb));

      /*==========================================*/
      /* If the button is a separator, ignore it. */
      /*==========================================*/
      
      if (tbb.fsStyle & TBSTYLE_SEP)
        { continue; }

      /*=========================================*/
      /* Get information about the corresponding */
      /* menu item, if any.                      */
      /*=========================================*/
      
      uiState = GetMenuState(hmenu,(unsigned) tbb.idCommand,MF_BYCOMMAND);
      if (0xFFFFFFFF == uiState)
        { bMenuEnabled = FALSE; }
      else
        { bMenuEnabled = 0 == (uiState & (MF_DISABLED | MF_GRAYED)); }

      bButtonEnabled = 0 != (tbb.fsState & TBSTATE_ENABLED);

      /*===========================================*/
      /* If button and menu are in the same state, */
      /* we need do nothing for this button.       */
      /*===========================================*/
      
      if (bMenuEnabled == bButtonEnabled)
        { continue; }

      /*=====================================*/
      /* Enable/Disable this toolbar button. */
      /*=====================================*/
      
      VERIFY(Toolbar_EnableButton(hwnd,tbb.idCommand,bMenuEnabled));
     }
  }