gpt4 book ai didi

forms - Firemonkey 的多种表单在窗口菜单中显示多个项目

转载 作者:行者123 更新时间:2023-12-03 15:31:03 28 4
gpt4 key购买 nike

我目前正在尝试 Firemonkey 并遇到了这个问题。当我的申请中有多个表格时,我会得到相同数量的项目在我的 Windows 菜单栏中的一个应用程序(参见屏幕截图)。

在常规 VCL 应用程序中,只有一项标识应用程序(所以我的屏幕截图将只包含“Form2”项目)。

有谁知道我如何才能完成与 VCL 应用程序相同的行为,所以我的多表格申请只有一项???

multiple items

提前致谢!

泰斯

编辑:我成功地显示了第二种表单,底部菜单中只有一项,但表单的“透明度”属性必须为 true!因此,为了使第二个窗体可见,需要在第二个窗体中放置一个 TRectangle(带有标题和按钮的框架不可见)...

最佳答案

我找到了解决这个问题的方法。

当您创建具有所有者的表单时,FireMonkey 应该将所有者传递给 Windows CreateWindowEx 函数,但事实并非如此。

在单元FMX.Platform.Win中,在CreateWindow()函数中,更改以下内容:

  Wnd := CreateWindowEx(ExStyle, WindowClass.lpszClassName, PChar(AForm.Caption), Style,
Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),
GetDesktopWindow, 0, hInstance, nil);

对此:

  // If there's an owner, and it's a form, then create the window as a child
if (AForm <> nil) and (AForm.Owner <> nil) and (AForm.Owner is TForm) then
begin
// Child window
Wnd := CreateWindowEx(ExStyle, WindowClass.lpszClassName, PChar(AForm.Caption), Style,
Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),
HandleToHWND(TForm(AForm.Owner).Handle), 0, hInstance, nil);
end
else
begin
// Desktop window
Wnd := CreateWindowEx(ExStyle, WindowClass.lpszClassName, PChar(AForm.Caption), Style,
Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),
GetDesktopWindow, 0, hInstance, nil);
end;

因此,如果您要创建子表单,尤其是模态表单,请确保在创建子表单时将父表单指定为所有者,如下所示:

MyModalForm := TMyModalForm.Create(MyParentForm);
MyModalForm.ShowModal;

然后,修复后一切都会按预期工作。

不要忘记从项目设置的自动创建表单列表中删除子表单。

关于forms - Firemonkey 的多种表单在窗口菜单中显示多个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8489259/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com