Solved

Tool bar for a View

Posted on 1998-08-24
3
175 Views
Last Modified: 2013-11-19
I want to add a tool bar for my veiw. Because already
I got one tool bar in my MainFrame. How do I do that?
0
Comment
Question by:krpadman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Expert Comment

by:Priyesh
ID: 1321215
Create all u'r toolbars in u'r mainframe class...u may hide some of them and show along with u'r view..
0
 
LVL 4

Accepted Solution

by:
piano_boxer earned 100 total points
ID: 1321216
The toolbar needs to be created in the parent frame of the views (the CMDIChildWnd class).

To do this, derive a new class from CMDIChildWnd, modify your Document registration to use the new frame window. This is done in your CXxxxApp implementation file:

BOOL CMyApp::InitInstance()
{
    [............]

    CMultiDocTemplate* pDocTemplate;
    pDocTemplate = new CMultiDocTemplate(
        IDR_MTYPE,
        RUNTIME_CLASS(CMyDoc),
        RUNTIME_CLASS(CMyFrame), // <<< Your custom frame window class here
        RUNTIME_CLASS(CMyView));
    AddDocTemplate(pDocTemplate);
   
    [................]

    return TRUE;
}


! Remember to include the new frame class's header file
You can now test that it works with the new frame.

--

To add the toolbar, add a CToolBar member variable to the new frame class (CMyFrame) (call it something like m_wndToolbar).

Add a handler for WM_CREATE in CMyFrame, a create the toolbar in this function:

int CMyFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    if (!m_wndToolbar.Create(this) ||
        !m_wndToolbar.LoadToolBar(IDR_MYTOOLBAR))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;      // fail to create
    }
   
    return 0;
}
0
 

Author Comment

by:krpadman
ID: 1321217
Thank you very much!!. It is working great.
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question