当在另一个的TPanel上显示VCL表单时,这不会发生;表格显然是“合并”.我应该怎么做才能使用FireMonkey获得类似的结果?我希望FireMonkey表单上的控件可用,但保持父表单激活.
更新1
VCL
unit Unit1;interfaceuses WinAPI.windows,WinAPI.Messages,System.SysUtils,System.Variants,System.Classes,Vcl.Graphics,Vcl.Controls,FMX.Forms,Vcl.Forms,Vcl.Dialogs,Vcl.StdCtrls,Vcl.ExtCtrls,FMX.Platform.Win;type TMainForm = class(TForm) Panel1: TPanel; button1: Tbutton; procedure button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var MainForm: TMainForm;implementation{$R *.dfm}uses FireMonkeyForms;procedure TMainForm.button1Click(Sender: TObject);var LFMForm: FireMonkeyForms.TForm1; LFMHWnd: HWND;begin LFMForm := FireMonkeyForms.TForm1.Create(nil); LFMForm.left := 0; LFMForm.top := 0; LFMForm.Height := Panel1.ClIEntHeight; LFMForm.WIDth := Panel1.ClIEntWIDth; LFMForm.borderStyle := TFmxFormborderStyle.bsNone; LFMForm.borderIcons := []; LFMHWnd := FmxHandletoHWND(LFMForm.Handle); SetwindowLong(LFMHWnd,GWL_STYLE,getwindowlong(LFMHwnd,GWL_STYLE) or WS_CHILD); WinAPI.windows.SetParent(LFMHWnd,Panel1.Handle); LFMForm.Visible := True;end;end.
FireMonkey
unit FireMonkeyForms;interfaceuses System.SysUtils,System.Types,System.UITypes,FMX.Types,FMX.Controls,FMX.Dialogs,FMX.Layouts,FMX.Memo;type TForm1 = class(TForm) Label1: TLabel; Memo1: TMemo; private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.fmx}end.解决方法 行为的原因是窗口管理器不知道您已将firemonkey窗口设为子窗口,因此在激活firemonkey窗口时它将停用先前活动的窗口.如
SetParent function
中所述,您必须手动设置子标志.示例用法可以是: var FMForm: TFMForm1; FMHWnd: HWND;begin FMForm := TFMForm1.Create(nil); FMForm.left := 0; FMForm.top := 0; FMHWnd := FmxHandletoHWND(FMForm.Handle); SetwindowLong(FMHWnd,getwindowlong(FMHwnd,GWL_STYLE) or WS_CHILD); winAPI.windows.SetParent(FMHWnd,Panel1.Handle); FMForm.Visible := True;
更新:
如果必须删除fmx表单的边框,则设置borderStyle会设置WS_CHILD样式,而WS_CHILD样式不能与WS_CHILD一起使用.在这种情况下,请明确设置您需要的样式,而不是获取和“或”它们. F.i.
.. LFMForm.borderIcons := []; LFMForm.borderStyle := TFmxFormborderStyle.bsNone; LFMHWnd := FmxHandletoHWND(LFMForm.Handle); SetwindowLong(LFMHWnd,WS_CHILDWINDOW or WS_border); ..总结
以上是内存溢出为你收集整理的delphi – 如何在VCL表单中无缝嵌入FireMonkey表单?全部内容,希望文章能够帮你解决delphi – 如何在VCL表单中无缝嵌入FireMonkey表单?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)