Delphi Mdi application Child forms get behind control

Hello,

I have an MDI application created in Delphi (the application has many reasons to be MDI, one of them, that the menu of the main form is always visible and clickable even if other forms are open).

The problem:
I put some Tile controls on the Main form so as the user can start some functions even easier.
When I open a child form it is shown behind the tile control, so it is not visible.

How can I avoid this?

Thank you.
Member_2_7965240Asked:
Who is Participating?
 
Geert GConnect With a Mentor Oracle dbaCommented:
actually, it's pointless to use an mdi setup with tiles

add a panel, with some other controls, like a label and an edit and ...

select a tile, check the frames property, and add 1 if you haven't already
in frame set the detailcontrol to the panel you just created

if you run that, and hit the tile button,
it will rotate left and display the contents of the panel
and a back button to go back to the tile menu
0
 
Geert GOracle dbaCommented:
Use BringToFront on the child form after opening it

The Forms/Windows inside the MainForm container have a Z order
BringToFront place it at the top

child := TMdiChild.Create(Self);
child.Caption := 'blablabla';
// ..
child.BringToFront;

Open in new window


Alternative:
You could also move all the Tile forms to the back with the method SendToBack
0
 
Member_2_7965240Author Commented:
Geert Gruwez: thank you for the answer.

The child.BringToFront doesn't work, the child form is still behind the Tile controls.

And this is which maybe you misunderstood: I wrote "Tile controls" and not tile forms.

I use Devexpress TdxTileControl (but anyway if I put a simple Button on the main form, the child form will get under it too).

Thank you.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Geert GOracle dbaCommented:
well yes.
If you put the TdxTileControl in the main form that's the way it will work

create an mdi child with that TdxTileControl inside it
I used the sample of the Mdi application and added this:

unit uTileMenu;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, dxTileControl,
  cxLookAndFeels, cxLookAndFeelPainters, dxCustomTileControl, cxClasses;

type
  TmdiTileMenu = class(TForm)
    dxTileControl1: TdxTileControl;
    dxTileControl1Group1: TdxTileControlGroup;
    dxTileControl1Item1: TdxTileControlItem;
    dxTileControl1Item2: TdxTileControlItem;
    dxTileControl1Item3: TdxTileControlItem;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  mdiTileMenu: TmdiTileMenu;

implementation

{$R *.dfm}

end.

Open in new window


object mdiTileMenu: TmdiTileMenu
  Left = 346
  Top = 274
  BorderIcons = []
  BorderStyle = bsNone
  ClientHeight = 358
  ClientWidth = 741
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  FormStyle = fsMDIChild
  OldCreateOrder = False
  Visible = True
  WindowState = wsMaximized
  PixelsPerInch = 96
  TextHeight = 13
  object dxTileControl1: TdxTileControl
    Left = 0
    Top = 0
    Width = 741
    Height = 358
    TabOrder = 0
    ExplicitLeft = -151
    ExplicitTop = 189
    ExplicitWidth = 892
    ExplicitHeight = 169
    object dxTileControl1Group1: TdxTileControlGroup
      Index = 0
    end
    object dxTileControl1Item1: TdxTileControlItem
      GroupIndex = 0
      IndexInGroup = 0
      Size = tcisLarge
      Text1.AssignedValues = []
      Text2.AssignedValues = []
      Text3.AssignedValues = []
      Text4.AssignedValues = []
    end
    object dxTileControl1Item2: TdxTileControlItem
      GroupIndex = 0
      IndexInGroup = 1
      RowCount = 2
      Size = tcisExtraLarge
      Text1.AssignedValues = []
      Text2.AssignedValues = []
      Text3.AssignedValues = []
      Text4.AssignedValues = []
    end
    object dxTileControl1Item3: TdxTileControlItem
      GroupIndex = 0
      IndexInGroup = 2
      Size = tcisSmall
      Text1.AssignedValues = []
      Text2.AssignedValues = []
      Text3.AssignedValues = []
      Text4.AssignedValues = []
    end
  end
end

Open in new window



    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure CreateMDIChild(const Name: string);
    procedure WMUser(var Msg: TMessage); message WM_USER;
  public
    { Public declarations }
  end;


procedure TMainForm.FormCreate(Sender: TObject);
begin
  PostMessage(Handle, WM_USER, 1, 0);
end;

procedure TMainForm.WMUser(var Msg: TMessage);
var tm: TmdiTileMenu;
begin
  tm := TmdiTileMenu.Create(Application);
end;

Open in new window


you'll have to write some code to handle bringing the menu to the front
components you place directly on the Mdi Main form always appear on top

you have to move controls to an mdichild window
and place the mdichild window on the main form
0
 
Geert GOracle dbaCommented:
change properties of the mdi child form for the menu :

  BorderIcons = []
  BorderStyle = bsNone
  FormStyle = fsMDIChild
  WindowState = wsMaximized

Open in new window

0
 
Member_2_7965240Author Commented:
Geert Gruwez:
Thank you for the answer.

select a tile, check the frames property, and add 1 if you haven't already
in frame set the detailcontrol to the panel you just created

I checked it but at me the frame of the tile doesn't contain detailcontrol property.

Thank you
0
 
Geert GOracle dbaCommented:
i was going to create sample ... but the TileControl has bugs !
at least my version has: 14.2.7

I added 3 panels on my form
then assigned each to an item

hit F9

then changed the text1 of each item
and all my panels disappeared !
they were deleted from the form

yuck ...

it seems to force you to work with frames, assigning them at runtime to each item
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.