Jump to content
vhanla

FMX form called from VCL form doesn't apply Top Most style to its child windows.

Recommended Posts

I'm using MonkeyMixer IDE plugin to allow inserting a new FMX form inside my VCL project.

I'm launching the FMX form using:

Form2.Parent := Form1;

Form2.Show;

However, the Form2 (FMX form), its FormStyle is set to StayOnTop.

But the new child windows won't show inheriting the WS_EX_TOPMOST GWL_EXSTYLE from the Form2 (fmx window), which indeed, it is TOP MOST.

So the result is something like this:

image.thumb.png.fd991f2c99f8c9b38c004f975fa55b8c.png

- The context menu shows behind the form.

- The ShowMessage also shows behind that form.

- And if I close that Form2, the ShowMessage window still remains there.

Important: The context menu (PopupMenu) and the ShowMessage box belongs to the Form2 (FMX form).

 

Notice that this works correctly in a pure FMX project, but this issue only happens in the mixed methods.

 

I guess it has something to do with the VCL forms interfering with the FMX forms handling, since using VCL styles, seems to be applied in the FMX form but partially, as shown in the following picture:

image.thumb.png.9d2b123a72eae988f2db140bb1ddbdd7.png

 

Do you know how to fix that?

 

[EDIT] I found a hardcoded "workaround", which is to modify the FMX.Platform.Win.pas file modifying the function TPlatformWin.CreateAppHandle:HWND; adding WS_EX_TOPMOST 😅, it "works as expected" now, but it will turn all TOPMOST:

  Result := CreateWindowEx(WS_EX_WINDOWEDGE or WS_EX_TOPMOST or WS_EX_TOOLWINDOW, FMAppClass.lpszClassName, PChar(FTitle),
                           WS_POPUP or WS_GROUP, 0, 0, 0, 0, GetDesktopWindow, 0, hInstance, nil)

 

Edited by vhanla
Add more info.

Share this post


Link to post
On 8/17/2023 at 6:19 AM, vhanla said:

Form2.Parent := Form1;

 

Form2.Show;

But how? :classic_blink:

 

[dcc32 Error] uMainForm.pas(27): E2010 Incompatible types: 'TFmxObject' and 'TForm1'

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×