Solved

Minimize forms within MenuForm and not multiple forms on Windows Start Bar

Posted on 2009-05-05
6
161 Views
Last Modified: 2012-05-06
I have two or more forms that can be opened at the same time directly from my menu.  The forms, when minimized stay within the borders of my MainMenu form.

However, one of these forms has a button where I want to load another form, BUT NOT with .ShowDialog.  Or at least not where other forms that are open can't be activated.  I want all three forms to be free-wheeling and minimize without creating another minimized button on the start bar.

How would I open the 3rd form to create this type of situation?
From MainMenu....
 
Loading 1st Form
    Private Sub TruckStatus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuTruckStatus.Click
        If myFormsList.ContainsKey(1000) Then
            Dim frm As Form = DirectCast(myFormsList(1000), Form)
            Misc_BrowseFormStatus.RefreshBrowseFormStatusGrid.Invoke()
            frm.Activate()
            frm.WindowState = FormWindowState.Normal
        Else
            Dim frm As Form = Misc_BrowseFormStatus.Instance
            myFormsList.Add(1000, frm)
            frm.MdiParent = Me
            frm.Show()
        End If
    End Sub
 
Loading 2nd Form
    Private Sub mnuLoadMgmt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLoadMgmt.Click
        If myFormsList.ContainsKey(2) Then
            Dim frm As Form = DirectCast(myFormsList(2), Form)
            Main_LoadMgmt.ReActivateLoadEntryForm.Invoke()
            frm.Activate()
            frm.WindowState = FormWindowState.Normal
        Else
            glNewLoad = True
            Dim frm As Form = Main_LoadMgmt.Instance
            myFormsList.Add(2, frm)
            frm.MdiParent = Me
            frm.Show()
        End If
    End Sub
 
Loading 3rd Form from inside 2nd Form
    Private Sub bBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bBrowse.Click
            glTable = "truck_loads"
            If myFormsList.ContainsKey(2001) Then
                Dim frm As Form = DirectCast(myFormsList(2001), Form)
                frm.Activate()
                frm.WindowState = FormWindowState.Normal
            Else
                Dim frm As Form = Misc_BrowseForm.Instance(dvGlobalLoads.Sort)
                myFormsList.Add(2001, frm)
                frm.Show()      ????? Here's the problem
            End If
        End If
    End Sub

Open in new window

0
Comment
Question by:TSFLLC
[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
  • 2
6 Comments
 
LVL 12

Expert Comment

by:needo_jee
ID: 24310301
hi,

could you try this

 Dim frm As Form = Misc_BrowseForm.Instance(dvGlobalLoads.Sort)
                myFormsList.Add(2001, frm)
                frm.Show(Me)      ????? Here's the problem


OR

me.ownedforms.add( frm)
frm.show()

-Thanks
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24312211
Change this code
                Dim frm As Form = Misc_BrowseForm.Instance(dvGlobalLoads.Sort)
                myFormsList.Add(2001, frm)
                frm.Show()      ????? Here's the problem

to this
                Dim frm As Form = Misc_BrowseForm.Instance(dvGlobalLoads.Sort)
                myFormsList.Add(2001, frm)
                frm.MdiParent = Me.MdiParent
                frm.Show()      '????? Here's the problem
0
 

Author Comment

by:TSFLLC
ID: 24313573
needo_jee,

You might want to check the member list for OwnedForms.  Add is not a vlid member.
frm.Show(Me) displays the form in 'dialog mode' in that I cannot click on the other forms and make them active on top.  It also creates a separate window on the start bar as I was attempting to rectify.

CodeCruiser,
I don't know why I had not figured this one out before.
Making the current form MdiParent of Misc_BrowseForm worked like a charm.  Have a number of places with other forms where I will need to update this.

Mucho thanks!
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Closing Comment

by:TSFLLC
ID: 31578286
Perfect one-liner !!!
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24314010
TSFLLC,
I am glad that you problem is solved. One clarification though.
>Making the current form MdiParent of Misc_BrowseForm worked like a charm.
I think you are confused here. When you start form2, you set its mdiparent to be mainform. Then when you set form3.mdiparent = form2.mdiparent then it means the mdiparent of form3 is the mainform as well. Only forms with IsMDIParent property set to true can be set as MDIParents.
0
 

Author Comment

by:TSFLLC
ID: 24314965
My mistake....I transposed the form in my comment.  You are very correct.

Thanks for the clarification.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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