Multiple forms with Firemonkey showing multiple items in a Windows menu

I am currently experimenting with Firemonkey and stumbled upon this. When I have several forms in my application, I get the same number of items in my Windows menu bar for a single application (see screenshot).

In normal VCL applications, there is only one element that identifies the application (so my screenshot will only contain the "Form2" element).

Does anyone know how I can perform the same behavior as a VCL application, so that there is only one element for my multi-format application ???

multiple items

Thanks in advance!

Tys

Edit: I managed to display the second form with one element in the bottom menu, but the β€œTransparency” property of the form should be true! Therefore, in order to make the second visible figure, the TRectangle must be placed in the second form (without a frame with an inscription and buttons visible) ...

+4
source share
1 answer

I found a workaround for this.

When you create a form with the owner, FireMonkey should pass the owner down to the Windows CreateWindowEx , but that is not the case.

In the FMX.Platform.Win module in the CreateWindow() function, change this:

  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); 

For this:

  // If there an owner, and it 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; 

So, if you are going to create a child, especially a modal form, be sure to designate the parent form as the owner when you create it as follows:

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

Then everything will work as expected after the fix.

Do not forget to remove the child form from the list of Forms of automatic creation in the settings of your project.

+3
source

Source: https://habr.com/ru/post/1386099/


All Articles