Solved

Tool bar for a View

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

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