[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Delphi: Define FormStyle fsMDIChild or fsNormal at runtime

Posted on 2013-01-02
2
Medium Priority
?
2,562 Views
Last Modified: 2013-01-02
I have a Vcl.Form that is a MDIChild (FormStyle=fsMDIChild). No I have the requirement that I need this form also as a modal dialog. I tried to change the FormStyle at runtime but that does not work.

In the VCL documentation I found a remark that FormStyle should not be changed at runtime. That's obiously the reason why it doesn't work. A workaround would be to have a copy of that form so that one form has FormStyle=fsNormal and the other FormStyle=fsMDIChild. But this is a maintenance nightmare.

Can somebody help me find a solution to that problem? Maybe someone has a better workaround, etc.?

Regards,
Dirk.
0
Comment
Question by:dirkil2
[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 Comments
 

Accepted Solution

by:
dirkil2 earned 0 total points
ID: 38738120
I just found that my question has been aswered before: http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20976700.html

Therefore I suggest to close my question.
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 38738185
I suggest to use TFrame container. It is like TForm but without border. So, add TFrame to project. Add all components and code to that unit like you do on your form. Then you can create TForm on runtime as TMdiChild or Dialog. This is the way to put your frame control to other form....

... when you want to create dialog:
procedure TForm1.Button1Click(Sender: TObject);
var
  frm: TFrame1;
  modalFrm: TForm;
begin
  modalFrm := TForm.Create(Self);
  try
    modalFrm.BorderStyle := bsDialog;
    modalFrm.Position := poScreenCenter;
    modalFrm.Width := 500;
    modalFrm.Height := 400;

    frm := TFrame1.CreateParented(modalFrm.Handle);
    frm.Parent := modalFrm;
    frm.Align := alClient;
    frm.Visible := True;

    modalFrm.ShowModal;
  finally
    modalFrm.Free;
  end;
end;

Open in new window


... when you want to put frame on form as mdichild:
var
  frm: TFrame1;
  mdiFrm: TForm;
begin
  mdiFrm := TForm.Create(nil);
  try
    mdiFrm.FormStyle := fsMDIChild;
    mdiFrm.Parent := Self;
    mdiFrm.Width := 500;
    mdiFrm.Height := 400;

    frm := TFrame1.CreateParented(mdiFrm.Handle);
    frm.Parent := mdiFrm;
    frm.Align := alClient;
    frm.Visible := True;

    mdiFrm.Show;
   // mdiFrm.WindowState := wsMaximized;
  finally
  end;

Open in new window


... when you put frame on main form which is not mdiparent but simple form
(can be your TPanel component if want):
var
  frm: TFrame1;
begin
  frm := TFrame1.CreateParented(Self.Handle); // or Panel1.Handle
  frm.Parent := Self;  // or Panel1
  frm.Align := alClient;
  frm.Visible := True;

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 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