Delphi Xe2 with Firemonkey:您是否可以拥有一个以默认 Windows 非客户端绘画风格以外的风格绘画的非客户端区域?

发布于 2024-12-28 19:08:11 字数 473 浏览 2 评论 0原文

这是我使用 firemonkey + Delphi XE2 制作的 delphi 应用程序的示例。

正如您所看到的,您可以使用 Firemonkey 中的视觉样式“样式书”来自定义窗口框架内大多数内容的外观。然而,窗框的外部是使用 Windows 决定的任何样式绘制的。现在,如果我使用 VCL 而不是 Firemonkey,我可以应用“VCL 样式”并将整个 VCL 应用程序“换肤”为深色配色方案。

我的猜测是 Delphi XE2 + Firemonkey 还不可能做到这一点。谁能展示如何做到这一点?

在此处输入图像描述

在设计时,表单的“预览”会显示漂亮的黑色边框。但是当我运行我的应用程序时,Windows XP“Luna”主题边框(下图中的蓝色部分)看起来很糟糕。讽刺的是,VCL(在带有样式的 XE2 中)比 Firemonkey 更漂亮......

Here is a sample of a delphi application I am making using firemonkey + Delphi XE2.

As you can see, you can use the visual style "stylebook" in Firemonkey to customize the appearance of most things inside the window frame. However the outside of the window frame is drawn using whatever style Windows decides. Now if I was using VCL instead of Firemonkey, I could apply "VCL Styles" and "skin" the whole VCL application in a dark color scheme.

My guess is that this is NOT YET posssible with Delphi XE2 + Firemonkey. Can anyone show how to do this?

enter image description here

At designtime, the "preview" of your form shows a nice black border. But when I run my app, the Windows XP "Luna" theme border (the blue parts in the picture below) looks atrocious. Ironically, the VCL is prettier (in XE2 with styles) than Firemonkey...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

快乐很简单 2025-01-04 19:08:11

您可以像往常一样创建一个 VCL Forms 应用程序,如果您喜欢的话可以使用样式,在运行时加载 Firemonkey 表单并将 VCL 表单设置为其父表单:

uses
  FMX.Platform.Win, FMX.Forms,
  Unit2;

procedure TForm1.FormCreate(Sender: TObject);
var
  Form2: TForm2;
begin
  Form2 := TForm2.Create(nil);
  Form2.BorderStyle := FMX.Forms.TFmxFormBorderStyle.bsNone;
  Form2.SetBounds(0, 0, ClientWidth, ClientHeight);
  Winapi.Windows.SetParent(FmxHandleToHWND(Form2.Handle), Handle);
  Form2.Show;
end;

在下面的屏幕截图中,Form1 是 VCL 应用程序主表单(具有 Carbon 样式),带有按钮的深灰色区域是嵌入的 Firemonkey 表单:

Firemonkey formembedded in a VCL form

请注意,我不是处理调整父窗口的大小 - 它也应该调整嵌入表单的大小,模拟 alClient 对齐方式。
这种方法似乎存在许多潜在问题 - 我认为 IDE 不允许您轻松地将 Firemonkey 表单与 VCL 表单混合是有原因的 - 它会警告可能的“编译错误或意外行为”。

You can create a VCL Forms application as usual, with styles if you like, at runtime load your Firemonkey form and set your VCL form as its parent:

uses
  FMX.Platform.Win, FMX.Forms,
  Unit2;

procedure TForm1.FormCreate(Sender: TObject);
var
  Form2: TForm2;
begin
  Form2 := TForm2.Create(nil);
  Form2.BorderStyle := FMX.Forms.TFmxFormBorderStyle.bsNone;
  Form2.SetBounds(0, 0, ClientWidth, ClientHeight);
  Winapi.Windows.SetParent(FmxHandleToHWND(Form2.Handle), Handle);
  Form2.Show;
end;

In the following screenshot, Form1 is the VCL application main form (with Carbon style) and the dark-grey area with the button is the embedded Firemonkey form:

Firemonkey form embedded in a VCL form

Note that I'm not handling resizing of the parent window - it should resize the emebedded form, too, emulating alClient alignment.
It seems there are many potential problems with this approach - I think there's a reason why the IDE doesn't let you easily mix Firemonkey forms with VCL forms - it warns about possible "compilation errors or unexpected behavior."

〃安静 2025-01-04 19:08:11

Firemonkey 是跨平台的。总的来说,您无法在 FMX 框架本身内执行任何依赖于平台的操作。但是,您可以调用底层平台(Windows、OSX 或 iOS)来访问特定于平台的功能。这应该在条件编译的代码中完成。

例如。

{$IF DCC}
  something;
{$ENDIF}

{$IF FPC}
  somethingelse;
{$ENDIF}

从另一个角度来看,您可能可以在 TRectangle(例如)上完成所有 FMX 工作,然后使用 AddObject(或分配其父级)到 VCL 表单。

Firemonkey is cross platform. By and large you cannot do anything that is platform dependent within the FMX framework itself. You can however make calls to the underlying platform (be it windows, OSX or iOS) to access platform specific functionality. This should be done within conditionally compiled code.

eg.

{$IF DCC}
  something;
{$ENDIF}

{$IF FPC}
  somethingelse;
{$ENDIF}

Looking at it from another viewpoint, it may be possible for you do do all of your FMX work on a TRectangle (for example), then use AddObject (or assign its parent), to a VCL form.

末蓝 2025-01-04 19:08:11

如果将表单 BorderStyle 更改为 bsNone,则可以添加所需的任何镶边。当然,您需要手动处理最大化、最小化、关闭、调整大小等操作。

If you change the forms BorderStyle to bsNone, you can add whatever chrome you want. You will, of course, need to manually handle maximise, minimise, close, resize etc actions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文