Solved

Tool bar for a View

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now