Example #1
0
int CControlBar::OnCreate( LPCREATESTRUCT lpCreateStruct )
/********************************************************/
{
    if( CWnd::OnCreate( lpCreateStruct ) == -1 ) {
        return( -1 );
    }

    CFrameWnd *pFrame = GetParentFrame();
    if( pFrame != NULL ) {
        pFrame->AddControlBar( this );
        m_pDockSite = pFrame;
    }

    if( m_dwStyle & CBRS_TOOLTIPS ) {
        EnableToolTips();
    }
    
    return( 0 );
}
Example #2
0
void
CPaletteWindow::CreateBar(bool bCreate)
{
	// should only be called if there is really need to create/destroy the bar
	ASSERT(bCreate == (m_pBarParent == NULL));
	CFrameWnd* parent = (CFrameWnd*)AfxGetApp()->m_pMainWnd;
	if (bCreate)
	{	
		m_pBarParent = new CPaletteBar;
    if (!m_pBarParent)
      return;
    if (m_pBarParent->Create(m_Name, parent, BAR_ID_START + m_PaletteNumber) == FALSE) {
      delete m_pBarParent;
      m_pBarParent = NULL;
      return;
    }
		
		//move the palette window into the bar
		if (m_hWnd != 0)
		{		
			SetParent(m_pBarParent);
			ShowWindow(SW_SHOW);
		}
		//set various styles
		parent->AddControlBar(m_pBarParent);
		m_pBarParent->SetBarStyle(m_pBarParent->GetBarStyle() |  CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
		m_pBarParent->SetSCBStyle(SCBS_SIZECHILD);
		m_pBarParent->EnableDocking(CBRS_ALIGN_ANY);		
		parent->DockControlBar(m_pBarParent, AFX_IDW_DOCKBAR_LEFT);		
	}
	else
	{
		//move the palette window out the bar (onto the desktop), not to destroy the palette
		ASSERT(m_hWnd != 0);
		ShowWindow(SW_HIDE);
		SetParent(NULL);
		parent->RemoveControlBar(m_pBarParent);
		delete m_pBarParent;
		m_pBarParent = NULL;
	}
}