Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Tool bar for a View

Posted on 1998-08-24
3
Medium Priority
?
179 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
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 400 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Loops Section Overview
Suggested Courses
Course of the Month6 days, 4 hours left to enroll

773 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