Solved

Toolbar/MdiChild

Posted on 2000-03-14
3
236 Views
Last Modified: 2010-05-02
i am wrting a small prog. that uses a Mdiform with one childform(ie. Form1.the form is set as mdidhild=true).
I can make an array ( a Set No. of forms to add )for the ChildForms and
assign then toolbar buttons so when i click a button the right window shows.
The main point is how can i add a ChildForm as and when i need and still assign it to a Toolbar Button.
 I Have tried but all that happens is the last ChildForm shows.
  any help is much appreciated
I'll offer 50 points but if you feel it needs more and i agree i will oblige
0
Comment
Question by:oldholburn
[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
  • 2
3 Comments
 
LVL 1

Expert Comment

by:epretti
ID: 2617836
When you redim your Array you use

Redim [Array_Name] ([New_Value)

Because if you do so it's wrong, because in these way you loose your previous data. Try this:

Redim PRESERVE [Array_Name]([New_Value])
0
 
LVL 1

Expert Comment

by:epretti
ID: 2617883
When you redim your Array you use

Redim [Array_Name] ([New_Value)

Because if you do so it's wrong, because in these way you loose your previous data. Try this:

Redim PRESERVE [Array_Name]([New_Value])
0
 
LVL 14

Accepted Solution

by:
wsh2 earned 50 total points
ID: 2618911
Epretti:
Uh.. Huh?

"The main point is how can I add a ChildForm as and when i need and still assign it to a Toolbar Button."

To a Standard.Exe Project..

1.  Add an MDIForm
2.  Add a Toolbar to the MDIForm
3.  Change the Form1.MDIChild property to True
4.  Copy and Paste the following code into MDIForm1

<----- Code Begin ----->

Option Explicit

Private Sub MDIForm_Load()
    xAddForm
    xAddForm
    xAddForm
End Sub

Private Sub xAddForm()
   
    Static intChildForm As Integer
    Dim strChildForm As String
    intChildForm = intChildForm + 1
    strChildForm = "Form" & Format(intChildForm, "0##")
   
    ' Add a Toolbar Button
    Dim btnWork As Button
    Set btnWork = Toolbar1.Buttons.Add()
    btnWork.Key = strChildForm
    btnWork.Caption = strChildForm
    btnWork.ToolTipText = strChildForm

    Dim frmChild As New Form1
    Load frmChild
    frmChild.Caption = strChildForm
    frmChild.Tag = strChildForm
    frmChild.Show
   
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    If Left(Button.Key, 4) = "Form" _
    Then
        Dim frmWork As Form
        For Each frmWork In Forms
        With frmWork
            If .Tag = Button.Key _
            Then
                .Caption = "This Form Is Active"
                .SetFocus
            Else
                .Caption = .Tag
            End If
        End With
        Next frmWork
        Exit Sub
    End If
End Sub

<----- Code End ----->

5. ENJOY !!!!

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

632 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