Ejemplo n.º 1
0
void CCoolBarCtrl::OnTimer(UINT nIDEvent) 
{
	if ( m_bRecalc )
	{
		CMDIFrameWnd* pOwner = (CMDIFrameWnd*)GetOwner();

		if ( pOwner != NULL && pOwner->IsKindOf( RUNTIME_CLASS(CMDIFrameWnd) ) )
		{
			if ( ! pOwner->IsIconic() )
			{
				pOwner->RecalcLayout();
				m_bRecalc = FALSE;
			}
		}
	}

	if ( nIDEvent == 1 && ( ! m_bMenuGray || m_pDown == NULL ) )
	{
		CRect rcWindow;
		CPoint point;

		GetCursorPos( &point );
		ScreenToClient( &point );
		GetClientRect( &rcWindow );

		if ( rcWindow.PtInRect( point ) && GetTopLevelParent()->IsWindowEnabled() )
		{
			CCoolBarItem* pItem = HitTest( point );

			if ( m_pDown && m_pDown != pItem ) pItem = NULL;

			if ( pItem != m_pHot )
			{
				m_pHot = pItem;
				Invalidate();
			}
		}
		else
		{
			KillTimer( nIDEvent );
			m_bTimer = FALSE;

			if ( m_pHot )
			{
				m_pHot = NULL;
				Invalidate();
			}
		}
	}

	CControlBar::OnTimer( nIDEvent );
}
Ejemplo n.º 2
0
void CCoolBarCtrl::OnUpdated()
{
	if ( ! m_bStretch )
	{
		CSize czLast = m_czLast;
		
		if ( CalcFixedLayout( FALSE, TRUE ) != czLast )
		{
			CMDIFrameWnd* pOwner = (CMDIFrameWnd*)GetOwner();

			if ( pOwner && pOwner->IsKindOf( RUNTIME_CLASS(CMDIFrameWnd) ) )
			{
				if ( pOwner->IsIconic() )
					m_bRecalc = TRUE;
				else
					pOwner->RecalcLayout();
			}
		}
	}
	
	Invalidate();
}
Ejemplo n.º 3
0
void CDynToolBar::LoadState(char* pFilename)
  {
  CProfINIFile PF(pFilename);
  CMDIFrameWnd* pM = pTBMngr->pMainFrame;
  Strng Section;
  Section.Set("ToolBar_%d", iWindowID);
  Strng NewTitle = PF.RdStr(Section(), "Title", (char*)(const char*)sTitle);
  if (NewTitle.Length()!=sTitle.GetLength() || strcmp(NewTitle(), (const char*)sTitle)!=0)
    {
    SetWindowText(NewTitle());
    sTitle = NewTitle();
    }
  DWORD BarStyle = GetBarStyle();
  DWORD Style = GetStyle();
  BarStyle = PF.RdLong(Section(), "BarStyle", BarStyle);
  BarStyle &= CBRS_ALL; //CNM Prevent an ASSERT
  SetBarStyle(BarStyle);

  if (bCanConfigure)
    {
    CToolBarCtrl& bc = GetToolBarCtrl();
    int Cnt = bc.GetButtonCount();
    Cnt = PF.RdInt(Section(), "ButtonIDCount", Cnt);
    BOOL Chngd = (Cnt!=bc.GetButtonCount());
    UINT* NewIDs = new UINT[Cnt];
    Strng Item;
    for (int i=0; i<Cnt; i++)
      {
      Item.Set("ID_%d", i);
      int Cmd = (i<(int)iLen ? BtnIDs[i] : ID_SEPARATOR);
      Cmd = PF.RdInt(Section(), Item(), Cmd);
      NewIDs[i] = (UINT)Cmd;
      Chngd = (Chngd || (NewIDs[i]!=BtnIDs[i]));
      }
    if (Chngd)
      ChangeButtons(NewIDs, Cnt);
    delete []NewIDs;
    }

  flag Visible = ((Style & WS_VISIBLE) != 0);
  Visible = PF.RdInt(Section(), "Visible", Visible);
  pM->ShowControlBar(this, Visible, FALSE);
  pM->RecalcLayout(); //get MFC to adjust the dimensions of all docked ToolBars so that GetWindowRect will be accurate
  CRect Rect;
  CWnd* pWnd = GetParent();
  if (BarStyle & CBRS_FLOATING)
    {
    if (pWnd && pWnd->GetParent())
      {
      if (PrjFileVerNo()>=25)
        {
        CRect MRect;
        AfxGetMainWnd()->GetWindowRect(MRect);
        Rect.OffsetRect(-MRect.left, -MRect.top);
        int L=PF.RdInt(Section(), "Left", Rect.left);
        int T=PF.RdInt(Section(), "Top", Rect.top);
        Rect.OffsetRect(L-Rect.left, T-Rect.top);
        Rect.OffsetRect(+MRect.left, +MRect.top);
        }
      else
        {
        pWnd->GetParent()->GetWindowRect(&Rect);
        Location.x = PF.RdInt(Section(), "Left", Rect.left);
        Location.y = PF.RdInt(Section(), "Top", Rect.top);
        }
      pM->FloatControlBar(this, Location);
      }
    }
  else
    {
    GetWindowRect(&Rect);
    if (PrjFileVerNo()>=25)
      {
      CRect MRect;
      AfxGetMainWnd()->GetWindowRect(MRect);
      Rect.OffsetRect(-MRect.left, -MRect.top);
      int L=PF.RdInt(Section(), "Left", Rect.left);
      int T=PF.RdInt(Section(), "Top", Rect.top);
      Rect.OffsetRect(L-Rect.left, T-Rect.top);
      Rect.OffsetRect(+MRect.left, +MRect.top);
      }
    else
      {
    //Rect.left = PF.RdInt(Section(), "Left", Rect.left);
    //Rect.top = PF.RdInt(Section(), "Top", Rect.top);
      int L=PF.RdInt(Section(), "Left", Rect.left);
      int T=PF.RdInt(Section(), "Top", Rect.top);
      Rect.right  += L-Rect.left;
      Rect.bottom += T-Rect.top;
      Rect.left   += L-Rect.left;
      Rect.top    += T-Rect.top;
      }
    //Rect.top = PF.RdInt(Section(), "Top", Rect.top);
    UINT n = 0;
    if (BarStyle & CBRS_ALIGN_TOP)
      {
      Rect.top -= 1;
      Rect.bottom -= 1;
      n = AFX_IDW_DOCKBAR_TOP;
      }
    if (n==0 && BarStyle & CBRS_ALIGN_BOTTOM)
      {
      Rect.top += 1;
      Rect.bottom += 1;
      n = AFX_IDW_DOCKBAR_BOTTOM;
      }
    if (n==0 && BarStyle & CBRS_ALIGN_LEFT)
      {
      Rect.left -= 1;
      Rect.right -= 1;
      n = AFX_IDW_DOCKBAR_LEFT;
      }
    if (n==0 && BarStyle & CBRS_ALIGN_RIGHT)
      {
      Rect.left += 1;
      Rect.right += 1;
      n = AFX_IDW_DOCKBAR_RIGHT;
      }
    pM->DockControlBar(this, n, &Rect);
    }
  pM->RecalcLayout();
  }