Title: Bug in TMenuItem in a MDI Application
Question: When you design a MDI Application, everytime you create a Child Form it should be listed in the WindowMenu of the container Form, but this insnt always the case.
Answer:
I am developing an application for a goberment agency in Mexico, this is a MDI application, the users detected a bug, if they loaded for example three modules of the application (which are Child Forms), and then looked in the Windows menu of the application, none of the were listed, but if they loaded another Form after that, and lokked again in the windows menu, voila! all of the active Child Forms were listed.
So I searched in the Documentation and I found the following:
"The Window menu also lists (at the bottom) the child windows that are currently open in the application. When the user selects one of these windows from the menu, the window becomes the active window in the application.
...The names of open child forms are merged onto the menu AUTOMATICALLY at run-time."
Well, if the menu manages the names of the open child forms AUTOMATICALLY, what was wrong?, I decided to create a small sample MDI application and again it didint work, but one of my coleagues made another which diferent results, so I looked deeply the two projects in order to find a clue.
Here is the text representation of the working example:
object MainMenu1: TMainMenu
Left = 264
Top = 72
object File1: TMenuItem
Caption = '&File'
object Ventana11: TMenuItem
Caption = 'Window1 &1'
OnClick = Window1Click
end
object Window21: TMenuItem
Caption = 'Window2 &2'
OnClick = Window221Click
end
object Close1: TMenuItem
Caption = 'C&lose'
end
end
object Window1: TMenuItem
Caption = '&Window'
object Tile1: TMenuItem
Caption = '&Tile'
end
object Cascade1: TMenuItem
Caption = '&Cascade'
end
object ArrangeIcons1: TMenuItem
Caption = '&Arrange Icons'
end
end
object Exit1: TMenuItem
Caption = '&Exit'
end
end
And here is the code that didnt work:
object MainMenu1: TMainMenu
Left = 264
Top = 72
object File1: TMenuItem
Caption = '&File'
object Window1: TMenuItem
Caption = 'Window &1'
OnClick = Window1Click
end
object Window21: TMenuItem
Caption = 'Window &2'
OnClick = Window21Click
end
object Close1: TMenuItem
Caption = 'C&lose'
end
end
object Window1: TMenuItem
Caption = '&Window'
object Tile1: TMenuItem
Caption = '&Tile'
end
object Cascade1: TMenuItem
Caption = 'Cascade'
end
object ArrangeIcons1: TMenuItem
Caption = '&Arrange Icons'
end
end
object Exit1: TMenuItem
Caption = '&Exit'
end
end
When I compared the two examples, I found hard to believe that the diference I found was the cause of the problem, but it is! In case that you havent already realized, in the second listing, one the the TMenuItems of the WindowMenu has not an Ampersand (&) in its Caption.
That resolved the problem, now my users are happy, and I hope this can be useful to you