📄 faq66.htm
字号:
<HTML>
<HEAD>
<TITLE>Create an MDI menu that lists open MDI windows.</TITLE>
<META NAME="Author" CONTENT="Harold Howe">
</HEAD>
<BODY BGCOLOR="WHITE">
<CENTER>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="640">
<TR>
<TD>
<H3>
Create an MDI menu that lists open MDI windows.
</H3>
<P>
Most MDI programs contain a Window menu that lists all of the open MDI windows in a program. Figure 1 illustrates
this menu item.
</P>
<IMG SRC="images/windowmenu.gif" ALT="An MDI Window menu" BORDER=0 HSPACE="0" ALIGN="CENTER" VALIGN="TOP">
<P><B>Figure 1: MDI Windows Menu.</B>
<P>
C++Builder can create and maintain the window menu without requiring you to do any work. To add a window menu to
your MDI project, follow these steps:
</P>
<P>
<B>Step 1:</B> Add a menu item to the <TT>TMainMenu</TT> control that is on the MDI parent form. Set the
<TT>Caption</TT> property of this item to <TT>&Window</TT>. Set the <TT>GroupIndex</TT> of this menu item to a high
value to keep the window menu menu to the right of any child menu items that get merged into the main menu. Usually, you
will add sub menu items under the window menu for tiling, cascading, and minimizing the MDI child windows.
</P>
<P>
<B>Step 2:</B> Bring up the MDI parent window in the Object Inspector. All forms have a property called
<TT>WindowMenu</TT>. This property is a <TT>TMenuItem</TT> pointer that tells the VCL which menu item will act as the
MDI window menu. Use the combobox provided in this property to select the window menu item that you created in step 1.
</P>
<P>
That's it. Run the program and see if it works. Notice that the window items appear automatically. Also notice that
you don't have to write any code to activate an MDI child when it is selected from the menu.
</P>
<P>
<B>Note:</B> If you want your window menu to contain items for tiling and cascading the MDI children, you will have
to code those <TT>OnClick</TT> handlers yourself. <TT>TForm</TT> provides functions that can help you do the work:
<TT>Tile</TT>, <TT>Cascade</TT>, <TT>ArrangeIcons</TT>. If you use the MDI project wizard in the Object Repository, this
code is created for you by C++Builder.
</P>
<P>
<B>Note:</B> If you create your project using the MDI project wizard in the Object Repository, the <TT>WindowMenu</TT>
property will be configured for you.
</P>
</TD> </TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -