Solved

Toolbar in a MDI Form

Posted on 1998-10-26
9
2,089 Views
Last Modified: 2013-12-25
I want to display a Toolbar that is on a MDI Child on the MDI Master. (In VB6)

In the MDI Form there is a Toolbar, but for a specific MDI Child I want to use another Toolbar. This one has to be located on the MDI Form.
I've put the negotiatetoolbar-property of the MDI Form on True. I have put a Toolbar on a MDI Child Form and set the negotiate-property on True. But the Toolbar stays on the MDI Child.

Am I doing something wrong?
Is there anyone that has the solution for this problem?
0
Comment
Question by:jntj405
9 Comments
 
LVL 2

Expert Comment

by:schild
ID: 1487940
As far as I understand your question, I think that the negotiatetoolbar is not working the you think it is.

Read the following MSDN article:


Creating a Toolbar
The toolbar (also called a ribbon or control bar) has become a standard feature in many Windows-based applications. A toolbar provides quick access to the most frequently used menu commands in an application. Creating a toolbar is easy and convenient using the toolbar control, which is available with the Professional and Enterprise editions of Visual Basic. If you are using the Learning Edition of Visual Basic, you can create toolbars manually as described in "Negotiating Menu and Toolbar Appearance" later in this chapter.

The following example demonstrates creating a toolbar for an MDI application; the procedure for creating a toolbar on a standard form is basically the same.

 To manually create a toolbar

Place a picture box on the MDI form.
The width of the picture box automatically stretches to fill the width of the MDI form's workspace. The workspace is the area inside a form's borders, not including the title bar, menu bar, or any toolbars, status bars, or scroll bars that may be on the form.

Note You can place only those controls that support the Align property directly on an MDI form (the picture box is the only standard control that supports this property).

Inside the picture box, place any controls you want to display on the toolbar.
Typically, you create buttons for the toolbar using command buttons or image controls. Figure 6.16 shows a toolbar containing image controls.

To add a control inside a picture box, click the control button in the toolbox, and then draw it inside the picture box.

Note When an MDI form contains a picture box, the internal area of the MDI form does not include the area of the picture box. For example, the ScaleHeight property of the MDI form returns the internal height of the MDI form, which does not include the height of the picture box.

Figure 6.16 You can create buttons for the toolbar using image controls



Set design-time properties.
One advantage of using a toolbar is that you can present the user with a graphical representation of a command. The image control is a good choice as a toolbar button because you can use it to display a bitmap. Set its Picture property at design time to display a bitmap; this provides the user with a visual cue of the command performed when the button is clicked. You can also use ToolTips, which display the name of the toolbar button when a user rests the mouse pointer over a button, by setting the ToolTipText property for the button.

Write code.
Because toolbar buttons are frequently used to provide easy access to other commands, most of the time you call other procedures, such as a corresponding menu command, from within each button's Click event.

Tip You can use controls that are invisible at run time (such as the timer control) with an MDI form without displaying a toolbar. To do this, place a picture box on the MDI form, place the control in the picture box, and set the picture box's Visible property to False.

Writing Code for Toolbars

Toolbars are used to provide the user with a quick way to access some of the application's commands. For example, the first button on the toolbar in Figure 6.16 is a shortcut for the File New command. There are now three places in the MDI NotePad sample application where the user can request a new file:

On the MDI form (New on the MDI form File menu)
On the child form (New on the child form File menu)
On the toolbar (File New button)
Rather than duplicate this code three times, you can take the original code from the child form's mnuFileNew_Click event and place it in a public procedure in the child form. You can call this procedure from any of the preceding event procedures. Here's an example:




' This routine is in a public procedure.
Public Sub FileNew ()
    Dim frmNewPad As New frmNotePad
    frmNewPad.Show
End Sub

' The user chooses New on the child form File menu.
Private Sub mnuchildFileNew_Click ()
    FileNew
End Sub

' The user chooses New on the MDI form File menu.
Private Sub mnumdiFileNew_Click ()
    frmNotePad.FileNew
End Sub

' The user clicks the File New button on the toolbar.
Private Sub btnFileNew_Click ()
    frmNotePad.FileNew
End Sub

------------------ Article End ------------------

In any case if you need a special toolbar in a specific child, just add a toolbar to it and use it a  normal forms toolbar

Good Luck
Schild


0
 

Author Comment

by:jntj405
ID: 1487941
What I want is the following:
I want to do the same like you can do with menu's. There is a menu on a MDI Form. When declaring a menu on a MDI Child (with negiotiatemenus on True), the menu that is shown on the MDIForm, is that of the MDI Child and not that of the MDI Form.
I want to do the same with Toolbars. According to the Help-files of VB, this must be possible with the negotiatetoolbars-property. But when I change this property, I see no difference when I run that Project.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1487942
Negotiation of toolbars only works for Inserted or embedded object using OLE. See text below.
To see how it works. Add an OLE control on your MDI form and put a word document in it. Now start your application. And double click the OLE control. Now you will see the negatiation of the toolbars.

PIECE of the MSDN

The MDI form's NegotiateToolbars property determines whether the linked or embedded object's toolbars will be floating palettes or placed on the parent form. This behavior does not require toolbars to be present on the MDI parent form. If the MDI form's NegotiateToolbars property is True, the object's toolbar appears on the MDI parent form. If NegotiateToolbars is False, the object's toolbar will be a floating palette.

If an MDI form includes a toolbar, it is usually contained in a picture box control on the parent form. The picture box's Negotiate property determines whether the container's toolbar is still displayed or is replaced by the object's toolbar when activated. If Negotiate is True, the object's toolbar is displayed in addition to the container's toolbar. If Negotiate is False, the object's toolbar replaces the container's toolbar.

Note Menu and toolbar negotiation will occur only for insertable objects that support in-place activation.


0
 

Author Comment

by:jntj405
ID: 1487943
Mirkwood,

Thanks for that information. But is there anyway that I can achieve my goal?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:vmano
ID: 1487944
jntj405,
i just looked in to the help of NegotiateToolbars, Negotiate property in VB6.0, and it says "NOT AVAILABLE AT RUN TIME". is that true or should it be "NOT AVAILABLE AT DESIGN TIME". If it is not availbale at run time, i think it won't have any effect to what ever value you set.please correct me, if i am wrong.

vmano
0
 

Author Comment

by:jntj405
ID: 1487945
vmano,

"Not available at run time" means:
If you change it in design-time directly in the properties, it will work. You cann't change it with code.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1487946
It might not be the answer you want to hear but mdi forms cannot place their toolbar into the parent menu.
This is by design. Microsoft does not want to support different kinds of MDI-forms in one MDI application. All windows in an MDI should have the same functionality and therefor the same toolbar.
0
 
LVL 15

Accepted Solution

by:
ameba earned 300 total points
ID: 1487947
If you have 5 different form types, add 5 toolbars to your MDI form. Set toolbars' visible property to False. Then use Activate, Deactivate or GetFocus events to set Visible property of the toolbars. You will also need 6th toolbar, when there is no MDIChild form.
Code in toolbars' Click event will have to use ActiveForm property to identify MDIChild form.
0
 

Author Comment

by:jntj405
ID: 1487948
Ameba,

Thanks for that sollution. I've tried it and it works.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

747 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

12 Experts available now in Live!

Get 1:1 Help Now