Solved

Tool bar for a View

Posted on 1998-08-24
3
171 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 72
Get filename and folder into excel 7 84
Perl Awk Need Help 3 138
no14 challenge 14 73
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

749 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