When you select the WindowList option for a menu item on the Window menu of a MDI application you will get a sub menu with the list of open windows. If you do not want this you can get a list right on the Window menu like in a professional application by following these steps.
Create a top level menu called mnuWindow with a caption of Window and the following sub menu items on the MDI parent form
For the Click events of mnuWindowCascade, mnuWindowTile and mnuWindowArrange enter the standard VB commands for tiling, cascading and arranging windows.
For the Click event of mnuWindowList which should have Index As Integer for an argument enter
Dim F As Form
'loop through all open forms
For Each F In Forms
'check each form to see if it is the selected form
If mnuWindowList(Index).Caption = F.Caption Then
This will make selecting one of the choices on the list give the focus to the form whose captions is on the picked choice.
Your Window menu’s choices will now respond appropriately to a user selections, but at run time you will find no Windows listed below the separator bar. Further if your program does not open more than one child form at startup you will be able to make choices that have no meaning.
To solve these problems create the following subroutine in the MDI parent form
Dim Counter As Integer
Counter = 0
'set enabled property for menus and menu selections to allow for
‘functions that cannot be carried out at the current time
mnuWindowCascade.Enabled = False
mnuWindowTile.Enabled = False
mnuWindowArrange.Enabled = False
mnuWindowSeperator.Visible = False
Do Until Counter = mnuWindowList.Count
mnuWindowList(Counter).Visible = False
Counter = Counter + 1
and add modWindowListFunctions.bas to your program. After adding the bas the only edit you need to make to it is to change all occurrences of frmStartup to the name of your applications MDI parent form.
After that all that’s left is calls to the newly added code. In the Load event for the MDI parent form enter
For all child forms enter Call ResetWindowList(Me, "add") in the Activate event and and Call ResetWindowList(Me, "remove") in the Deactivate event.
For all child forms enter Call WindowListAddItem(Me) in the Load event and
If UnloadMode = 0 Or UnloadMode = 1 Then
in the QueryUnload event.
Lila Godel's Web Site
Brought To You By Hamilton Services, Inc.