?
Solved

trouble forms mdi child

Posted on 1998-11-11
3
Medium Priority
?
234 Views
Last Modified: 2010-04-04
i got an aplication, and it got MDI parent and children, my question is, how can i call into the MDI parent a child form
i've us  Tform.create(self) but it doesn't work.
later, how can i close them(children forms).
   
0
Comment
Question by:jabita
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 200 total points
ID: 1346617
Here is an example...

Let's say you have a menu where you have an item New to create a new form...Here is how this is coded...

TForm1 is the MDI Child form's name...

with TForm1.Create(self) do
try
  //Maybe some properties or something...
  ShowModal;
finally
  Free;
end;

Hope this helps.
Cheers,
Viktor
0
 

Author Comment

by:jabita
ID: 1346618
i have use it but doesn't work
when i use run by step it collapse in the instruction TForm1.Create(self), and i dont know why, the compiler just give the direcctions.
 
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1346619
Hello again!

Here is a whole project I got together for you....It contains two units ./// a Child.pas and Frame.pas .... The Child.pas is the unit that actually containts the Child Form.... Take a look at them...

//------------------- Frame.pas -------------------//
unit Frame;
interface
uses Windows, Classes, Graphics, Forms, Controls, Child,
  Menus, SysUtils;
type
  TMainForm = class(TForm)
    MainMenu1: TMainMenu;
    Window1: TMenuItem;
    New1: TMenuItem;
    File1: TMenuItem;
    N1: TMenuItem;
    Exit1: TMenuItem;
    Cascade1: TMenuItem;
    Tile1: TMenuItem;
    ArrangeIcons1: TMenuItem;
    procedure New1Click(Sender: TObject);
    procedure Cascade1Click(Sender: TObject);
    procedure Tile1Click(Sender: TObject);
    procedure ArrangeIcons1Click(Sender: TObject);
    procedure Exit1Click(Sender: TObject);
  private
    { Private declarations }
    Counter: Integer;
  public
    { Public declarations }
  end;
var
  MainForm: TMainForm;
implementation
{$R *.DFM}
procedure TMainForm.New1Click(Sender: TObject);
var
  ChildForm: TChildForm;
begin
  Inc (Counter);
  ChildForm := TChildForm.Create (self);
  ChildForm.Caption := ChildForm.Caption + ' ' +
    IntToStr (Counter);
  ChildForm.Show;
end;
procedure TMainForm.Cascade1Click(Sender: TObject);
begin
  Cascade;
end;
procedure TMainForm.Tile1Click(Sender: TObject);
begin
  Tile;
end;
procedure TMainForm.ArrangeIcons1Click(Sender: TObject);
begin
  ArrangeIcons;
end;
procedure TMainForm.Exit1Click(Sender: TObject);
begin
  Close;
end;
end.
//------------------- Child.pas -------------------//
unit Child;
interface
uses
  Windows, Classes, Graphics, Forms,
  Controls, Menus, Dialogs, SysUtils;
type
  TChildForm = class(TForm)
    MainMenu1: TMainMenu;
    Circle1: TMenuItem;
    FillColor1: TMenuItem;
    BorderColor1: TMenuItem;
    BorderSize1: TMenuItem;
    N1: TMenuItem;
    GetPosition1: TMenuItem;
    ColorDialog1: TColorDialog;
    procedure FormCreate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FillColor1Click(Sender: TObject);
    procedure BorderColor1Click(Sender: TObject);
    procedure BorderSize1Click(Sender: TObject);
    procedure GetPosition1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    XCenter, YCenter: Integer;
    BorderSize: Integer;
    BorderColor, FillCOlor: TColor;
  public
    { Public declarations }
  end;
var
  ChildForm: TChildForm;
implementation
{$R *.DFM}
procedure TChildForm.FormCreate(Sender: TObject);
begin
  XCenter := - 200;
  YCenter := - 200;
  BorderSize := 1;
  BorderColor := clBlack;
  FillColor := clYellow;
end;
procedure TChildForm.FormPaint(Sender: TObject);
begin
  Canvas.Pen.Width := BorderSize;
  Canvas.Pen.Color := BorderColor;
  Canvas.Brush.Color := FillColor;
  Canvas.Ellipse (XCenter-30, YCenter-30, XCenter+30, YCenter+30);
end;
procedure TChildForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  XCenter := X;
  YCenter := Y;
  Repaint;
end;
procedure TChildForm.FillColor1Click(Sender: TObject);
begin
  ColorDialog1.Color := FillColor;
  if ColorDialog1.Execute then
  begin
    FillColor := ColorDialog1.Color;
    Repaint;
  end;
end;
procedure TChildForm.BorderColor1Click(Sender: TObject);
begin
  ColorDialog1.Color := BorderColor;
  if ColorDialog1.Execute then
  begin
    BorderColor := ColorDialog1.Color;
    Repaint;
  end;
end;
procedure TChildForm.BorderSize1Click(Sender: TObject);
var
  InputString: string;
begin
  InputString := IntToStr (BorderSize);
  if InputQuery ('Border', 'Insert width', InputString) then
  begin
    BorderSize := StrToIntDef (InputString, BorderSize);
    Repaint;
  end;
end;
procedure TChildForm.GetPosition1Click(Sender: TObject);
begin
  MessageDlg ('The center of the circle is in the position (' +
    IntToStr (XCenter) + ', ' + IntToStr (YCenter) + ').',
    mtInformation, [mbOk], 0);
end;
procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;
end.

Hope this helps you!

If you still need some help just say so :)

Cheers,
Viktor
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 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