Multiple Toolbars
-
How does one implement muiltiple toolbars? Our app starts out with a commandbar (menu + buttons), but depending on what the user does in the menu, we want to display another toolbar (or even better, a commandbar with just buttons that replaces the original one until they're done with the new toolbar). Does anyone have any hints they'd like to share? ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
The project I'm working on right now has a similar functionality. I supports the normal command bar, plus a toolbar at the top of the screen. Here is the code I've used: Header for frame:
.
.
.
protected: // control bar embedded members
CCeCommandBar m_wndCommandBar;
CChildView m_wndView;CToolBar m\_tbDummy;
.
.
.Implementarion of frame:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create a view to occupy the client area of the frame
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
m_wndCommandBar.m_bShowSharedNewButton = FALSE;
m_ToolTipsTable[0] = MakeString(IDS_NEW);
m_ToolTipsTable[1] = MakeString(IDS_FILE);
m_ToolTipsTable[2] = MakeString(IDS_MHELP);
m_ToolTipsTable[3] = MakeString(IDS_CUT);
m_ToolTipsTable[4] = MakeString(IDS_COPY);
m_ToolTipsTable[5] = MakeString(IDS_PASTE);
m_ToolTipsTable[6] = MakeString(IDS_ABOUT);if(!m\_wndCommandBar.Create(this) || !m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME) || !m\_wndCommandBar.AddAdornments() || !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME) || !m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(6), (LPARAM)(&m\_ToolTipsTable\[1\]))) { TRACE0("Failed to create CommandBar\\n"); return -1; // fail to create } m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED); if(!m\_tbDummy.Create(this, WS\_CHILD | WS\_VISIBLE | CBRS\_TOP) || !m\_tbDummy.LoadToolBar(IDR\_DUMMY)) { AfxMessageBox(\_T("Failed to create dummy!")); return -1; } m\_tbDummy.SetHeight(20); return 0;
}
Cheers.
-
The project I'm working on right now has a similar functionality. I supports the normal command bar, plus a toolbar at the top of the screen. Here is the code I've used: Header for frame:
.
.
.
protected: // control bar embedded members
CCeCommandBar m_wndCommandBar;
CChildView m_wndView;CToolBar m\_tbDummy;
.
.
.Implementarion of frame:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create a view to occupy the client area of the frame
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0("Failed to create view window\n");
return -1;
}
m_wndCommandBar.m_bShowSharedNewButton = FALSE;
m_ToolTipsTable[0] = MakeString(IDS_NEW);
m_ToolTipsTable[1] = MakeString(IDS_FILE);
m_ToolTipsTable[2] = MakeString(IDS_MHELP);
m_ToolTipsTable[3] = MakeString(IDS_CUT);
m_ToolTipsTable[4] = MakeString(IDS_COPY);
m_ToolTipsTable[5] = MakeString(IDS_PASTE);
m_ToolTipsTable[6] = MakeString(IDS_ABOUT);if(!m\_wndCommandBar.Create(this) || !m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME) || !m\_wndCommandBar.AddAdornments() || !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME) || !m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(6), (LPARAM)(&m\_ToolTipsTable\[1\]))) { TRACE0("Failed to create CommandBar\\n"); return -1; // fail to create } m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED); if(!m\_tbDummy.Create(this, WS\_CHILD | WS\_VISIBLE | CBRS\_TOP) || !m\_tbDummy.LoadToolBar(IDR\_DUMMY)) { AfxMessageBox(\_T("Failed to create dummy!")); return -1; } m\_tbDummy.SetHeight(20); return 0;
}
Cheers.
This is what I did, and all I've managed to do is to get the CommandBar to dissappear altogether. What's more, when I shut the app down and restart it, the original commandbar is STILL gone (in the emulator). In MainFrm.h:
class CMainFrame
{
...
...
private:
CToolBar m_barProcess;
CToolBar m_barAnnotate;
CToolBar m_barZoom;
CToolBar m_barVideo;
CToolBar m_barAVI;
CChildView m_wndView;
UINT m_currentBar;BOOL CreateOtherCommandBars(); void HideCurrentToolbar (); void ShowThisBar (UINT newBar); void ShowMainCommandBar ();
};
In MainFrm.cpp:
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; m\_wndCommandBar.m\_bShowSharedNewButton = FALSE; m\_ToolTipsTable\[0\] = MakeString(IDS\_NEW); m\_ToolTipsTable\[1\] = MakeString(IDS\_FILE); m\_ToolTipsTable\[2\] = MakeString(IDS\_MHELP); m\_ToolTipsTable\[3\] = MakeString(IDS\_CUT); m\_ToolTipsTable\[4\] = MakeString(IDS\_COPY); m\_ToolTipsTable\[5\] = MakeString(IDS\_PASTE); m\_ToolTipsTable\[6\] = MakeString(IDS\_ABOUT); if(!m\_wndCommandBar.Create(this) || !m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME) || !m\_wndCommandBar.AddAdornments() || !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME) || !m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable))) { TRACE0("Failed to create CommandBar\\n"); return -1; // fail to create } m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED); CreateOtherCommandBars(); return 0;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
BOOL CMainFrame::CreateOtherCommandBars()
{
m_currentBar = IDR_MAINFRAME;
UINT barStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM/* | CBRS_TOOLTIPS | CBRS_FLYBY*/;
UINT barStyleEx = CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED;
if (!m_barProcess.Create(this, TBSTYLE_FLAT, barStyle) ||
!m_barProcess.LoadToolBar(IDR_PROCESSBAR))
{
return FALSE;
}
if (!m_barAnnotate.Create(this, TBSTYLE_FLAT, barStyle) ||
!m_barAnnotate.LoadToolBar(IDR_ANNOTATEBAR))
{
return FALSE;
}
if (!m_barZoom.Create(this, TBSTYLE_FLAT, barStyle) ||
!m_barZoom.LoadToolBar( -
This is what I did, and all I've managed to do is to get the CommandBar to dissappear altogether. What's more, when I shut the app down and restart it, the original commandbar is STILL gone (in the emulator). In MainFrm.h:
class CMainFrame
{
...
...
private:
CToolBar m_barProcess;
CToolBar m_barAnnotate;
CToolBar m_barZoom;
CToolBar m_barVideo;
CToolBar m_barAVI;
CChildView m_wndView;
UINT m_currentBar;BOOL CreateOtherCommandBars(); void HideCurrentToolbar (); void ShowThisBar (UINT newBar); void ShowMainCommandBar ();
};
In MainFrm.cpp:
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; m\_wndCommandBar.m\_bShowSharedNewButton = FALSE; m\_ToolTipsTable\[0\] = MakeString(IDS\_NEW); m\_ToolTipsTable\[1\] = MakeString(IDS\_FILE); m\_ToolTipsTable\[2\] = MakeString(IDS\_MHELP); m\_ToolTipsTable\[3\] = MakeString(IDS\_CUT); m\_ToolTipsTable\[4\] = MakeString(IDS\_COPY); m\_ToolTipsTable\[5\] = MakeString(IDS\_PASTE); m\_ToolTipsTable\[6\] = MakeString(IDS\_ABOUT); if(!m\_wndCommandBar.Create(this) || !m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME) || !m\_wndCommandBar.AddAdornments() || !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME) || !m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable))) { TRACE0("Failed to create CommandBar\\n"); return -1; // fail to create } m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED); CreateOtherCommandBars(); return 0;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
BOOL CMainFrame::CreateOtherCommandBars()
{
m_currentBar = IDR_MAINFRAME;
UINT barStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM/* | CBRS_TOOLTIPS | CBRS_FLYBY*/;
UINT barStyleEx = CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED;
if (!m_barProcess.Create(this, TBSTYLE_FLAT, barStyle) ||
!m_barProcess.LoadToolBar(IDR_PROCESSBAR))
{
return FALSE;
}
if (!m_barAnnotate.Create(this, TBSTYLE_FLAT, barStyle) ||
!m_barAnnotate.LoadToolBar(IDR_ANNOTATEBAR))
{
return FALSE;
}
if (!m_barZoom.Create(this, TBSTYLE_FLAT, barStyle) ||
!m_barZoom.LoadToolBar(I don't know if this will work better: create one toolbar at a time, destroying the previous one.
-
I don't know if this will work better: create one toolbar at a time, destroying the previous one.
What I'm trying to get is what Pocket Word does. There's a button on the commandbar that brings up an additional toolbar. I have tried a number of approaches to this, but I can't get it to work. I've almost decided that PocketPC 2002 is equivalent to "hell on earth". ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
-
What I'm trying to get is what Pocket Word does. There's a button on the commandbar that brings up an additional toolbar. I have tried a number of approaches to this, but I can't get it to work. I've almost decided that PocketPC 2002 is equivalent to "hell on earth". ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
I believe you should create a
CToolBar
in your main frame using theCBRS_BOTTOM
style. Hope this is not another blind alley... -
What I'm trying to get is what Pocket Word does. There's a button on the commandbar that brings up an additional toolbar. I have tried a number of approaches to this, but I can't get it to work. I've almost decided that PocketPC 2002 is equivalent to "hell on earth". ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
I have it. How do I send you the code?
-
What I'm trying to get is what Pocket Word does. There's a button on the commandbar that brings up an additional toolbar. I have tried a number of approaches to this, but I can't get it to work. I've almost decided that PocketPC 2002 is equivalent to "hell on earth". ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
John Simmons / outlaw programmer wrote: I've almost decided that PocketPC 2002 is equivalent to "hell on earth". Here comes a bit of "heaven", I hope! ;) Multiple Toolbars in the PocketPC 2002 [^]
-
John Simmons / outlaw programmer wrote: I've almost decided that PocketPC 2002 is equivalent to "hell on earth". Here comes a bit of "heaven", I hope! ;) Multiple Toolbars in the PocketPC 2002 [^]
I'll have a look - at first glance, it appears to be exactly what i need. Many thanks! ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
-
John Simmons / outlaw programmer wrote: I've almost decided that PocketPC 2002 is equivalent to "hell on earth". Here comes a bit of "heaven", I hope! ;) Multiple Toolbars in the PocketPC 2002 [^]
It works! But you gotta tell me where you found out how to do that... :) ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
-
It works! But you gotta tell me where you found out how to do that... :) ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
(teeth gnashing) I had to go through the MFC source code... :eek: