Ejemplo n.º 1
0
void CToolBarEx::OnRestore( NMHDR* pNMHDR, LRESULT* pResult )
{
    NMTBRESTORE* lpnmtb = ( NMTBRESTORE* )pNMHDR;
    if ( lpnmtb->iItem == -1 )
    {
        lpnmtb->cButtons = ( lpnmtb->cbData - sizeof( DWORD ) * 2 ) / lpnmtb->cbBytesPerRecord;
        lpnmtb->pCurrent = lpnmtb->pData;

        SetTextOptions( ( ETextOptions )*lpnmtb->pCurrent++, false );
        SetIconOptions( ( EIconOptions )*lpnmtb->pCurrent++, false );

        if ( lpnmtb->cButtons == 0 )
        {
            ReloadButtons();
            UpdateParentBandInfo();

            *pResult = 1;
            return;
        }
    }
    else
    {
        VERIFY( GetButtonInfo( lpnmtb->tbButton.idCommand, lpnmtb->tbButton ) );
    }

    *pResult = 0;
}
Ejemplo n.º 2
0
void CToolBarEx::OnReset( NMHDR* /*pNMHDR*/, LRESULT* pResult )
{
    // Delete all buttons
    CToolBarCtrl& tbCtrl = GetToolBarCtrl();
    while ( tbCtrl.DeleteButton( 0 ) );

    // Load buttons from internal cache
    for ( int nIndex = 0; nIndex <= m_aButtons.GetUpperBound(); nIndex++ )
    {
        if ( m_aButtons[ nIndex ].bInitiallyVisible )
        {
            VERIFY( tbCtrl.AddButtons( 1, &m_aButtons[ nIndex ].tbinfo ) );
        }
    }

    // Set default text & icon options
    SetIconOptions( m_eIconOptionsDefault, false );
    SetTextOptions( m_eTextOptionsDefault, false );
    ReloadButtons();
    UpdateParentBandInfo();

    // Synchronize with Customize dialog
    ASSERT( m_pCustomizeDlg != 0 );
    m_pCustomizeDlg->SetTextOptions( m_eTextOptions, true );
    m_pCustomizeDlg->SetIconOptions( m_eIconOptions, true );

    *pResult = 0;
}
Ejemplo n.º 3
0
void CToolBarEx::SetIconOptions( EIconOptions eIconOptions, bool bUpdate /*=true*/ )
{
    ASSERT( ::IsWindow( m_hWnd ) );
    ASSERT( IsIconOptionAvailable( eIconOptions ) );

    m_eIconOptions = eIconOptions;

    // Set image list(s) and icon size for selected icon options
    CToolBarCtrl& tbCtrl = GetToolBarCtrl();
    tbCtrl.SetImageList( 0 );
    tbCtrl.SetHotImageList( 0 );
    tbCtrl.SetDisabledImageList( 0 );

    CSize szIcon = ( eIconOptions == ioSmallIcons ) ? m_szImageSmall : m_szImageLarge;
	 VERIFY( tbCtrl.SetBitmapSize( szIcon ) );

    UINT nIDCold     = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallCold     : m_nIDLargeCold;
    UINT nIDHot      = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallHot      : m_nIDLargeHot;
    UINT nIDDisabled = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallDisabled : m_nIDLargeDisabled;
    ASSERT( nIDCold != ( UINT )-1 );    // at least there must be "cold" imagelist

    LPCTSTR lpResName = MAKEINTRESOURCE( nIDCold );
    HINSTANCE hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );

    m_imageListCold.DeleteImageList();
    VERIFY( m_imageListCold.Attach( ImageList_LoadImage( hInst, lpResName,
        szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
    tbCtrl.SetImageList( &m_imageListCold );

    if ( nIDHot != ( UINT )-1 ) // "hot" imagelist is optional
    {
        lpResName = MAKEINTRESOURCE( nIDHot );
        hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );

        m_imageListHot.DeleteImageList();
        VERIFY( m_imageListHot.Attach( ImageList_LoadImage( hInst, lpResName,
            szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
        tbCtrl.SetHotImageList( &m_imageListHot );
    }

    if ( nIDDisabled != ( UINT )-1 ) // "disabled" imagelist is optional
    {
        lpResName = MAKEINTRESOURCE( nIDDisabled );
        hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );

        m_imageListDisabled.DeleteImageList();
        VERIFY( m_imageListDisabled.Attach( ImageList_LoadImage( hInst, lpResName,
            szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
        tbCtrl.SetDisabledImageList( &m_imageListDisabled );
    }

    // If requested, reflect changes immediately
    if ( bUpdate )
    {
        ReloadButtons();
        UpdateParentBandInfo();
    }
}
Ejemplo n.º 4
0
void CToolBarEx::OnEndAdjust( NMHDR* /*pNMHDR*/, LRESULT* pResult )
{
    VERIFY( ::UnhookWindowsHookEx( m_hCBTHook ) );
    m_hCBTHook = 0;
    m_pToolBar = 0;

    ReloadButtons();
    UpdateParentBandInfo();

    *pResult = 0;
}
Ejemplo n.º 5
0
void CToolBarEx::SetTextOptions( ETextOptions eTextOptions, bool bUpdate /*=true*/ )
{
    ASSERT( ::IsWindow( m_hWnd ) );
    ASSERT( GetStyle() & TBSTYLE_TOOLTIPS );
    ASSERT( !( GetBarStyle() & CBRS_TOOLTIPS ) );
    ASSERT( IsTextOptionAvailable( eTextOptions ) );

    m_eTextOptions = eTextOptions;

    // Modify toolbar style according to new text options
    ModifyStyle(
        ( eTextOptions == toTextOnRight ) ? 0 : TBSTYLE_LIST,
        ( eTextOptions == toTextOnRight ) ? TBSTYLE_LIST : 0 );

    CToolBarCtrl& tbCtrl = GetToolBarCtrl();
    DWORD dwStyleEx = tbCtrl.GetExtendedStyle();
    tbCtrl.SetExtendedStyle(
        ( eTextOptions == toTextOnRight ) ?
            ( dwStyleEx |  TBSTYLE_EX_MIXEDBUTTONS ) :
            ( dwStyleEx & ~TBSTYLE_EX_MIXEDBUTTONS ) );
    VERIFY( tbCtrl.SetMaxTextRows(
        ( eTextOptions == toNoTextLabels ) ? 0 : 1 ) );

    if ( eTextOptions == toTextLabels )
    {
        VERIFY( tbCtrl.SetButtonWidth( 0, 76 ) );
    }

    // Modify all (even currently hidden ones) buttons in internal cache
    int nIndex;
    for ( nIndex = 0; nIndex <= m_aButtons.GetUpperBound(); nIndex++ )
    {
        TBBUTTON& tbinfo = m_aButtons[ nIndex ].tbinfo;
        if ( !( tbinfo.fsStyle & TBSTYLE_SEP ) )
        {
            CString strButtonText;
            GetButtonText( tbinfo.idCommand, strButtonText );
            CString strToAdd( strButtonText, strButtonText.GetLength() + 1 );
            tbinfo.iString = tbCtrl.AddStrings( strToAdd );

            switch ( eTextOptions )
            {
                case toTextLabels:
                    tbinfo.fsStyle &= ~( TBSTYLE_AUTOSIZE | BTNS_SHOWTEXT );
                    break;

                case toTextOnRight:
                    tbinfo.fsStyle |= ( TBSTYLE_AUTOSIZE |
                        ( HasButtonText( tbinfo.idCommand ) ? BTNS_SHOWTEXT : 0 ) );
                    break;

                case toNoTextLabels:
                    tbinfo.fsStyle &= ~BTNS_SHOWTEXT;
                    tbinfo.fsStyle |= TBSTYLE_AUTOSIZE;
                    break;
            }
        }
    }

    // If requested, reflect changes immediately
    if ( bUpdate )
    {
        ReloadButtons();
        UpdateParentBandInfo();
    }
}
Ejemplo n.º 6
0
void CLinkBar::Init()
{
/*  static TBBUTTONEX tbButtons[] =
    {
        { {  0, ID_SEARCH_GOOGLE,		TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 }, true },
        { {  0, ID_SEARCH_ALTAVISTA,	TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 }, true },
        { {  0, ID_SEARCH_LYCOS,		TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 }, true },
        { {  0, ID_SEARCH_VIVISIMO,		TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 }, true }
    };
	*/
	// Delete old buttons
    CToolBarCtrl& tbCtrl = GetToolBarCtrl();
    while ( tbCtrl.DeleteButton( 0 ) );
	
    // Load buttons from provided array
    m_aButtons.RemoveAll();
	
	//for(int i = 0; i < 4; i++)// comment by ny
		//AddButton(i, tbButtons[i]);// comment by ny

	/*
	CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
	for(int i=0;i<pFrame->m_linkbarItem.GetSize();i++)
	{
		TBBUTTONEX tbButtons[] =
		{
			{ {  pFrame->m_linkbarItem[i]->icon,pFrame->m_linkbarItem[i]->nID,TBSTATE_ENABLED, TBSTYLE_BUTTON, 0,0 }, true}
        };
		AddButton(i,*tbButtons,pFrame->m_linkbarItem[i]->strName);
	}
	//the linkbar item will never be used so delete it
	for(i=0;i<pFrame->m_linkbarItem.GetSize();i++)
	{
		delete pFrame->m_linkbarItem [i];
	}
	pFrame->m_linkbarItem.RemoveAll();

	CImageList	m_ImageListSmall;
	HIMAGELIST hImageList;
	SHFILEINFO shFi;
	hImageList=(HIMAGELIST)SHGetFileInfo("C:\\",0,&shFi,sizeof(shFi),
		SHGFI_SYSICONINDEX|SHGFI_SMALLICON);
	m_ImageListSmall.m_hImageList=hImageList;
	
	//CToolBarCtrl& tbCtrl = GetToolBarCtrl();
	tbCtrl.SetImageList(&m_ImageListSmall);
	m_ImageListSmall.Detach();
	*/

	//CImageList img;//comment by ny
	//HBITMAP hbmp = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP_SEARCH));//comment by ny
	//img.Create(16, 16, ILC_COLOR8|ILC_MASK, 7, 1);//comment by ny
	//ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));//comment by ny
	//tbCtrl.SetImageList(&img);//comment by ny
	//img.Detach();//comment by ny
	
	m_eIconOptionsDefault=m_eIconOptions=ioSmallIcons;
	
	SetCustomizeMode(FALSE);
	
	ReloadButtons();
    UpdateParentBandInfo();
}