Solved

Delphi Mdi application Child forms get behind control

Posted on 2016-08-24
7
212 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 37

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 37

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 37

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 37

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 37

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

773 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