15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


ToolbaRS

Zach_Ho@smtplink.syscom.com.tw
Monday, March 17, 1997

     David,
     
     I don't know why, but we usually create and load our toolbar in each 
     view's OnCreate() function, like this:
     
        m_wndToolBar.Create(AfxGetMainWnd());
        m_wndToolBar.LoadToolBar(IDR_TOOLBAR_XXX);
     
     so if you switch among views, the toolbar of the lost focus view will 
     be hidden.
     
     But if you create your toolbars in the InitInstance() function, 
     depending on the way you create, those toolbars may all be the 
     children of the mainframe, and they will all be shown regardless of 
     which view is active.
     
     Hope this help.
     Zach 03.17.1997
     


______________________________ Reply Separator _________________________________
Subject: ToolbaRS
Author:  owner-mfc-l@majordomo.netcom.com at smtplink-syscom
Date:    1997/3/16 05:18 AM


Environment: VC++ 4.2b, Win 95
     
I have an app that has several different views of the same document = 
class, and I would like a different toolbar with each.  I would rather = 
create the toolbar and attach it in the CView::OnInitialUpdate() = 
function, but this doesn't seem to work.  If I create them in the = 
InitInstance(), it works fine, but every view then shows every toolbar.  = 
I tried to use ShowWindow(SW_HIDE) to hide the ones I didn't want, but = 
that just leaves a huge gap in the toolbar area.  None of the views can = 
be displayed at the same time, so it doesn't make sense to have extras. = 
I didn't see any examples dealing with this, so anybody have any = 
suggestions, please let me know...
     
Thanks!
     
David



bshamsian@ccvhs.vhsla.com
Wednesday, March 19, 1997

[Mini-digest: 2 responses]

     Environment: VC++ 4.1b, Win NT 4.0
     
     David,
     
     In our application we also have multiple views from the same document.
     We needed the buttons on the main toolbar to change depending on which 
     view the user is in.  Here is how we did it.
     
     1) Create one main tool bar in the OnCreate of our CMainFrame   
        class.  Store the handle to the toolbar in the CMainFrame 
        class.  Lets call this m_wndToolBar.  Load the default toolbar
        using the m_wndToolBar.LoadToolBar(IDR_TOOLBAR_DEFAULT) function.
     
     2) Override the OnActivateView of every view which needs a 
        different toolbar. In the OnActivateView perform the following 
        in order to load a new set of buttons and command ids into the
        main toolbar:
     
                CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd() ;
                if (pMainFrame == NULL) return ;
          
                pMainFrame->m_wndToolBar.LoadToolBar(IDR_TOOLBAR_XXXX) ;
          
     IDR_TOOLBAR_XXXX is the id for the toolbar you want to associate with 
     this view.
          
     Thus you basically create a main toolbar once and just reload a new 
     set if buttons and command id's into it everytime the view is changed.
          
     Hope this helps
     Ben
           
           
     

______________________________ Reply Separator _________________________________
Subject: Re: ToolbaRS
Author:  mfc-l@netcom.com at vhsunix
Date:    3/19/97 11:45 AM


     David,
     
     I don't know why, but we usually create and load our toolbar in each 
     view's OnCreate() function, like this:
     
        m_wndToolBar.Create(AfxGetMainWnd()); 
        m_wndToolBar.LoadToolBar(IDR_TOOLBAR_XXX);
     
     so if you switch among views, the toolbar of the lost focus view will 
     be hidden.
     
     But if you create your toolbars in the InitInstance() function, 
     depending on the way you create, those toolbars may all be the 
     children of the mainframe, and they will all be shown regardless of 
     which view is active.
     
     Hope this help.
     Zach 03.17.1997
     
     
     
______________________________ Reply Separator _________________________________
Subject: ToolbaRS
Author:  owner-mfc-l@majordomo.netcom.com at smtplink-syscom 
Date:    1997/3/16 05:18 AM
     
     
Environment: VC++ 4.2b, Win 95
     
I have an app that has several different views of the same document = 
class, and I would like a different toolbar with each.  I would rather = 
create the toolbar and attach it in the CView::OnInitialUpdate() = 
function, but this doesn't seem to work.  If I create them in the = 
InitInstance(), it works fine, but every view then shows every toolbar.  = 
I tried to use ShowWindow(SW_HIDE) to hide the ones I didn't want, but = 
that just leaves a huge gap in the toolbar area.  None of the views can = 
be displayed at the same time, so it doesn't make sense to have extras. = 
I didn't see any examples dealing with this, so anybody have any = 
suggestions, please let me know...
     
Thanks!
     
David

-----From: jtalkar@optika.com (Jeremiah Talkar)


Creating the toolbars in the Cview::OnCreate() show help you achieve what   
you want to do. In any case, if you still have trouble getting it to   
work, you actually should use CWnd::ShowControlBar() in order to   
correctly show or hide any CcontrolBar derived class.

Jeremiah

 -----Original Message-----
From: David Little
Sent: Wednesday, March 12, 1997 9:10 PM
To: 'MFC Question'
Subject: ToolbaRS



Environment: VC++ 4.2b, Win 95

I have an app that has several different views of the same document =
class, and I would like a different toolbar with each.  I would rather =
create the toolbar and attach it in the CView::OnInitialUpdate() =
function, but this doesn't seem to work.  If I create them in the =
InitInstance(), it works fine, but every view then shows every toolbar.   
 =
I tried to use ShowWindow(SW_HIDE) to hide the ones I didn't want, but =
that just leaves a huge gap in the toolbar area.  None of the views can =
be displayed at the same time, so it doesn't make sense to have extras. =
I didn't see any examples dealing with this, so anybody have any =
suggestions, please let me know...

Thanks!

David






Become an MFC-L member | Вернуться в корень Архива |