Solved

Delphi Mdi application Child forms get behind control

Posted on 2016-08-24
7
114 Views
Last Modified: 2016-09-07
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.
0
Comment
Question by:Member_2_7965240
  • 5
  • 2
7 Comments
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 41768788
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
 

Author Comment

by:Member_2_7965240
ID: 41774539
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
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 41774586
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 41774589
change properties of the mdi child form for the menu :

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

Open in new window

0
 
LVL 36

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 41774723
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
 

Author Comment

by:Member_2_7965240
ID: 41785689
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
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 41787427
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now