奇怪的问题,关于mdi窗口(25分)

  • 主题发起人 主题发起人 进进
  • 开始时间 开始时间

进进

Unregistered / Unconfirmed
GUEST, unregistred user!
我将form1设为fsMDIForm,并为main form,将form2设为fsMDIChild,
在form1的菜单中写有: form2.show;
为什么程序一运行,form2就被打开,而我还跟本没有按菜单,
我希望form2在我按下form1的菜单后打开,允满form1的工作区窗口,
而不掩盖form1的菜单。我是新手,分是少了。
谢谢垂教。
 
1)在项目文件.dpr中把Application.CreateForm(TForm2,Form2);这一行删掉
2)不掩盖菜单是不可能的,除非那个菜单控件是你自制的不用windows的
 
用向导创建一个试试:
New->Projects->MDI Application->OK
注意:
1、在Project->Options->Form页,将子窗体加到Availabel Forms列表中
2、在子窗体的OnClose事件中加上代码:Action := caFree;
 
倒是有办法把MDI与MDICHILD的菜单合并
 
同意x900
子窗体设计的时候不创建菜单;在程序中当要显示子窗体时动态修改主窗体的菜单
 
>>我希望form2在我按下form1的菜单后打开,允满form1的工作区窗口,
>>而不掩盖form1的菜单
设置form2的菜单项目的GroupIndex属性,和主窗体的主菜单的GroupIndex不同就不会覆盖。
详细可以参考帮助文件的TMenuItem.GroupIndex说明
以下为节选
Identifies the logical group to which the menu item belongs.

property GroupIndex: Byte;

Description

Use GroupIndex to control how menus are merged. In applications that contain
multiple forms, items from the menus of secondary forms can be merged into the
application抯 main menu as those forms become active. MDI applications always
merge the menus of child windows with the main menu of the parent window.

By default, all menu items in a menu bar (main menu) have the same GroupIndex
value. To use GroupIndex to merge menus, set the GroupIndex value of each
successive menu item to a value equal to or greater than that of the previous
menu item.

When a menu item in a menu bar that is merged into the application's main
menu has the same GroupIndex value as a menu item in the main menu, the
menu item in the application's main menu is replaced by the corresponding
menu item. If multiple menu items in the application's main menu have the
same GroupIndex value, they can be replaced only by separate menu items
from the other form's menu that also have repeated GroupIndex values.
Thus, the first main menu item with a given value is replaced by the first
item in the second form with that value, the second item in the main form
is replaced by the second item in the second form, and so on.

When a menu item in a menu bar that is merged into the application's main
menu has a GroupIndex that falls between the GroupIndex values of two
adjacent items on the application's main menu, that menu item is inserted
between the two adjacent items. If the item's GroupIndex value is greater
than all other GroupIndex values in the application's main menu, the item
appears at the end of the main menu. If the GroupIndex value is less than
all other GroupIndex values in the application's main menu, the menu item
appears at the beginning of the main menu bar.
 
在项目文件.dpr中把Application.CreateForm(TForm2,Form2);这一行删掉
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
562
import
I
I
回复
0
查看
557
import
I
I
回复
0
查看
734
import
I
后退
顶部